Noga Cohen is a Sr. Product Marketing Manager for CA BlazeMeter. She manages the BlazeMeter blog and other content activities. Noga focuses on creating technological content in the fields of performance, load testing and API testing, both independently and by managing writers who are developers. Noga has more than 5 years of experience in a wide scope of writing techniques: hi-tech, business, journalist and academic.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Sep 13 2016

How to Convert Selenium Scripts into the JMX Converter

In this blog post we will go over converting existing Selenium scripts into JMeter for load testing.


Why Convert Selenium to JMX?


Converting existing Selenium scripts into JMX files enables you to leverage functional Selenium tests and produce load test scripts. Instead of maintaining JMeter scripts and updating them every time your web application changes, you can easily convert from an existing Selenium script. Note that you must have functional Selenium tests and maintain them together during application development. This way, when you want to execute load tests, you have already updated your functional tests.


By using Taurus, an open source automation tool, you can automate this process completely, by building a pipeline of functional Selenium tests. If the Selenium tests passed, Taurus converts them into load tests and runs the load test using JMeter.


How to Convert Selenium to JMX


First, make sure you have the most updated version of Taurus - version 1.6.6 or above. To convert, we will use the Proxy2JMX Converter Taurus module.


taurus proxy2jmx converter


In this example we put the Selenium scripts in the Taurus Examples directory.


Taurus directory


You can check out this example under the Selenium examples directory.


selenium examples directory


Let’s look at this simple config:


jmx config


This config states that the executor is Selenium, it will perform 1 iteration, it uses a scenario that is a script from the “dir” directory and the service it will perform is converting proxy2jmx.


Execute the config by typing bzt convert_to_jmx.yml.


Make sure you have a BlazeMeter account, because behind the scenes, the converter uses the BlazeMeter proxy recorder to record and generate “Smart JMX”. Smart JMX has many benefits: automatic extractors, request cleanup and grouping and top-level configuration items.


You should put your BlazeMeter API key into .bzt-rc file under your home directory, as described here. This is where you hold your personal preferences for Taurus.


Now, run the test. Taurus will launch and execute the Selenium test in Taurus, and also capture the traffic and convert it into JMX by using the proxy. You don’t have to do or change anything in your selenium scripts.


Then, wait for Taurus to finish its job. After the test has finished running, open the resulting JMX with JMeter. The line of the Taurus log starting with “JMX saved into ...” will explain where JMX is stored and under which name.


On the left you will see the structure of the requests.


jmeter jmx request structure


On the right, launch the test in the ‘View Results Tree’ to see how it does with the converted script. The requests are reproduced very accurately.


jmeter view results tree


Congratulations! You can now leverage your functional tests to script your load tests.


Want to learn more? View our webinar Using Taurus to Automate JMeter and Selenium Tests


Check out this free video tutorial for more information.

arrow Please enter a URL with http(s)

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