In the previous posts, we explained the concept of browser-level load testing and the importance of running real browser load tests. In this blog post we explain how to leverage your Selenium scripts to execute browser-level load testing.
Related: To learn more about load testing download the eBook
– Load Testing Buyer’s Guide.
Selenium is a free and open-source automated testing framework for web applications. It is one of the most popular and widely-used browser automation testing tool. Using Selenium helps users validate web applications across different real browsers and platforms.
Using Selenium scripts in load testing can serve 2 purposes:
- Running many real browsers to create true load tests that simulates many concurrent users
- Running a few real browsers to create toad tests that simulates few concurrent user to measure user experience while creating the massive load with protocol level scripts that simulate many concurrent users
To achieve browser level testing, WebLOAD has the ability to execute load tests using Java Selenium scripts. There are a few ways to run Selenium with WebLOAD, the simplest one is to take the Java Selenium scripts and execute them in WebLOAD.
In order to that, small additional changes to the script are required to make it interact with WebLOAD. This can be done without breaking the original functionality – the enhanced script can still be executed in a regular test automation environment where the additional changes are ignored.
WebLoadDriver
Selenium WebDriver is an open-source collection of APIs for controlling browsers. Selenium WebDriver speaks directly to the browser and uses the browser’s own engine to control it. It enables you to execute cross-browser testing.
WebLoadDriver wraps Selenium WebDriver, implementing all Selenium WebDriver methods and enriches it with performance and load testing functionality with dedicated methods.
For example:
Note that except for wrapping the original driver with WebLOADDriver, the Selenium code stays the same.
Collecting Performance Metrics
WebLoadDriver has several capabilities which are important for performance testing.
Running real browser load is not enough for performance testing, collecting and measuring performance metrics is also needed. WebLOADDrivers has the tools to do this.
The most important capabilities needed and are a part of WebLoadDriver are:
- reportStatistics – This method interacts with the browser and collects the browser’s last navigation timings. It includes information such as load time, rendering time, dom integration, DNS time, time to first byte, etc.
- Transactions – Transaction is a load testing concept that measures a whole business process from start to end. WebLoadDriver introduces 2 methods to deal with transactions: beginTransaction and endTransacation.
Let’s enhance the previous example with the performance metrics collection.
That’s it! The selenium code is WebLOAD ready!
Just a reminder – this script is not limited to the WebLOAD environment – It can still run in a regular automation environment where the WebLOAD extensions will be automatically ignored.
Executing Selenium scripts in WebLOAD
When the Java Selenium script is ready, WebLOAD can execute it in the standard way it executes any Java code.
First, bind WebLOAD JavaScript context to the Java.
Second, instantiate Selenium Java Object and execute its methods.
Now this WebLOAD script can run and have it execute the Selenium script.
Learn more how to Selenium scripts in WebLOAD, schedule a DEMO with us.