Guy Salton is a technical expert on the whole performance testing ecosystem - load testing tools, monitoring tools, CI tools, Networking and Infrastructure. His expertise is helping with POCs and special technical projects for strategic customers. Guy talks at conferences and meetups around the world, writes blog posts and gives webinars.

Learn JMeter in 5 Hours

Start Learning
Slack

Run massively scalable performance tests on web, mobile, and APIs

Nov 10 2016

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.

 

The scripts:

 

---
execution:
- executor: selenium
  concurrency: 1
  hold-for: 5m
  ramp-up: 10s
  locations:
    us-east-1: 1
    us-west-1: 1
    us-west-2: 1
    eu-west-1: 1
    eu-central-1: 1
  scenario: Thread Group
scenarios:
  Thread Group:
    requests:
    - label: blazedemo
      method: GET
      url: http://www.blazedemo.com/

services:
- module: passfail
  criteria:
  - avg-rt of blazedemo>150ms for 30s, stop as failed

---
execution:
- executor: jmeter
  concurrency: 20
  hold-for: 5m
  ramp-up: 60s
  locations:
    us-east-1: 1
    us-west-1: 1
    us-west-2: 1
    eu-west-1: 1
    eu-central-1: 1
  scenario: Thread Group
scenarios:
  Thread Group:
    requests:
    - label: blazedemo_jmeter
      method: GET
      url: http://blazedemo.com/
    - body:
        fromPort: Paris
        toPort: Buenos Aires
      label: reserve
      method: POST
      url: http://blazedemo.com/reserve.php

 

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:

 

Taurus dashboard test automation

 

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 muktiple geolocations

 

CA Blazemeter reports dashboard

 

CA BlazeMeter provides rich reports for analyzing different KPI correlations, trends and discovering bottlenecks. You can read more here.

 

5. Taurus can be added to Jenkins through the ‘Execute shell’ build step. Read more here.

 

jenkins execute shell build step

 

Congratulations! You are now ready to automate your JMeter and Selenium tests in parallel on Taurus and as part of the CI cycle.

 

NEXT STEPS

 

 

 

 

Click here to subscribe to our newsletter.

Interested in writing for our Blog?Send us a pitch!

Your email is required to complete the test. If you proceed, your test will be aborted.