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 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 intend to adopt.
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 effort. 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.
Selenium Grid as a tool for Selenium load testing:
The 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 the 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 load-testing job along with a cluster of nodes to run parallel tests.
In this setup, you can utilize the Selenium grid’s ability to offload tests across different nodes. There is a Selenium plugin available for Jenkins. You need this plugin to set up 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 another tool that 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 that most HTTP tracking tools support.
You can quickly set up BrowserMob Proxy with a Selenium standalone server. 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 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 be more useful for smaller websites or web applications.
Try these add-ons to reduce manual testing efforts: Selenium IDE Firefox Add-ons
Now, it’s time to read some contrary arguments that discourage using Selenium for load testing.
Some Counter Views
While we have seen that Selenium supports load testing, there are counter-views. Let’s hear them out.
Here the author agrees to the fact that we could use Selenium to test load. However, 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 that have native support for load testing like JMeter or Gattling.
SauceLabs is one of the fastest-growing companies that provides a cloud-based solution for Selenium testing. Get more details on SauceLabs from the below blog post.
Since it’s a popular issue that affects the testing fraternity across the industry, we’ve seen experts discussing it on the StackOverflow forum.
According to views on the StackOverflow forum, Selenium grid is a tool that scales the tests to run on multiple nodes. And, you can use it with TestNG to enable Selenium load testing.
Yet, they reject this approach as they feel the idea is not sustainable. There are Selenium grid docs as well to suggest that the above solution is not scalable.
Please refer to this thread from the StackOverflow forum to read more insights on this issue.
Since most of us use Selenium for test automation, 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 about which is the right approach and suits your application’s context.
For us, it’s time to say Bye. Keep looking till you find the solution that 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.