iMacros is part of the Ipswitch family of tools and services. Learn More »

Load and Performance Testing: How to Use iMacros with JMeter

by / Wednesday, 20 May 2015 / Published in Tips and Tricks

Using iMacros with JMeter, you can perform load tests with 100% realistic testing data to accurately reflect true end-user experiences. Most load testing tools simulate only the server side traffic that is generated by the browser at the HTTP layer. iMacros makes the difference by testing the complete web application inside the browser on the client side (iMacros Browser, Internet Explorer, Firefox and Chrome). This includes load testing websites with AJAX, Flash, Flex, Silverlight or Java applets. So, the metrics collected by JMeter when using iMacros render the overall browser execution time.

This approach requires that each simulated user has his own browser instance. You can run several instances of iMacros Browser at once, thus simulating concurrent users. This approach works very well for 1…50 users per average PC. The limit is only the number of IE or Firefox instances that can run on your machine. To run iMacros for Firefox with Multiple Profiles, you can use the Profile Manager or a batch file for creating profiles. A user profile in Chrome can be cloned by simply copying its content into a new folder.

Getting started is easy: To use iMacros with JMeter you do not need to install any plug-in.

All you need is to create a script to control iMacros, and build a Test Plan in JMeter that launches the script.

How to Launch iMacros from JMeter Using VB Script

1. Create a VB Script to Control iMacros

The iMacros Enterprise Edition automatically installs the Web Browser API (iMacros Scripting Interface). With these powerful commands you can easy write scripts (in a scripting language of your choice) that allow you to control iMacros. The following VB script is executing simple iMacros code for navigating to a web page:

01_VBScript

Tip: Use the iMacros Editor Code Generator feature to convert your iMacros macros into scripting/programming language code.

2. Build a JMeter Test Plan

The next step is to build a Test Plan in JMeter. Add a Thread Group to your Test Plan to create multiple threads and change its values as desired. Each thread will have a single browser instance.

01_VBScript

Add to the Thread Group an OS Process Sampler with the “cmd” command and the following two values:

03_OS_Sampler_VBS

The second value contains the path to your VB script. Finally, you need to add listeners, e.g. Summary Report, to display the test results.

How to Launch iMacros from JMeter Using Powershell and iMacros Browser

Instead of VBScript, it is possible to use PowerShell to control iMacros as the following example shows:

04_PowerShell_1

The PowerShell script can be launched in JMeter by adding an OS Process Sampler:

05_OS_Sampler_PS_1

Notice that the PowerShell script takes as an argument the JMeter built-in variable __threadNum and displays the current thread number in iMacros.

Passing Arguments from JMeter to PowerShell and Running iMacros for Firefox

The following PowerShell script launches iMacros for Firefox using multiple profiles named f1, f2, f3…fn:

06_PowerShell_2

Using the built-in __threadNum variable allows you to associate each thread to a single browser instance. In JMeter you can also define user variables that can be passed to the PowerShell script, e.g. loopsNum that simply contains the total number of loops:

07_OS_Sampler_PS_2

There is more in-depth information about the User Defined Variables on the JMeter documentation page.

Adding Listeners to View and Store the Test Results

The listener components display the collected performance and load test results of the samplers. The metrics can be shown in a tree, table, graph or log file:

08_Listener_Tree

09_Listener_Summary

Download scripting code and test plans:

Source.zip

Note: Consider changing the directory path in the JMeter samplers to where the scripts are stored.

TOP