Using Selenium with JMeter

To use Selenium Webdriver with JMeter, install “Webdriver” plugins. The WebDriver sampler is useful if you want to test for performance AJAX or GWT based web applications.

Download WebDriver plugins from

Unzip the files and copy in the lib folder under JMeter home directory.

To test if WebDriver plugins installed open Jmeter and test if there is jp@gc – Firefox Driver Config.

*If not, check your JMeter’s lib folder.
 Selenium Webdriver SamplerAdd the Webdriver sampler and Firefox or chrome driver config element. Insert the following code to launch Bing search and search for a text. Also add tree listener to view the result.
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(
var wait = new support_ui.WebDriverWait(WDS.browser, 20000)
var searchField = WDS.browser.findElement('sb_form_q'))
var button = WDS.browser.findElement('sb_form_go'))
Explanation of the code
  • The code starts with the import Java packages “org.openqa.selenium” and “” which will allow you to use the WebDriver classes.
  • WDS.sampleResult.sampleStart() and WDS.sampleResult.sampleEnd() captures sampler’s time and will track it. You can remove them, the script will still work but you will not get load time
  • WDS.browser.get(‘’) – opens the browser with Bing search website
  • var searchField = WDS.browser.findElement(‘sb_form_q’)) – saves the search text box in searchField varialble
  • – Clicks the search field to make it active
  • searchField.sendKeys([‘testing’]) – Enters text to search
  • var button = WDS.browser.findElement(‘sb_form_go’)) – Saves search button in a variable
  • – clicks on the search button.

You are now ready to go. Do let us know your experience in using Selenium with JMeter

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.