How to Set Up Appium for Test Automation

Rommel Malqued
Jan 29 · 7 min read

Are you are getting started with your mobile test automation journey? Then Appium is a must know tool. Appium is an open source test automation framework for use with native, hybrid and mobile web apps. Though setting up Appium can be difficult if you’re new as it requires a lot of dependencies with other tools. This is where this article comes in, to help you set up Appium. Let’s get started!

You can install it via npm or download Appium Desktop. I like Appium Desktop because it comes with the Appium Inspector which we will be using to inspect mobile elements. Also I like to start Appium Server programmatically. If you did not install Appium via npm and tried to start Appium programmatically, you will get this kind of exception. So we will be installing Appium using both methods.

NOTE: This is intended for Mac users only. If you’re not a mac user, you can still use this as a reference.

Before proceeding with Appium installation be sure to check these articles first. But if you think you already have these configured then proceed with Appium installation.

Installing Appium Desktop

  1. Go to Appium download page and download the installer for your MacOS.

2. Open the downloaded file then move Appium to your Applications folder. Then wait to finish installation.

Install Appium Via npm

To use npm make sure you have Node installed in your system. I you haven’t yet, check this article on How To Install Homebrew And Node For Test Automation.

To install appium, run the command below in your Terminal. This will install the latest appium version.

npm install -g appium

If you get an error due to the warning below, just chown the node_modules folder.

To chown the node_modules, run the command below on your terminal. It will ask for your mac login password.

sudo chown -R $USER /usr/local/lib/node_modules

After executing chown command, just rerun the install command.

If you want to install a specific appium version you can follow this format npm install -g appium@1.19.1, where the number following @ is the version you want to install. But it’s better to use the latest version.

To check if appium is installed, run this command on your Terminal.

appium -v

One way to check Appium set up is by using appium-doctor.

Installing appium-doctor

appium-doctor attempts to diagnose and fix common Node, iOS and Android configuration issues before starting Appium.

To install, run the command below on your terminal.

npm install -g appium-doctor 

To check Appium set up using appium-doctor, run this command.

appium-doctor

This will check if all necessary and optional dependencies for Appium to run are set properly. If you want to check platform specific dependencies:

For android, run

appium-doctor --android

For iOS, run

appium-doctor --ios

When you run appium-doctor you should see something like the image below.

All the necessary dependencies are installed and configured correctly. If yours is not, please revisit the steps above and also check the other three articles mentioned at the start.

If in case you get a warning that DevToolsSecurity is NOT enabled! This just means that Xcode developer mode is not yet enabled. This usually happens when you just installed Xcode and haven’t opened it yet and did not agreed to enable developer mode.

To enable it, just open Xcode, create sample project and then a pop modal like below should show. Just click Enable.

If in case it does not show, just run the command below on your Terminal

DevToolsSecurity -enable

Then run appium-doctor again to verify. If you’re done with the necessary dependencies, that should be enough for you to be able to run your automation scripts using Appium. If you want to install the optional dependencies continue on the next section.

Download and installation of the following tools takes time, be patient.

Install CMake (check their website)

CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.

To install, open terminal and run,

brew install cmake

Install opencv4nodejs

opencv4nodejs allows you to use the native OpenCV library in nodejs. Besides a synchronous API the package provides an asynchronous API, which allows you to build non-blocking and multithreaded computer vision tasks. opencv4nodejs supports OpenCV 3 and OpenCV 4.

To install, run this command.

npm install -g opencv4nodejs

Install ffmpeg (check their website)

ffmpeg is a complete, cross-platform solution to record, convert and stream audio and video.

To install, run this command.

brew install ffmpeg

Install mjpeg-consumer

A node.js transform stream implementation that consumes http multipart mjpeg streams and emits jpegs

To install, run this command.

npm install -g mjpeg-consumer

Install set-simulator-location

This is a simple CLI for easily setting the location of the currently running iOS Simulator.

brew install lyft/formulae/set-simulator-location

Install idb and idb_companion

iOS Debug Bridge (idb) is a versatile tool for automating iOS Simulators & Devices. It exposes a lot of functionality that is spread over Apple’s tools in a consistent and human-friendly interface

We will install idb using pip3, so let’s install python3 first.

brew install python3

Once python3 is installed, add python3 to your PATH and export it on your .bash_profile. If you’ve checked the other three articles above you should know how to do this by now.

export PATH="/Library/Frameworks/Python.framework/Versions/<insert python version here>/bin:${PATH}"For example you downloaded python 3.8.5export PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"

Once python3 is installed, proceed with the installation of idb and idb_companion. Run the following command on your terminal.

brew tap facebook/fb
brew install idb-companion
pip3 install fb-idb

Install applesimutils

A collection of utils for Apple simulators.

To install run these commands on your terminal.

brew tap wix/brew
brew install applesimutils

Install gst-launch-1.0

It is used to stream the screen of the device under test.

To install run these commands on your terminal.

brew install gstreamer

Install bundletool

It is used to handle Android App Bundle.

Setting up bundletool is a little more complicated compared to the others. If you don’t want to do it, it’s okay since it is only optional but if you want to do it, follow carefully the next steps.

  1. Visit bundletool GitHub page.
  2. Download bundle tool jar file. By the time you see this, it might not be the same version. Just download whatever the latest is.

3. Rename the file to bundletool.jar.

4. Go to this directory ~/Library/Android/sdk/ . How to get here. Open Finder, hit cmd+shift+g then paste ~/Library/Android/sdk/

5. Under that directory, create a new folder and name it bundle-tool.

6. Move the downloaded bundle-tool.jar in this location.

7. Then run the command below on your terminal to make it executable.

chmod +x ~/Library/Android/sdk/bundle-tool/bundletool.jar

8. Then add this to your .bash_profile.

export PATH=${PATH}:Library/Android/sdk/bundle-tool

9. Restart your Terminal.

To verify if Appium set up is complete. Rerun appium-doctor.

Yeeey! We’ve managed to setup Appium and all its dependencies.

Since all through out the installation we keep on mentioning .bash_profile. This is how your .bash_profile should look like now.

Setting up Appium can take the whole day especially if you are new to it without even considering how fast your internet connection is. Even professionals encounter issues during set up so don’t get frustrated. These tools provides very informative warning and error messages that can help you resolve the issues being encountered. If you follow this article you should be fine but if you get lost just ask for help or search the internet.

Enjoy your mobile test automation journey! 🍻 🍻 🍻

The Startup

Get smarter at building your thing. Join The Startup’s +724K followers.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +724K followers.

Rommel Malqued

Written by

“Good Automation Brings Agility”. Software QA With An Agile Mindset. https://www.linkedin.com/in/rmalked/

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +724K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store