JMeter Selenium Webdriver

The JMeter Selenium Webdriver sampler is useful for testing the performance of AJAX, GWT-based Web applications, and simulated user actions.

To use Selenium Webdriver with JMeter, simply install “Webdriver Set” plugins.

Write your WebDriver script as usual, then add “Thread Group” to your “Test Plan.”

JMeter Selenium Webdriver

Add Config Element -> HTTP Cookie Manager, Config Element -> jp@gc – Firefox Driver Config, Sampler -> jp@gc – Web Driver Sampler, Listener -> View Results Tree.

The result is as follows:

JMeter Selenium Webdriver

You do not need to configure two config elements – you may omit that step. Open the “Web Driver Sampler” and add this code:

var pkg = JavaImporter(org.openqa.selenium); //WebDriver classes
var support_ui = JavaImporter(; //WebDriver classes
var wait = new support_ui.WebDriverWait(WDS.browser, 5000);

WDS.sampleResult.sampleStart(); //captures sampler's start time
WDS.sampleResult.getLatency();"Sample started");

WDS.browser.get(''); //opens website specified in ''"Sample ended - navigated to");

var searchField = WDS.browser.findElement('search_form_input_homepage')); //saves search field into searchField; //clicks search field
searchField.sendKeys(['blazemeter']); //types word "blazemeter" in field"Searched for BlazeMeter");

var button = WDS.browser.findElement('search_button_homepage')); //Find Search button; //Click Search Button"Clicked on the search button");

var link = WDS.browser.findElement(pkg.By.cssSelector('#r1-0 > div > h2 > a.result__a > b')); //also saves selector as variable but uses CSS.; //Click the search result's Link


Now, try to start your test. Whatever you do, DO NOT change the “Thread Group” values. They must all be set to 1.

You should see the new Firefox window that will open the website. Search for “BlazeMeter.” After the test has started, open View Results Tree to confirm there are no errors. If the Response Code is “200” and the Response Message is “OK,” the test was run successful. If not, check the WebDriver script for errors. 

Code Review

Our code starts with the import Java packages “org.openqa.selenium” and “” that allow you to use the WebDriver classes.  

If you want to use any of the packages, import them with JavaImporter:

var action = JavaImporter(org.openqa.selenium.PACKAGENAME.CLASSNAME)

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:

Load Time-JMeter WebDriver Sampler
  • WDS.browser.get(‘’) – Opens the website
  • var searchField = WDS.browser.findElement(‘wp-block-search__input-1’)) – Saves the search field into searchField variable.
  • – Clicks the search field.
  • searchField.sendKeys([‘jmeter’]) – Types “JMeter” in field
  • var link = WDS.browser.findElement(pkg.By.ByCssSelector(‘#r1-0 > div > h2 > a.result__a > b’)) – Saves selector as variable but uses CSS.
  • + ‘ has logged an entry’) – Logs a message.

How to Use Selectors

To simplify the use of selectors, install the Selenium IDE add-on. Selenium IDE is a Firefox add-on with a recording option for actions in the browser. To get similar selectors, download and install the add-on. (Be sure to download the .xpi file.)

Open Duck Duck Go and Selenium IDE. Set the Selenium IDE’s base URL Type “blazemeter” and click Search. If you open Selenium IDE, you see the captured actions and selectors.

Webdriver JMeter Selenium Blog

All captured data can be manually converted to the WebDriver format(see below).

captured data can be manually converted to WebDriver format.

Leave a Reply

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