Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Convert Selenium Scripts into the JMX Converter

DZone's Guide to

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.

· Performance Zone
Free Resource

Download our Introduction to API Performance Testing and learn why testing your API is just as important as testing your website, and how to start today.

 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.

Check out this free video tutorial for more information.

Find scaling and performance issues before your customers do with our Introduction to High-Capacity Load Testing guide.

Topics:
convert ,script ,tests ,selenium ,examples ,jmx ,converter ,scripts ,load testing

Published at DZone with permission of Noga Cohen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}