---
title: "Appium - Native Application Monitoring"
slug: "appium-native-application-monitoring"
updated: 2025-07-18T19:46:04Z
published: 2025-07-18T19:46:04Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Appium - Native Application Monitoring

## **Introduction**

Appium is a server written in Node.js. It can be built and installed [from source](http://appium.io/docs/en/contributing-to-appium/appium-from-source/index.html) or installed directly from [NPM](https://www.npmjs.com/package/appium). Appium is a freely distributed open-source mobile application UI testing framework. It supports native, hybrid, and web application testing as well as automation tests on physical devices and device emulators. It also offers cross-platform application testing.

**Appium Clients**

Appium offers several client libraries (Java, Ruby, Python, PHP, JavaScript, and C#) that support Appium's extensions to the WebDriver protocol. When using Appium, you want to use these client libraries instead of your regular WebDriver client. You can view the full list of libraries here: [http://appium.io/docs/en/about-appium/appium-clients/index.html](http://appium.io/docs/en/about-appium/appium-clients/index.html). In this guide, we will be using the Python client library.

**Appium Metrics:**

```
Getting memoryinfo metrics
totalPrivateDirty : 51430
nativePrivateDirty : 22512
dalvikPrivateDirty : 2604 e
glPrivateDirty : 4007
glPrivateDirty : 13207
totalPss : 64929
nativePss : 22629
dalvikPss : 2689
eglPss : 4007
glPss : 13207
nativeHeapAllocatedSize : 24491 nativeHeapSize : 34816

Getting Batteryinfo metrics
power : 100
```

Appium is used for availability monitoring. To capture time spent on each step of the user journey, you will need to modify the script. This is done by adding a time capture before the first click and before the second click, and then getting the difference between these two values.

## **Prerequisites**

- CentOS 7.4+
- 64-bit Operating System, x64-based processor
- Node JS (NPM)
- An admin user account with the ability to run commands as `sudo`
- Android Device

**Firebase** (optional)

1. For our examples, we will be using Google Firebase performance SDK and mitmproxy along with Appium to capture network requests and device-level metrics.
2. To add Performance Monitoring SDK to your Android app, please follow the steps in this article: [https://firebase.google.com/docs/perf-mon/get-started-android](https://firebase.google.com/docs/perf-mon/get-started-android)

**mitmproxy** (optional) If you are using android device/emulator which is older than nougat, setting up mitmprxy is straightforward. If the device runs on a later OS, you need to ”root” the device and install the mitmproxy certificate as the root certificate. This is because Android version 7, "Nougat", introduced stricter security rules when it comes to installing SSL certificates. These devices keep two lists of trusted certificates: user certificates and system certificates. Installing a certificate through the UI puts it into the user certificate list, but only certificates in the system list are trusted for app-based network requests. We provide detail on how to set up mitmproxy in the following sections.

## **Installation & Configuration**

1. **Install Appium** Make sure that the latest node version is installed on the machine.
  - Update the node by running:  

`$ sudo yum update`
  - Install Appium server  

`$ sudo npm install -g appium --unsafe-perm=true --allow-root`
2. **Install JDK** `$ yum install java-1.8.0-openjdk`
3. **Confirm JDK is installed** `$ java -version` If Java path is not set properly, you will get error messages.
4. **Install Android SDK**
  1. Navigate to the following directory:  

`$ cd/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox`
  2. Install SDK Command-line tools by downloading the file from the below link.  

`$ wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip`
  3. Unzip the contents of the file  

`$ unzip sdk-tools-linux-4333796.zip`
5. After unzipping, navigate to `tools/bin` and run the sdkmanager tool:

```
$ cd tools/bin/
$ ./sdkmanager –update
$ ./sdkmanager "platforms;android-29" "platform-tools"  "build-tools;29.0.2" "extras;google;m2repository"      "extras;android;m2repository"
$ ./sdkmanager --licenses
```

1. **Set Environment variables for Android SDK**  

Create a shell script under the following directory. `/etc/profile.d/`

```
$ cd /etc/profile.d/
$ sudo vim appium_config.sh
```

Add the below lines and save the file.

```
export ANDROID_HOME=/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools
```

Make sure that Android SDK is set properly in the above ANDROID_HOME path. The directory should be `/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/`

1. **Install Appium Python client** *Note: Both Appium and mitmproxy require python version 3 to be installed.*
  1. **Enable Software Collections (SCL):**  

`$ sudo yum install centos-release-scl`
  2. **Install Python 3 on CentOS 7:**  

`$ sudo yum install rh-python36`
  3. To access Python 3.6 you need to launch a new shell instance using the Software Collection scl tool.  

`$ scl enable rh-python36 bash`
  4. You’ll notice that Python 3.6 is the default version in your current shell now.  

`python –version`
  5. **Install Appium client**  

The command below will download the and Install from PyPi, as 'Appium-Python-Client'.  

`$ pip install Appium-Python-Client`
2. **Install Mitmproxy (Optional)** We will be using a man-in-middle proxy, which will be set up on a node, and network requests from the android device will be redirected through this proxy. All the requests are captured to calculate and register different network-related metrics. You can skip installing mitmproxy If you don’t wish to capture network requests through the proxy.
  1. **Make sure python 3 is enabled:** `scl enable rh-python36 bash`
  2. **Install Mitmproxy:** `$ pip install mitmproxy`
  3. **Configuring the firewall...** `$ firewall-cmd --zone=public --add-port=8080/tcp --permanent` `$ firewall-cmd --reload` `$ firewall-cmd --list-ports`

## **Implementation**

For testing, a Python file `test_appium.py` is attached to this article. This script installs an APK file and clicks on a button. `mitmproxy_log_parser.py` parses all network requests captured through mitmproxy. Place this Python file under the following directory: `/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/`

You might need to change few values in the python file according to your device setup, such as device name, version, or app directory. ![mceclip0.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360054989012-mceclip0.png)

***You can also use the attached sample APK file for testing purposes. This APK file should also be placed in the sandbox directory.***

Below is the link for Python language bindings for Appium. [https://github.com/appium/python-client](https://github.com/appium/python-client)

**Create custom script:** Place the shell script attached in this article `appium.sh` under the following directory. `/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox`

This script will invoke the python script. Shell script is also attached on this article. Catchpoint requires that the script is executable. To change the file permissions, run: `$ chmod 500 appium.sh $ chown serveruser appium.sh`

1. **Setting up Android Device** You can either use a real android device or set up an emulator to test the APK files. To use ADB with your device, you’ll need to enable developer options and USB debugging:

- Open **Settings** and select **About** on your android device.
- Tap on **Build number** seven times.
- Go back and select **Developer options**.
- Scroll down and check the **Android debugging** or **USB debugging** entry under **Debugging**.
- Plug your device into your computer.
- On the computer, open a terminal and type `ADB devices`.
- A dialog should show on your device, asking you to allow USB debugging. Check **always allow** and choose **OK**.

To set up an Emulator on android studio, follow the link below. [https://developer.android.com/studio/run/managing-avds#createavd](https://developer.android.com/studio/run/managing-avds#createavd) [https://developer.android.com/studio/run/managing-avds](https://developer.android.com/studio/run/managing-avds)

1. **Start Appium server** Make sure you start Appium as a superuser before running the tests from the catchpoint portal. `$ appium &amp;`
2. **Create the Custom Test** To configure the script in Catchpoint Portal, go to **Control Center > Tests** and create a **Custom Test**. This will open the Test Properties blade where we need to fill in script details.

The script file name should be the same as the file placed in the sandbox folder. This file would be the first point of execution when the run is triggered. In our example, it would be `appium.sh` ![image.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/image%285%29.png)

1. **Start Mitmproxy (Optional)**

Note: Follow this step only if you have installed mitmproxy.

```
mitmdump -w /opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/outfile
```

**Set up proxy for android device.**

- Open your Android's Settings.
- Tap **Wi-Fi**.
- Tap and hold the Wi-Fi network name, then Select **Modify Network**.
- Tap **Advanced Options**.
- Tap **Manual**.
- Change your proxy settings. Enter the **hostname** and **proxy port**. The hostname will be your node's IP address. Android device and the node will be on the same network. Port will be **8080**.
- Tap **Save**.

1. **Install Mitmproxy certificate (Optional)  

![mceclip2.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360055121131-mceclip2.png) **

Now that your proxy is all set up, the next step is to install the certificate. To install the certificate go to [mitm.it](http://mitm.it/) on the android simulator and you should see the following screen. On this screen choose **android** and give the certificate a name. After installing the certificate, you are ready to use the proxy.

Note: If the device or the emulator version is Nougat or Android version > 7.0, we need to install this as a root certificate. For this the device needs to be rooted. Below are the steps for the same.

**Install certificate on the device (If android/emulator is > Nougat)** Once the device is rooted start adb by using

```
$ adb devices
```

This should show up your device on the terminal. Next, we unlock the device further:

```
$ adb root
$ adb remount
```

Let's now find our certificate file and push it to the device. The first time we ran mitmproxy, it saved its certificates to the home directory. Let's save that to a variable to use later.

```
$ ca=~/mitmproxy-ca-cert.pem
```

We also need to get a special hash to identify the certificate. The filename of the certificate on the emulator needs to be set as the hash of the certificate.

```
$ hash=$(openssl x509 -noout -subject_hash_old -in $ca)
```

If you don't have openssl installed on your computer, you can cheat and just use the value `c8750f0d`. The mitmproxy certificate is the same for everybody, so unless they change it in a later version, this should be fine.

```
$ hash=c8750f0d
```

Ok, now we install it on the device:

```
$ adb push $ca /system/etc/security/cacerts/$hash.0
```

And let's take adb back out of root mode, because the emulators tend to crash when restarting or lose the mitmproxy certificate unless you take this step: `$ adb unroot`

## **Results**

We can set up indicators to capture the results from catchpoint’s STDOUT. Test app which is used in this setup makes network request to few of the URL’s to load the images. Based on the we have built the regular expression. This would change according the app which goes into testing.

Response times:

| **Indicator name** | **Regular expression** |
| --- | --- |
| www.formula1.com | (?:\ https\://www\.formula1\.com[^\ ]* \d+b (\d+)) |
| mercedes-benz.com | (?:\ https\://www\.mercedes-benz\.com/.*\ \d+b\ (\d+)ms) |
| Batteryinfo_usage | power\ \:\ (\d+) |
| nativeHeapSize | nativeHeapSize : (\d+) |

Note: `www.formula1.com` and mercedes-benz.com are individual requests

We can still set up our own set of indicators based on the requirements. ![mceclip3.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360054989292-mceclip3.png) Scatterplot Results: ![mceclip5.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360055121331-mceclip5.png)

[test.apk](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/test.apk)

[test_appium.py](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/test_appium.py)

[mitmproxy_log_parser.py](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/mitmproxy_log_parser.py)

[appium.sh](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/appium.sh)
