Jmeter is one of the most used open source performance testing tool. we can use it for different types of load tests like Smoke, Load, Stress, Endurance testing. Jmeter comes with most of the features which helps for regular testing but in some cases we need to go out of box and extend our scripting skill to support client requirement. Jmeter has feature called Plugin Manager which will help us to install new feature into our existing jmeter instance which will support different samplers to satisfy our requirements.

Creating Selenium Scripts with Jmeter: In this post, you will see how to create a selenium script in JMeter. Generally, we will use this Jmeter+Selenium to replace the Load runner Ajax true client protocol. By adding some plugins from the Plugin manager, adding chrome drive or Mozilla driver we can create the script. But we will have a question.

What kind of response time will JMeter + selenium give? Whether it’s giving time taken to get a response or DOM interaction, Dom Loaded or what?

Jmeter + Selenium will give you DOM Content Loaded response time

Q: What is DOM Content Loaded Time?

A: DOM Content Loaded response time = Response time to Download Doc + all Resouces(JS,CSS,images, fonts, etc) + rendering time of your page

Q: Can we get Page wise response time like transaction

A: Yes we can get response time for each page

How to Setup Jmeter to Create Selenium Scripts

Open Jmeter and go to Plugin Manager window like below

After Opening Plugin manager go to available manager tab like below

Search for the Selenium/WebDriver Support and Click Apply changes and Restart Jmeter like below

After installing Selenium web driver it will install the required jar to your JMETER_HOME/lib folder

Note: Sometimes download chrome or firefox driver may not compatible with your current chrome version you can download the supported driver version

For Downloading chrome Driver use below link

https://chromedriver.chromium.org/downloads

Confirm the download driver version will support your chrome browser

How to Start Script Selenium Script

  1. Add Thread Group to Test plan in Jmeter
  2. Add jp@gc – Chrome Driver Config from Config Element

3. Add the download chromedriver.exe path in chrome tab in chrome config

4. We can run the Chrome browser in headless mode and Andriod mobile

5. In Experimental window, we can configure a few more options like creating a new browser for every iteration, etc

7. In the proxy window, if have any proxy connection we can add it

8. Add jp@gc – WebDriver Sampler from Sampler Menu

9. In Web Driver Sampler Jmeter will give access for some object by which we can create script Web driver sampler have below objects available

  1. WDS.name
  2. WDS.parameters
  3. WDS.args
  4. WDS.vars
  5. WDS.ctx
  6. WDS.props
  7. WDS.log
  8. WDS.browser
  9. WDS.sampleResult

10. Below is the sample code to run Jmeterplugin.org page

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

After saving the code you can run the script and see the output like below

for importing new classes in web driver sampler we can you JavaImporter

example :

var jsExecutor = JavaImporter(org.openqa.selenium.JavascriptExecutor);

executeScript is the method in javaScriptExecutor class now we can invoke a method like this

jsExecutor.executeScript("return window.performance.timing");


Thanks

Creating Selenium Scripts with Jmeter

Leave a Reply

Your email address will not be published. Required fields are marked *