How to Automate JMeter and Selenium Testing and Run Them in Parallel
Continuous Testing and Continuous Integration are the best ways to ensure your product constantly performs optimally. Load testing with JMeter or other tools, and browser testing with Selenium, can be integrated into the CI cycle. This blog post will cover how to automate these tests, and is based on Alon Girmonsky’s talk at Jenkins World 2016, which you can view here.
Using Taurus for Load and Browser Test Automation
Taurus, an open-source test automation framework, can help you automate open-source tools, like JMeter, Selenium, The Grinder, Gatling, Locust and Siege. This lets you run tests automatically and in parallel to achieve better test coverage. If you run the load and functional tests in the cloud, you will also be able to view and analyze test results for JMeter and Selenium through rich reports and identify issues and trends.
A few words about Taurus: Taurus is a command-line tool that lets you define your test universe by using YAML, which is a readable and writeable language, or through the JSON format, which you can generate in your code. Taurus builds and runs the tests in real-time through a configuration file, and then analyzes and communicates the results. Taurus supports multiple cloud locations from different providers: Amazon, Google, Azure, etc.
Automating JMeter and Selenium Tests
How does it work? Let’s look at this example:
1. Download Taurus
2. Build or import 2 scripts: One for Selenium that automates the browser, one for JMeter commands - for reaching scales. If you add thresholds to the test, they will be shown on the Taurus local interface when the results are in.
In these two YAML scripts -
The Selenium script automates the default browser Firefox, for this url - http://www.blazedemo.com/, from 5 different locations, for a 10 second ramp-up, for a full test duration of 5 minutes and for 1 VU. We also added pass/fail criteria - if the average response time is more than 150 milliseconds for more than 30 seconds, the test will stop as failed.
The JMeter script tests 2 requests - one GET request to http://blazedemo.com, one POST request to http://blazedemo.com/reserve.php, with 2 body parameters. The test is run from 5 different locations, for a 60 second ramp-up, for a full test duration of 5 minutes and for 20 VUs.
3. Run the test locally at first, to ensure it runs well before committing it. Your browser will probably open up many times during the test run - this is normal.
Both systems are operated by Taurus and run in parallel on the local machine. They can be viewed in real-time. This is the Taurus dashboard for these two tests:
In the top right you can see the two tests running in parallel (JMeter: Thread Group; Selenium: test_requests.py). Taurus can run Selenium from different programming languages such as Java, Python and Ruby. The default language is Python.
In the top right, the alert for the pass/fail criteria that is about to be met, is displayed.
In the middle you can see the cumulative statistics (for Selenium and JMeter) for the requests in different KPIs, such as latency, connect time, error rate, etc.
4. Now, run the tests in the cloud by adding -cloud to the command line. The tests will be opened in CA BlazeMeter and run in parallel from multi geolocations.
CA BlazeMeter provides rich reports for analyzing different KPI correlations, trends and discovering bottlenecks. You can read more here.
Congratulations! You are now ready to automate your JMeter and Selenium tests in parallel on Taurus and as part of the CI cycle.
- Want to learn more? View our webinar Using Taurus to Automate JMeter and Selenium Tests.
- Click here to learn more about load testing with BlazeMeter.
- View a recording of our London meetup to see how to run tests in Taurus: