Bob Meliev

Using Selenium with JMeter's WebDriver Sampler

Posted by Bob Meliev


To use Selenium Webdriver with JMeter, simply install "Webdriver Set" plugins. The WebDriver sampler is useful for testing the performance of AJAX, GWT-based Web applications, and simulated user actions.
Download WebDriver plugins:
Unzip archive:
Unzipped files must be in the lib/ folder. To determine if WebDriver plugins are installed, open Jmeter and test if there is jp@gc - Firefox Driver Config. If not, check your JMeter's lib folder.
WebDriver plugins installed open Jmeter - Firefox Driver Config.
Write your WebDriver script as usual, then add "Thread Group" to your "Test Plan."
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:
add "Thread Group" to your "Test Plan"
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)
var support_ui = JavaImporter(
var wait = new support_ui.WebDriverWait(WDS.browser, 5000)
var searchField = WDS.browser.findElement('search_form_input_homepage'))
var button = WDS.browser.findElement('search_button_homepage'))
var link = WDS.browser.findElement(pkg.By.ByCssSelector('#r1-0 > div.links_main > h2 > a.large > b')) + ' has logged an entry');
(Don't worry if the entire code doesn’t seem clear yet. We'll revisit it below.

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

 "Thread Group" values must be 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. 


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('search_form_input_homepage')) - Saves the search field into searchField variable.
  • - Clicks the search field.
  • searchField.sendKeys(['blazemeter']) - Types “blazemeter” in field
  • var link = WDS.browser.findElement(pkg.By.ByCssSelector('#r1-0 > div.links_main > h2 > a.large > b')) - Saves selector as variable but uses CSS.
  • + ' has logged an entry') - Logs a message.


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 format
All captured data can be manually converted to the WebDriver format(see below).
captured data can be manually converted to WebDriver format.


To launch the WebDriver test in the cloud with more concurrent users on BlazeMeter, use Firefox, which is the only currently supported browser for use with WebDriver. Create a new test and upload your JMX file to run it.
Before uploading your JMeter script, it’s best to remove/disable View Results Tree, which can slow test performance. After a few minutes, reports will generate.
BlazeMeter's load reports
We launched the test with 40 concurrent users, as noted in the response time (*see the Monitoring tab).
BlazeMeter's Monitoring Tab-load testing results
Although we launched the test with only 40 users, the CPU is fully utilized from the outset. This is precisely why each sampler starts one browser. Be sure to take this into account when writing tests.


When using the WebDriver plugin, in order to perform better load testing, assemble the Selenium tests with JMeter tests. The number of WebDriver samplers should be fewer than the number of JMeter samplers. If you need any values from websites through Ajax, you can use WebDriver with the Once Only Controller to avoid continual/duplicate browser launches.