Probably you are working on a large web application and using Selenium for UI testing. And now trying to find out whether you can use it for load testing or not. But let us tell you that there isn’t an easy answer to this question. Because the experts have different opinions both in favor and against doing Selenium load testing. Since there is no consent in this respect, so it’s up to you which expert advice you intend to adopt.
Although, there is no doubt that we can use Selenium for load testing. For example, it has components like Selenium Grid and supports tools like BrowserMob that can help us in achieving our goal. But all of it requires us to make some adjustments to let it work for load testing.
Also, using Selenium for load testing would depend on the type of requirement you have. And setting up all this is going to take significant time and efforts. So you must play wise before going with Selenium for load testing.
Hence, first of all, let’s begin reviewing the options available that could probably get us to a working Selenium load testing solution. Then only, you can either deny or accept any of the two views.
Selenium Load Testing – Why and How Should You Do It?
First of all, let’s check out the options that endorse Selenium for load testing. And, then you might go into seeing the contrary views.
Why and How to Do Selenium Load Testing?
Selenium Grid as a tool for Selenium load testing.
Selenium grid is one of the scarcely used Selenium components. It supports parallel execution of Selenium tests on different browsers. Most of all, it works on the master-slave model to run the tests. Hence, using it for load testing could be the best choice.
You can prepare a load testing setup using Selenium grid and Jenkins. It’s an open source CI tool for executing automation tasks. It can support using multiple slave nodes to run concurrent Selenium tests. In Jenkins, you would need to create a Selenium load testing job along with a cluster of nodes to run parallel tests.
In this setup, you can utilize Selenium grid’s ability to offload tests across different nodes. There is a Selenium plugin available for Jenkins. You need this plugin to setup a test grid to eliminate a lot of manual hassles.
Consequently, If you want to run this kind of setup, then you would also need to procure the right hardware.
For example, the VMWare ESXI is the rightmost candidate for creating and running nodes on the fly. For auto spinning of virtual nodes, you can use the vSphere Cloud Plugin in Jenkins.
This plugin offers unique build steps to start/stop nodes on the ESXI server. You’ve to modify the Selenium load testing job in Jenkins to add the cloud plugin build steps.
BrowserMob Proxy for Selenium load testing.
BrowserMob Proxy is an another tool which probably provides the best integration with Selenium. It filters and tracks performance stats for web applications. It archives traffic in HAR (HTTP Archive format) and performs the blacklisting/whitelisting of the content. HAR is a standard format which most HTTP tracking tools support.
You can quickly setup BrowserMob Proxy with Selenium standalone server to carry out load testing. Here is a summary of steps to follow for preparing the Selenium load testing environment.
- Get the latest version of BrowserMob Proxy.
- Launch the BrowserMob Proxy.
- Start a new project while adding BrowserMob and Selenium Standalone Server jars.
- Initiate the execution.
- Now you’ll see the proxy server getting started and logs being visible.
- After the execution, check the HAR file containing the performance logs.
- Try using a free HAR file analyzer and verify the performance results.
Selenium IDE JMeter Add-on for Firefox.
Another option to worth trying is installing the JMeter add-on for Selenium IDE.
You can read about this add-on from our last blog post. It might help you set up the Selenium load testing.
By the way, it would more useful for smaller websites or web applications.
Now, it’s time to read some contrary arguments that discourage using Selenium for load testing.
Some Counter Views on Selenium Load Testing.
Here the author agrees to the fact that we could use Selenium to test load. But he emphasizes that it’s not a tool designed for load testing. And it could be expensive to go with it.
Rather he suggests going for tools which have native support for load testing like JMeter or Gattling.
SauceLabs is one of the fastest growing company which provides a cloud-based solution for Selenium testing. Get more details on SauceLabs from the below blog post.
Since it’s a popular issue which affects the testing fraternity across the industry, we’ve seen experts discussing it on the StackOverflow forum.
There are views which say that Selenium grid is a tool which can scale the tests to run on multiple nodes. And, you can use it with TestNG to produce a Selenium load testing solution.
Finally, they reject this approach as they feel the idea is not sustainable. There are Selenium grid docs to suggest that the above solution is not scalable.
Please refer this thread from StackOverflow forum to read more insights on this issue.
Since most of us use Selenium for test automation, so it’s valid to ask why should we not use it for load testing. Hence, we tried to address this issue at length and brought in different views. Now the ball is in your court, and you must think which is the right approach and suits in your application’s context.
For us, it’s time to say Bye. Keep looking till you find the solution which is right for you. Also, if this post on Selenium for load testing was able to help, then don’t mind sharing it with others.