How to Record Mobile Applications With Apache JMeter
Learn how to record Android or iOS mobile apps with JMeter for performance testing.
Join the DZone community and get the full member experience.
Join For FreeRecording of mobile application traffic is not much different from what we do to record scripts for web applications. All we have to do is put the proper proxy in place for a mobile device. Follow the below steps for Android or iOS mobile apps.
Open JMeter and right-click the Test Plan>>Add >>Threads (Users)>>Thread Group.
Right-click the Thread group>>Add>>Logic Controller>>Recording Controller.
Right-click the Threads>>Add>>Listener>>View Results Tree (to see response data while running the script).
Add test script recorder by selecting Add>Non-Test Elements>HTTP(S) Test Script Recorder option.
Add '9090' as the Port value and click the Start button. This will start the JMeter proxy on localhost.
On 'Start' of HTTP(S) Script Recorder you will see a dialogue box of Root CA Certificate — just click the 'OK' button to get rid of it.
Android proxy configuration:
- Go to Settings > Wi-Fi option (the shared Wi-Fi network should be same for both Mobile and PC where JMeter is installed).
- Long tap the network which you are connected and click the 'Modify Network' option.
- Check the 'Advanced options' checkbox.
- This will open advanced settings from which we can modify proxy manually. For this, set 'Proxy'option to 'Manual'.
- Now, set 'Proxy hostname' as your PC IP address and 'Proxy port' to 8080 as we have set up in JMeter Proxy server.
- Click 'Save', now you can start running the application on your mobile device and its requests will be recorded in JMeter.
iOS configuration:
- Go to Settings > Wi-Fi option (the shared Wi-Fi network should be same for both Mobile and PC where JMeter is installed).
- Click on the connected network.
- Select the 'Manual' option from HTTP Proxy section.
- Set the 'Server' as your PC IP address and 'Port' to 8080 as JMeter proxy server.
Recording a Mobile App Script
- Before running any application, make sure that you click the 'Start' button on HTTP(S) Test Script Recorder in JMeter.
- Open the mobile application you want to test and play around with the functionality the way you want it to be recorded in JMeter for load testing.
- As we have set the mobile connection over JMeter's proxy, thus all test flow are recorded to JMeter's Test Plan.
- Once you are done recording all the test flows of your application, stop the recording by 'Stop' button on 'HTTP(S) Test Script Recorder' in JMeter and save the Test Plan.
Now run your Test Plan by clicking the 'Play' button displayed in green.
After playing the Test Plan you can view the response of the each request in 'View Result Tree'.
Your script is ready for load testing. You may further refine it by adding correlation, parameterization, etc.
Opinions expressed by DZone contributors are their own.
Comments