Running Selenium tests in JMeter

19 Feb

To use Selenium Webdriver with JMeter install webdriver plugins

http://jmeter-plugins.org/downloads/file/JMeterPlugins-WebDriver-1.1.1.zip

  • Add “Thread Group”
  • Add “Config Element” -> “HTTP Cookie Manager”, “Config Element” -> “jp@gc – Firefox Driver Config”
  • Add “Sampler” -> “jp@gc – Web Driver Sampler”
  • Add “Listener” -> “View Results Tree”
  • add "Thread Group" to your "Test Plan"
  • In Web Driver Sampler(2)  add the following code
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)

WDS.sampleResult.sampleStart()
WDS.browser.get('http://example.com')
wait.until(conditions.presenceOfElementLocated(pkg.By.linkText('More information...')))
var element=WDS.browser.findElement(pkg.By.linkText("More information..."))
element.click()
WDS.sampleResult.sampleEnd()
  • Run the test

Note: if you find any issue with browser connection. Downgrade the firefox and try.( i tried with 25.0). Also by increasing the thread you can run multiple browser instance.

Advertisements

One Response to “Running Selenium tests in JMeter”

  1. glinius 06/28/2015 at 6:50 pm #

    Thanks for the information. In my turn I would recommend getting familiar with The WebDriver Sampler: Your Top 10 Questions Answered guide as WebDriver Sampler uses JavaScript as a language and even common things like wait for element, take screenshot or determine which browser versions are supported are not obvious and information on it is missing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: