The WebDriver executes real web browser interactions with your web-application. Running WebDriver virtual users alongside with HTTP virtual users allows to capture both network and real-user experience performance metrics. The WebDriver action uses the JMeter WebDriver sampler under the hood. It simulates real browser interactions by launching a web browser like Firefox.
The Selenium WebDriver action has several configuration options:
- Name: the name of the action. This name appears in test results,
- Script: contains the Selenium webdriver script to execute,
- Requests and Responses: when executing a virtual user validation, it shows the played request and the received server response.
WebDriver script edition
For more advanced usage of the web driver action, it is recommended to look at the official documentation.
Each webdriver action will take over the context from the previous action. Using this you can have a distinct action for each step. This way you get a response time for each page in a different webdriver action and if you name them right the report will be easy to use.
We take care of the infrastructure. But, launching real browser to gather end-user experience performance metrics consumes a lot of resources. As a consequence, the number of concurrent WebDriver virtual users has been drastically limited.
We strongly recommend running only a single WebDriver virtual user to collect real browser metrics during a load test. The purpose of this kind of virtual user is not to simulate the load. Load must always be simulated using regular HTTP actions.
Advanced script example¶
This script is a more advanced example created on our demonstration application:
var pkg = JavaImporter(org.openqa.selenium); var ui = JavaImporter(org.openqa.selenium.support.ui); //Clear cache and cookies in case the script runs several iterations WDS.browser.manage().deleteAllCookies(); // 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("https://petstore.octoperf.com/actions/Account.action?signonForm="); // Entering login and password WDS.browser.findElement(pkg.By.name("username")).clear(); WDS.browser.findElement(pkg.By.name("username")).sendKeys(['user1']); WDS.browser.findElement(pkg.By.name("password")).clear(); WDS.browser.findElement(pkg.By.name("password")).sendKeys(['pass']); var signon = WDS.browser.findElement(pkg.By.name("signon")); signon.click(); //Waiting for the logout link to appear as confirmation var waitLogin = new ui.WebDriverWait(WDS.browser, java.time.Duration.ofSeconds(120)); waitLogin.until(ui.ExpectedConditions.elementToBeClickable(pkg.By.linkText("Sign Out"))); // End the test sampler, capturing length of time for the test. WDS.sampleResult.sampleEnd();