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
In this example, we put the Selenium scripts in the Taurus Examples directory.
You can check out this example under the Selenium examples directory.
Let’s look at this simple 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.
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.
Congratulations! You can now leverage your functional tests to script your load tests.
Check out this free video tutorial for more information.