Record mobile application test scenario using Apache Jmeter

Last Updated 10 months ago

A. Initial Mobile Device Configuration

--
Important Note: Mobile device and the computer that will have Apache JMeter running need to be connected to the same network.

Let’s start by setting up our mobile device in order to make it able to send HTTP traffic information to the computer that will have Apache Jmeter running and recording all of that.


On an iOS device, follow these steps:-

  1. Settings Wi-FiConnected Network
  2. Choose Manual from HTTP Proxy section
  3. Add Server value, Server = Computer IP Address (the one that will have Apache JMeter recording the traffic)
  4. Add Port value, Port = 8888, for instance, or another port from your computer that is not (or will not) be used for other purposes


On an Android device, follow these steps:-

  1. SettingsWi-FiConnected Network
  2. Show advanced options
  3. Choose Manual from HTTP Proxy section
  4. Add Proxy host name value, Proxy host name = Computer IP Address (the one that will have Apache JMeter recording the traffic)
  5. Add Proxy port value, Proxy port = 8888, for instance, or another port from the computer that is not (or will not) be used for other purposes

B. Apache JMeter Test Plan Setup

--
The main goal is to make Apache JMeter ready to record data from the mobile device. So, without further delay, with Jmeter opened, follow the steps below:-

  1. Select the Test Plan element, right-click on it then go to Add → Non-Test Elements → HTTP(S) Test Script Recorder and click on it.
  2. Select the HTTP(S) Test Script Recorder, find the Global Settings section and fulfill the Port field with a port number which you know that is not being used by the operating system.
  3. Right-click on Test Plan then go to Add → Threads (Users) → Thread Group and click on it.
  4. Select the Thread Group (created on the previous step), Right-click on it then go to Add → Logic Controller → Recording Controller and click on it.
  5. Select the HTTP(S) Test Script Recorder element and click on Start button
  6. An alert window stating that a new temporary Root CA certificate was created under JMeter’s \bin folder will be displayed
  7. Send the ApacheJMeterTemporaryRootCA.crt (located in Apache JMeter’s \bin folder) to your email account.

C. Downloading & Installing the Certificate on the Mobile Device

--
On an iOS device, follow these steps:-

  1. Open (using Safari browser or iOS’s native mail app) the email that you sent previously, download the .crt file and open it.
  2. Once you open it you will be able to install it by tapping on Install.
  3. Your password will be asked, so type it.
  4. A message warning you that you are about to install an untrusted certificate will be displayed. Tap on Install, then tap on the Install button that will be shown.
  5. At this point, the certificate might be already installed and you just need to tap on Done.
  6. Now visit Settings General About Certificate Trust Settings, then “Enable full trust for root certificates” for the newly-installed certificate.

On an Android device, follow these steps:-

  1. Navigate to Settings Biometrics and security Other Security Settings Install from device storage. This path may vary according to the device and operating system.
  2. Select the downloaded certificate file and tap Done.
  3. Give a name to the certificate and tap OK.
  4. At this point, the certificate might have been installed. To confirm, just tap the User certificates option.

D. Start Recording

--

  1. On the mobile device open the application and start navigating on it.
  2. Go back to the Apache JMeter and expand the Recording Controller that have been added earlier (in Step 4 from Section 2 of this document). All the HTTP calls made by the mobile device should now being recorded. See the next section to learn how to record only specific requests.

Useful Tips

--

  • In order to avoid having ALL the HTTP requests sent by the mobile device recording or to have complete control of what is going to be recorded, select the HTTP(S) Test Script Recorder and go to Request Filtering section. There configure the filters that will make Apache JMeter to record only the things that are meaningful for the testing purposes.
  • A View Result Tree listener might come handy while recording the application HTTP calls. It allows to see in real-time the request and response details. To add it, just right-click on the Test Plan, go to Add Listener View Result Tree.

Loading