Introduction
Appium is a server written in Node.js. It can be built and installed from source or installed directly from NPM.
Appium is a freely distributed open-source mobile application UI testing framework. It allows native, hybrid and web application testing and supports automation test on physical devices, emulator or simulator. It also offers cross-platform application testing
Appium Clients Appium offers different 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.
To integrate Appium with our custom monitors we will need to install the below applications as well:
- JDK
- Android studio with Android SDK
- Xampp (installs all required php packages.)
- Composer (A dependency manager for PHP)
Prerequisites
- CentOS 7.4+
- 64-bit Operating System, x64-based processor 3. Node JS (NPM)
- An admin user account with the ability to run commands as sudo
- Android Device.
Video Tutorial for Installation:
Installation & Configuration
-
Installing Appium
Make sure that the latest node version is installed on the machine.- If needed, update the node by running:
$ sudo yum update - Install Appium server by running:
$ sudo npm install -g appium --unsafe-perm=true --allow-root
- If needed, update the node by running:
-
Install Xampp
- Download the latest version of Xampp for Linux from the link below (PHP 7.4.1):
$ wget <https://www.apachefriends.org/xampp-files/7.4.1/xampp-linux-x64-7.4.1-0-installer.run> - Change the permissions to the installer:
$ chmod 755 xampp-linux-*-installer.run - Run the installer
$ sudo ./xampp-linux-*-installer.run
Xampp is now installed below the /opt/lampp directory.
- Download the latest version of Xampp for Linux from the link below (PHP 7.4.1):
-
Install JDK
$ yum install java-1.8.0-openjdk- Check if the correct version has been installed by running:
$ java -version
(If Java path is not set properly, you will get error messages.)
-
Install Android SDK
-
Download SDK Command line tools from https://developer.android.com/sdk/index.html.
$ wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -
Unzip the files to a folder of your choosing within your home directory (e.g.
~/android-sdk)
$ unzip sdk-tools-linux-4333796.zip -
Navigate to
tools/bindirectory and run the sdkmanager tool :
-
$ ./sdkmanager –update
$ ./sdkmanager "platforms;android-29" "platform-tools" "build-tools;29.0.2" "extras;google;m2repository" "extras;android;m2repository"
$ ./sdkmanager --licenses
- Set Environment variables for Android SDK and PHP
- Create a shell script with any name under the
/etc/profile.d/directory:
$ sudo vim appium_config.sh - Copy and paste the below contents into this file and save it.
- Create a shell script with any name under the
export PATH=$PATH:/opt/lamp/bin
export ANDROID_HOME=/home/<username>/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Note: Make sure that Android SDK is set properly in the ANDROID_HOME path. The directory will usually be /root/Android/Sdk/ or /home/\<username\>/Android/Sdk/
- Install Composer
- Once Environment variables are set for PHP, download the Composer installer script:
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
This command will download thecomposer-setup.phpfile to the current working directory. Learn more. - To verify the data integrity of the script, compare the script SHA-384hash with the latest installer hash found here: Composer Public Keys / Signatures. The following wget command will download the expected signature of the latest Composer installer from the Composer's Github page and store it in a variable named HASH:
$ HASH="$(wget -q -O - https://composer.github.io/installer.sig)" - To verify that the installation script is not corrupted, run the following command:
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"- If the hashes match, the message "Installer verified" will be displayed.
- If the hashes don't match you will see "Installer corrupt". In this case, you need to redownload the Composer installation script and double-check the value of the
$HASHvariable withecho $HASH. Learn more.
Once the installer is verified, you can continue to the next step.
- Run the following command to install Composer in the
/usr/local/bindirectory:
$ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
All settings correct for using Composer
Downloading...
Composer (version 1.8.5) successfully installed to: /usr/local/bin/composer - Use it:
php /usr/local/bin/composer
The composer is now installed as a system-wide command and it will be available for all users. - Finally, verify the installation:
$ composer
This command will print the Composer's version, commands, and arguments.
- Once Environment variables are set for PHP, download the Composer installer script:
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ / __ `__ / __ / __ / ___ / _ / ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.8.5 2019-04-09 17:46:47
Usage:
command [options] [arguments]
At this point, you have successfully installed Composer on your CentOS system.
- Install Appium client
-
Create a file called
composer.jsonunder the following directory:
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox -
Add the following JSON to the file:
{
"name": "username/my-php-project",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/appium/php-client"
}
],
"require":
{
"appium/php-client": "dev-master"
}
} -
Execute the following commandto install the required packages for the Appium PHP client:
$ sudo composer update
-
Implementation
The attached sample php script installs an APK file and then asserts for an element before it clicks on a button. Code snippet will Copy this php file under the following directory:
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/venddor/appium/php-client/test/apps/
The platform version for the PHP file is the OS version of your emulator or the android device.

All the PHP scripts which are used to write the test cases will be under this directory.
- You can also use the sample APK file which is attached for testing purposes. This apk file should be Copied under the following directory
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/vendor/appium/php-client/test/apps/
All the APK files which should be tested on the device will be under this directory.
- For reference or for more examples, please look at the files under following directory:
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox/vendor/appium/php-client/test/functional/android/
https://github.com/appium/php-client
8. Create a custom script:
Copy the shell script appium.sh under the following directory.
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox
This script will Invoke the php file. Shell script is also attached to this article. Catchpoint requires that the script is executable. To change the file permissions, run:
$ chmod 500 appium.sh
$ chown serveruser appium.sh
-
Create the Custom Test
Create a Custom Test within the Catchpoint Portal using the JSON template below. Make sure that you replace the filename with the one you chose.{"shell_command_file_name":" appium.sh"} -
Set up the 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.
- 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 up a terminal/command prompt 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 Emulator on Android Studio, follow the links below: https://developer.android.com/studio/run/managing-avds#createavd https://developer.android.com/studio/run/managing-avds
11. Start Appium server
Make sure you start Appium as a root user before running the tests from the catchpoint portal.
$ appium &
Results
We can set up indicators to capture the results from catchpoint’s STDOUT.
appium_test_time_msappium_errors\_#
appium_test_time_ms: This is the total time taken by the PHP file to execute. This is similar to thr Exec Command Time (ms) metric in the waterfall. Regular expression for Insights: (?:Time\\:\\ (\d+.\d+ )seconds)
appium_errors_#: Shows the number of errors for that particular execution of the test case or the test run. Regular expression for Insights: (?:Errors\\:\\ (\d+)\\.)

Scatterplot Results:

You can also refer to:
Appium - Native Application Monitoring