Appium: Android automation testing environment configuration

Appium for Android on Mac

So basically the environment setting up is pretty similar with iOS. We need Node.js and Homebrew, and most importantly, Appium. Please follow the instruction of Appium configuration for iOS part above. Apart from that, path variables need to be set.

Path Environment Settings

1. Download Java JDK and Android SDK tools/Android Studio

2. Set environment variables, i.e. JAVA_HOME and ANDROID_HOME:

touch ~/.bash_profile

open ~/.bash_profile

Then, .bash_profile will be popped up.

Add the path values into the .bash_profile like below:

After this, we can run Appium and start the server and sessions.

For any errors in running Appium, please read carefully the error message and find out what the problem is.

Real Device Testing

For Android, as long as we know the app related information, we can use it to run the test. We do not need the original .apk file unless we are running the test on an emulator and we need to install that into our emulator.

To run the test, we need to know the related information of a particular application, i.e. app package, and app activity. So we will need to download and install apk info application into our devices.

Follow the steps below to run the real device testing:

1. Check whether the device is connected and the name of the device:

Type the following code into terminal

cd /usr/local/Android/platform-tools

./adb devices (“./” means run this code in the current folder, e.g. platform-tools)

2. Download “apk info” application into phone from Google Play or the internet, and use it to track the app related information.

3. Connect the device with Mac, and enable “USB debugging” so that we can run testing on it.

4. Open Appium Server, enter capabilities, and start the session.

(I am currently using IndustryConnect app to run the test. So please ignore the appPackage and appActivity capabilities.)

Open and Install Application into Emulator

Create and open an emulator

(Note that different from Windows, we do not need to open SDK and AVD manager to open an emulator. Instead, VisualStudio for Mac provides users emulator tools which is just like SDK and AVD manager does. If you still want to use the SDK and AVD manager provided by Android SDK tools, please refer to the section of “Use SDK tools” )

To open a emulator, firstly download API packages from SDK Manager. E.g. I am testing an application on Android 5.1 (API level is 22), so I have to download corresponding SDK platform and system image I need for my emulator. (I recommend that do not download every API level files unless your computer has enough storage. )

Then open Google Emulator Manager (or AVD manager on Windows), click “Create” to create a emulator.

Create your emulator:

For Mac, it is better to use Intel Atom x86 as it runs faster. But for Windows, Intel Atom may not work, so ARM or Google APIs is recommended.

Then Click OK, and then run the emulator we just created.

Use SDK tools:

This section is prepared for the reader who do not want to use the tools provided by VisualStudio for Mac, but want to open SDK Manager/AVD Manager/uiautomatorviewer.

Open the folder tools under the folder where your Android SDK tools saved in.

This is SDK manager and AVD manager. The default view is SDK manager. You can switch to AVD manager by Tools->Manage AVDs like this:

For uiautomatorviewer, open the last file in the tools folder:

Uiautomatorviewer can also assist you to find out the locators and locator values of elements in your real device or emulator. Just open it, then click the second button. It will produce you a screenshot when your real device is connected or your emulator is opened.

Below is a screenshot for Calculator.

Install an application on emulator

If you want to use emulator to do the testing, you need to install the app into the emulator. Firstly, download the .apk file into platform-tools folder. Then in the terminal prompt (the emulator needs to be opened):

cd /usr/local/Android/platform-tools (This code opens the platform-tools folder)

./adb install theApkFileYouWantToInstall.apk (Then use adb to install the app)

Emulator Testing

Similar with real device testing, we need to install apk info application first into emulator following the steps above.

We can download the .apk file by clicking the link APKinfo App (com.intelloware.apkinfo.apk)

from .

Then open the emulator we created before, and install this .apk file using the steps identified above using terminal prompt. After installing it, we can see a new app in our emulator:


Open it, and we can then view all the app related information. For example, below is the information of calculator:


With these capabilities, we can run the test. (the emulator has to be opened)

Write Automation Scripts

Please refer back to the iOS settings. Make sure that the capabilities we defined in VisualStudio is correct.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s