LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

Running Selenium scripts with JMeter

I have Selenium automation scripts ready with functional flow, now I want to integrate those scripts with JMeter for load-testing. Is that possible?If so how to integrate both? My first aim is to run the automation script using selenium than run those scripts in jmeter for load or performance testing.

Up Vote Down Vote 5 Votes
Posted 5 months ago


How to run selenium script in JMeter

Content source - QA Automation Blog

JMeter was originally built to provide an open source solution for load and performance testing. but JMeter can also be used for functional testing.

Selenium scripts can be executed in jmeter by selenium web driver.

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.

Why needed? With the advancement of technology, HTML5, JS and CSS improvements, more and more logic and behaviour have been pushed down to the client. Things that add to the overall browser execution time may include:

  1. Client-side Javascript execution – eg. AJAX, JS templates
  2. CSS transforms – eg. 3D matrix transforms, animations
  3. 3rd party plugins – eg. Facebook like, Double click ads, site analytics, etc

All these things add to the overall browser execution time,

This adds to the overall perceived performance of website/webapp, but this metric is not available in JMeter. JMeter is not a real browser so we cant measure the user experience at client side ,like page rendering/load time.

Performance mix is the practice to test application user experience while performing a load test. Web Driver Sampler automates the execution and collection of Performance metrics on the Browser (client-side). 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.


  1. JMeter must be installed on your system if not then refer here.
  2. Install the Webdriver Set plugin using the JMeter Plugins Manager.
  3. Write your WebDriver script as usual, then add “Thread Group” to your “Test Plan.”

Add below JMeter elements to test plan.

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

The result is as follows:

Add below code to WebDriver and modify as per your business scenario :

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

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

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

//Enter user name
var txtUserName = WDS.browser.findElement('userName')); //saves username field into txtUserName
txtUserName.sendKeys(['mercury']); //enter 'mercury' in user name"Enter UserName");

//Enter password
var txtPassword = WDS.browser.findElement('password')); //saves password field into txtPassword
txtPassword.sendKeys(['mercury']); //enter 'mercury' in password"Enter password");

//Click Sign in button
var btnLogin = WDS.browser.findElement(pkg.By.xpath('//input[@name=\'login\']')); //saves login field into btnLogin;

//Click sign off link
var lnkSignOff = WDS.browser.findElement(pkg.By.xpath('//a[@href=\'mercurysignoff.php\']')); //saves sign off field into lnkSignOff;

Up Vote Down Vote 2 Votes
Posted 5 months ago