Probably you are working on a large web application and seems like using Selenium for automating its workflows. And trying to find out whether you should consider Selenium 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 want to adopt.
Although, there is no doubt that we can use Selenium for load testing. For example, it has Selenium Grid and Remote Webdriver components that can help us in building a high-end setup. But it’s not something inherent in Selenium, so you’ll need to make 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 – Should You Do It or Not?
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.
1- Selenium load testing pros.
1.1- Using 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.
1.2- Using 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.
1.2.1- Get the latest version of BrowserMob Proxy.
1.2.2- Launch the BrowserMob Proxy.
1.2.3- Start a new project while adding BrowserMob and Selenium Standalone Server jars.
1.2.4- Initiate the execution.
1.2.5- Now you’ll see the proxy server getting started and logs being visible.
1.2.6- After the execution, check the HAR file containing the performance logs.
1.2.7- Try using a free HAR file analyzer and verify the performance results.
For more information on using BrowserMob, refer the online documentation.
1.3- Use 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 setting 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.
2- Selenium load testing cons.
2.1- Views as seen on SauceLabs.
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. Please refer this page for details.
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.
2.2- Views from StackOverflow.
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.