As an open source test automation tool, Selenium has gained immense popularity with organizations of all size. Wouldn’t it be nice if you could leverage your investment in Selenium functional test scripts towards load testing and see how your system behaves under a large volume of simultaneous users?
You can now do this and leverage your investment using a built-in integration between Selenium and WebLOAD, a performance testing platform.
What kind of load can you generate with Selenium?
You have two options for running load testing using Selenium WebDriver:
Selenium Browsers. This method will let you generate a limited load, since a browser is a resource-intensive component. The number of machines and their capacity will determine the load you can generate. An average machine can probably run about 10-20 web browsers, so that in practice, even running 50-100 Selenium WebDrivers in parallel will require plenty of computing resources.
Headless browsers. Because they lack GUI, Selenium headless browsers (like PhantomJS or HtmlUnit) are lighter. You’ll be able to generate a heavier load using the same number of load generator machines. The downside is that you’ll be losing the ‘real-life simulation’ effect, since you will not be able to measure the GUI. For example, rendering time and full load time cannot be measured in headless browsers.
Combining Selenium with WebLOAD for larger-scale load testing
Typically, load testing is done by simulating protocol-level clients. Put differently, rather than run 500 browsers, you simulate 500 client users and run them all from a single load generator machine. This method, by the way, is used by both commercial and open source load testing tools.
Protocol-level virtual clients let you generate massive load of hundreds or thousands of clients using less hardware resources and greater management capabilities. Remember that in load testing your goal is to validate server behavior (such as response time), rather than client-side behavior.
Using WebLOAD, you can combine Selenium browsers together with protocol-level virtual users. This offers two advantages:
- Script reuse – you can reuse functional tests already built with Selenium towards load testing. A WebLOAD plugin ‘transforms’ your Selenium script, adding necessary load-oriented elements like transaction measurements.
- Real user experience – you can measure and evaluate not only the server-side behavior under load, but also the user experience with a real browser.
Building Selenium Scripts for load testing
You have two options to create Selenium script towards load testing:
- Record a script in Selenium. You record a script in Selenium and then, using WebLOAD’s Selenium plugin export the script to be used in WebLOAD. This makes slight changes to the regular Java WebDriver code to allow WebLOAD to execute it and to collect performance measurements.
- Add code to your existing script. Make changes by yourself by adding code snippets.
Executing Selenium scripts and viewing results
Once your script is ready, you run it using the WebLOAD Console, with WebLOAD executing the Selenium WebDriver.
WebLOAD activates the Selenium WebDriver directly and collects measurements from both the browser and the servers. You can view detailed graphs that correlate the load generated on the website with navigation timing data related to all web pages, or to a specific page.
Free WebLOAD Trial
The free version of Webload lets you run a 50-user load for free, and includes the full Selenium integration. You can try it here.