Skip to content

Selenium WebDriver

Virtual users simulating Real-browser interactions can be created with the new Selenium WebDriver option. While JMeter virtual users are simulating user activity by sending http requests, WebDriver virtual users are simulating real browser interactions.

Running real-browser virtual users along with regular JMeter virtual users allows to capture real-user experience performance metrics.

Selenium Recording

The Selenium IDE is perfectly suited for recording Selenium scripts. It allows to record browser user interactions directly within Firefox.

Selenium IDE

For more information explaining how to record or write Selenium scripts, please take a look at the Selenium documentation.

Create Virtual User: WebDriver

Simply enter the URLs you want your virtual user to visit:

Create Virtual User from URLs

You need to enter valid URLs and include the protocol (I.e. http://doc.octoperf.com).

Import Selenium Script

To import an existing selenium script, follow the procedure above to create a sample virtual user. Then, replace the generated script by your own Selenium WebDriver script.

Script edition

Once the virtual user is created, the virtual user contains a WebDriver action with a sample Selenium script.

Selenium Sample Script

Scripts can be added, edited or removed. A Selenium Web Driver virtual user cannot mix WebDriver scripts with regular HTTP requests for performance reasons.

Advanced script example

This script is a more advanced example created on our demonstration application:

import openqa.selenium.OutputType.*;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;

// Required to start counting time which will get reported at the end of this code.
WDS.sampleResult.sampleStart();

// Load the login page
WDS.browser.get("http://petstore.octoperf.com/actions/Account.action?signonForm=");

// Entering login and password
WDS.browser.findElement(By.name("username")).clear();
WDS.browser.findElement(By.name("username")).sendKeys( new String[] { "user1" } );
WDS.browser.findElement(By.name("password")).clear();
WDS.browser.findElement(By.name("password")).sendKeys( new String[] { "pass1" } );
WebElement signon = WDS.browser.findElement(By.name("signon"));
signon.click();

//Waiting for the logout link to appear as confirmation
WebDriverWait waitLogin = new WebDriverWait(WDS.browser, 30);
waitLogin.until(ExpectedConditions.elementToBeClickable(By.linkText("Sign Out")));

// End the test sampler, capturing length of time for the test.
WDS.sampleResult.sampleEnd();