Skip to main content

Selenium Virtual User Scripts

Selenium Virtual User (VU) scripts are written using the Java programming language, and use Selenium WebDriver to automate web browsers. Selenium WebDriver provides an object-oriented API that provides a common interface for driving all of the major browsers (Internet Explorer, Firefox, Chrome, IPhone, etc.). It can also drive the HtmlUnit GUI-less browser, which is the fastest and most lightweight implementation of WebDriver, and hence is the most appropriate choice for a load testing application.

Each Selenium VU represents a single WebDriver instance. This instance can be accessed in your scripts by calling the getWebDriver() method:

Example

import org.openqa.selenium.By;
...

WebElement logInLink = getWebDriver().findElement(By.linkText("Log in"));

This code gets the VU's WebDriver instance, and then uses the findElement() method to find the Log in link on the current page.