Now that Jmeter has a webdriver sampler, is there anything that regular selenium can do to test a UI, that Jmeter still can't?

For example, I use Selenium in Java to do things like getting html attributes of an element element.getAttribute("title");

and waiting for conditions up to a maximum time

Wait<WebDriver> customWait = new FluentWait<WebDriver>(driver)
           .withTimeout(15L, TimeUnit.SECONDS)
           .pollingEvery(1, TimeUnit.SECONDS)

switching between windows, and more.

I've seen some example code for the Webdriver sampler here: http://jmeter-plugins.org/wiki/WebDriverSampler/?utm_source=jpgc&utm_medium=link&utm_campaign=WebDriverSampler

But it doesn't show how to accomplish tasks like the above - only how to send keys and click on elements.I can't find any documentation online regarding how to use the Webdriver sample to accomplish tasks like the above and others.

Is it possible to do these using Jmeter's webdriver sampler?

Besides these examples, what are other things you can do in Selenium, which Jmeter's webdriver sampler can't yet do?

5 Answers 5


I believe that answers to your questions and more are in the The WebDriver Sampler: Your Top 10 Questions Answered guide.

In particular:

  1. Get data from WebDriver Sampler into JMeter variable:

    You can pass data to JMeter via WDS.sampleResult.setResponseHeaders() method (body and message are being overwritten by the WebDriver Sampler). Once you set the headers you can fetch the data via Regular Expression Extractor. If you need to pass multiple variables headers can be split via \n delimiter like

    If you need to extract multiple values and more headers, you can use the “\n” delimiter. Here’s an example of how this is used correctly:

    WDS.sampleResult.setResponseHeaders('Header_1_Name: Header_1_Value' + '\n' + 'Header_2_Name: Header_2_Value')
  2. In order to wait for some element to appear in DOM use the following approach:

    var pkg = JavaImporter(org.openqa.selenium)
    var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
    var conditions = org.openqa.selenium.support.ui.ExpectedConditions
    var wait=new support_ui.WebDriverWait(WDS.browser, 10)
    wait.until(conditions.presenceOfElementLocated(pkg.By.linkText('More information...')))
    var element=WDS.browser.findElement(pkg.By.linkText("More information..."))
  3. To switch between windows refer to the following code snippet

    var handles = WDS.browser.getWindowHandles()
    var iterator = handles.iterator()
    var counter = 1;
    while (iterator.hasNext())
       var handle = iterator.next()
       WDS.log.info('Window ' + counter + ' title = ' + WDS.browser.getTitle())

Hope this helps.

  • 1
    Answers with only a link are discouraged because if the link moves or vanishes, your answer is no longer useful. Please try to summarize what information can be found at the link Commented Sep 22, 2014 at 17:22
  • Corrected the answer according to your comment, thanks.
    – Dmitri T
    Commented Sep 23, 2014 at 7:20

Imagine a jackhammer with a Phillips-head screwdriver welded onto the handle. You could, in theory, use this modified jackhammer for screwing things together, but you probably wouldn't want to.

JMeter is a tool for performance testing. Selenium is a tool for functional testing. I talk about the differences between the two kinds of testing here.


Agree with @user246 JMeter is for load testing and recommended to use WebDriver in JMeter paralel with load tests for Ajax applications. But if you run WebDriver sampler in "Once Only Controller" you are fine. Here you can find article about JMeter WebDriver sampler.

  • I'm not sure this is relevant to the original question. The article you linked talks about using Selenium with JMeter, not using JMeter instead of Selenium.
    – Kate Paulk
    Commented Sep 24, 2013 at 11:43
  • @KatePaulk Pat Meeker, asked "Is it possible to do these using Jmeter's webdriver sampler?" and link is the answer to his question.
    – Bob Meliev
    Commented Sep 25, 2013 at 6:04
  • I think everyone would be better served if you extracted the relevant portions of the link (helps to prevent link rot) and then the answer can be evaluated strictly on its content as opposed to outsourcing that content.
    – corsiKa
    Commented Sep 29, 2014 at 16:07

just my 5 cents - you can use a WebDriverRemote in jmeter, controling it with java||groovy code in JSR223 samples. You just start chromedriver.exe (or what is its equivalent on *nix OS) and then import org.openqa.selenium (the jar must be in ur jmeter classpath) and you get the full power of selenium webdriver integrated in the jmeter scenario. Hope that helps.


To get the auth token oauth(implementation) using WDS Jmeter 5.5 and Java 8

var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var conditions = org.openqa.selenium.support.ui.ExpectedConditions
var wait = new support_ui.WebDriverWait(WDS.browser, java.time.Duration.ofSeconds(120))
var jmeterVariables = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables();


var userName = WDS.browser.findElement(pkg.By.xpath("//input[@class='amplify-input amplify-field-group__control' and @name='username']")); 

var password = WDS.browser.findElement(pkg.By.xpath("//input[@class='amplify-input amplify-field-group__control' and @name='password']")); 

var signInbutton = WDS.browser.findElement(pkg.By.xpath("//button[@class='amplify-button amplify-button--primary amplify-field-group__control amplify-authenticator__font']")); 


var dashboard=WDS.browser.findElement(pkg.By.cssSelector('.p-menuitem-link.router-link-active.router-link-active-exact')).getText()
WDS.log.info("Dashboard text " +dashboard);

var tokenStorageValue  = WDS.browser.executeScript('return window.sessionStorage.getItem("auth-mod")')
WDS.log.info("Token storage value is " +tokenStorageValue);

var value = JSON.parse(tokenStorageValue);
WDS.log.info("User Token Value is " +value.userToken);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.