Jmeter | Integrated with Selenium webdriver

Priyank Shah
3 min readDec 11, 2017

As a performance engineer, I would like to know page rendering time (Not the only response time) using Jmeter.

Problem (Actual Need):

You want to load test your application and get user response times including page rendering. You usually use JMeter for load testing but the issue is that JMeter is not a real browser, so the reported response times do not include page rendering. As shown in below image, we will get [X2 — X1] easily using Jmeter BUT not [X4 — X1].

Solution:

Thanks to JMeter eco-system, It is very rich, so there is a solution for this, we will use:

Implementation:

A) The easiest way to get the plugins is to install Plugins Manager. Then you’ll be able to install any other plugins just by clicking chekbox. Plugins Manager is available from “Options” menu of JMeter.

Download plugins-manager.jar and put it into lib/ext directory, then restart JMeter.

B) Install the Webdriver using the JMeter Plugins Manager

C) Add Config Element -> HTTP Cookie Manager, Config Element -> jp@gc — Firefox Driver Config, Sampler -> jp@gc — Web Driver Sampler, Listener -> View Summay report.

D) Open the “Web Driver Sampler” and add this code. (By default, below code should already be present)

WDS.sampleResult.sampleStart()
WDS.browser.get(‘http://jmeter-plugins.org')
WDS.sampleResult.sampleEnd()

Difficult to understand? We’ll revisit it soon.

Now, try to start your test. You should see the new Firefox window that will open the website.

Let’s understand a code bit:

More info: list of WebDriver’s packages.

WDS.sampleResult.sampleStart() and WDS.sampleResult.sampleEnd()captures the sampler’s time and tracks it. You can remove them. The script will still work, but you can’t get load time:

WDS.browser.get(‘http://jmeter-plugins.org') — Opens the website http://jmeter-plugins.org

Note:

  • Using Selenium tests in JMeter is rather easy and allows you to reuse your Selenium Functional Testing for Load Testing.
  • Using Webdriver limits your capacity to scale due to its high usage of CPU as you nearly use 1 CPU core per every virtual user.
  • So effiecive way is to mix it with a regular JMeter load Test. This way, the regular JMeter Load Test will put enough load on your system while the JMeter WebDriver plan will allow you to get the user experienced response times including page rendering.

--

--

Priyank Shah
Priyank Shah

Written by Priyank Shah

Agile Product Leader | Delivery Manager | Design Thinker (PRINCE2, CSPO™, CSM™, SFC™, ISTQB)

Responses (1)