Hey there, performance testers! Tired of handcrafting your JMeter scripts? Well, buckle up, because JMeter has a sweet trick up its sleeve called script recording. Skip the manual coding and let JMeter capture your app clicks like a digital detective. It translates these clicks into a script filled with all the JMeter elements you need. Record your scenario in JMeter and upload it on Azure load Testing for analysing your application’s performance.
Ready to see how it works? Let's dive in!
STEPS TO PERFORM JMETER RECORDING
For the purpose of our demonstration, we will be load testing our web application, an online shopping application called Contoso Traders. Let’s go.
CREATE A JMETER TEMPLATE
Open the JMeter GUI in your local PC. Navigate to Templates and select the ‘Recording’ template. Enter the URL of your web application as shown below.
Go to HTTP(S) Test Script Record. Under Target Controller, select the target destination of the recorded samplers in your test script. In this demonstration, we would be choosing our destination as ‘Use Recording Controller’.
Under HTTP Sampler Settings, check ‘Follow Redirects’ if it’s not already checked. The "Follow Redirects" option checks if a server's response is a redirection and redirects to the URL if it is. Give a Transaction Name of your choice.
In the tab ‘Requests Filtering’, you can exclude URL Patterns which you don’t want JMeter to record. In the demonstration, we wanted to exclude images of .svg extension. So under the ‘URL Patterns to Exclude’, we replaced
(?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2) with (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2|svg)
INSTALL JMETER CA CERTIFICATE Once you click on Start, a JMeter proxy server is started, which is used to intercept the browser requests. A file called ApacheJMeterTemporaryRootCA.crt will be generated in JMETER_HOME/bin folder. You need to install this certificate by following the steps mentioned here - Installing the JMeter CA certificate for HTTPS recording. Since we are using Chrome browser for recording, we have installed the certificate by opening ApacheJMeterTemporaryRootCA.crt stored in JMETER_HOME/bin. Click on the "Details" tab and check that the certificate details agree with the ones displayed by the JMeter Test Script Recorder. If OK, go back to the "General" tab, and click on "Install Certificate …" and follow the Wizard prompts.
CONFIGURE YOUR BROWSER TO USE THE JMETER PROXY
If you are recording on Firefox, you can follow these steps.
For Chrome or Edge, you can follow these steps-
Go to Proxy Setting in your system settings.
Under Manual Proxy settings, click on ‘Set up’ button against ‘Use a proxy server’.
Toggle the ‘Use a proxy server’ button, with IP and port number as shown below. Click on Save.
RECORD YOUR NAVIGATION
Go to your HTTP(S) Test Script Recorder in your JMX Script. Click on Start.
Navigate to your browser (Chrome for this demo) and perform the user scenario that you intend to load test.
After you are done, go to ‘Recording Controller’ to view your JMX script.
Voila! Your test script is effortlessly generated from the sequence of user actions performed.
UPLOAD ON AZURE LOAD TESTING
You can run your script on our fully-managed service – Azure Load Testing. The service ensures that you can scale effortlessly, integrate testing in your CI/CD pipelines and consume your test results to improve your system performance. Just follow these steps to upload and run your script.