Android Software - Appium servers only

This documentation will guide you in installing a mobile testing platform (software part) using only Appium nodes for Android phones.

List of prerequisites :

  • a computer with macOS Mojave (minimum version : 10.14.0)
  • administrator rights

What you will need to install :

  • JDK 1.8
  • Android SDK 28
  • Node.js 8.12.0
  • npm 6.4.1
  • Chrome driver 77.0.3865.40
  • Appium 1.14.2
  • Appium-Doctor 1.6.0

Tools installation

JDK

Download and install JDK 1.8 from Oracle website and add the environment variable :

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
source .bash_profile

Android SDK

Download the Android SDK from here and move the downloaded folder to /Application folder. Then, add the environment variable :

export ANDROID_HOME=/Applications/android-sdk-macosx/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source .bash_profile

Update the Android SDK following the README instructions in the downloaded folder.

Node.js

Download and install Node.js 8.12.0 from here. You can check the version using :

node -v
npm -v

Homebrew and adb

Install homebrew followig instructions of Homebrew hompage. Then, install adb (included in platform-tools) using this command :

brew cask install android-platform-tools

Chrome driver

You will need to download a Chromedriver version compatible with the Chrome browser version on your phone. In our example, phones use Chrome v77.0.3865.40, so we have to download the corresponding executable of Chromedriver. Find the good version in this list. Place the Chromedriver executable in the folder of your choice, we will need it to start appium server.

Appium server

You may install different versions of Appium (for example, Appium 1.13.0 for iOS part and Appium 1.14.2 for Android part), so we recommend that you do not install Appium in global mode. Create a folder /AppiumAndroid somewhere and then run the following command to install Appium :

npm install appium@1.14.2 --save

If you will use an unique version of Appium, you can install Appium server in global mode using the option -g.

Appium Doctor

Install Appium Doctor :

npm install -g appium-doctor

and then run the following command to check if all prerequisites are installed for Appium :

appium-doctor

Appium configuration

You will need to create a configuration file for each phone you want to connect. You can find an example of configuration file in /nodes folder. This file is composed as follows. You have to change some information in this sample file :

  • the device name
  • the device UUID
  • the Android version on the device

How to get UUID ?

Plug your phone into an USB port and run the following command in terminal :

adb devices

It will show you the list of the connected devices and you can get the device UUID :

List of devices attached
A1B2C3D4E5F6G7H8     device

Start the platform

Make sure your phone is connected to the computer and run an appium server in a terminal :

/path/to/appium --default-capabilities /path/to/android-config-file.json --port 4701 --chromedriver-executable /path/to/chromedriver

You should see the following message :

[Appium] Welcome to Appium v1.8.1
[Appium] Non-default server args:
[Appium]   port: 4701
[Appium]   chromedriver-executable: chromedriver
[Appium]   defaultCapabilities: {
[Appium]     capabilities: {
[Appium]       0: {
[Appium]         browserName: chrome
[Appium]         deviceName: Samsung Galaxy S9
[Appium]         maxInstances: 1
[Appium]         platform: ANDROID
[Appium]         uuid: 123456789ABCDEFG
[Appium]         version: 9
[Appium]       }
[Appium]     }
[Appium]   }
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium]   capabilities: {
[Appium]     0: {
[Appium]       browserName: chrome
[Appium]       deviceName: Samsung Galaxy S9
[Appium]       maxInstances: 1
[Appium]       platform: ANDROID
[Appium]       uuid: 123456789ABCDEFG
[Appium]       version: 9
[Appium]     }
[Appium]   }
[Appium] Appium REST http interface listener started on 0.0.0.0:4701

Automate servers launch (optional)

In the /scripts folder you will find a script that will launch the Appium servers. After modifying the path, you can start the script running this command in a terminal :

. run-appium-servers-for-android.sh

To go further, you can schedule the server launch by defining a cron job. To see the list of your cron jobs, run the command :

crontab -l

To add a new entry in the crontab, run this command :

crontab -e

Edit the file, adding this line in order to launch the script at 9AM every week day :

0 9 * * 1-5 . /Users/path/to/run-appium-servers-for-android.sh

Learn more about cron expression here : https://crontab.guru/

Automate the checking connected devices (optional)

In the /scripts folder, you will find a script that check the connected devices. This script counts the number of devices and send a slack message if there is a missing one. You have to change some information :

  • the expected number of connected devices
  • the slack channel you want to receive a message
  • the alert message
  • the displayed name
  • the slack hook url

To go further, you can schedule this devices checking by defining a cron job. To see the list of your cron jobs, run the command :

crontab -l

To add a new entry in the crontab, run this command :

crontab -e

Edit the file, adding this line in order to check every 10 minutes between 9AM and 6PM every week day :

*/10 9-18 * * 1-5 . /Users/path/to/check-connected-phones.sh

Learn more about cron expression here : https://crontab.guru/

Phones setup (optional)

To improve the use of the platform and make it as autonomous as possible, you can :

  • disable the phone pausing
  • disable the Google voice assistant or remove the access permission to the microphone