Appium Setup from Scratch

Anoop Nair
4 min readMay 6, 2018

--

Appium is an open source test automation tool developed and supported by Sauce Labs to automate native and hybrid mobile apps. It is basically known as a Cross-Platform Mobile Automation Tool. It uses JSON wire protocol internally to interact with iOS and Android native apps using the Selenium WebDriver.

Appium Setup

Please Note that the below setup has been done and tested on MAC OS Make sure you have the latest mac (since xcode version is dependent on your mac os version) version and your editor is updated

  1. Install Brew, Node & npm on your machine via iterm
brew tap caskroom/versions
brew update
brew install carthage
brew install node
npm install -g npm

Check the Node & npm version

node --version
npm --version

2. Install Latest Version of Java. I am installing Java 8 because it is the LTS Version (Long Term Support)

brew cask install java8

3. Install Appium and Web driver globally

npm install -g appium
npm install wd

4. Download JDK Latest Version

5. Download the Selenium, Selenium Stand Alone and Appium JAR’s for Java Client Selenium JAR for JAVA Selenium Standalone JAR Appium Client Libraries

6. Install IntelliJ IDEA, and Go to File -> Project Structure -> Upload the JDK from local machine

Android Automation

  1. For Android Automation, We need to install the Android Studio Android Studio
  2. Update System Preferences, Open bash_profile in terminal:
nano ~/.bash_profile
Paste the below :
export ANDROID_HOME=/Users/User_name/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
SAVE AND EXIT TERMINAL

3. Check that JAVA_HOME and ANDROID_HOME is set:

$echo $JAVA_HOME
$echo $ANDROID_HOME

4. Open the Android Studio and go to Preferences -> System Settings -> Android SDK & Download the Necessary Package.

5. I use Genymotion Virtual Emulator for Android and i love it. You will ❤️ it too.

Follow the Steps to install Genymotion : https://docs.genymotion.com/Content/01_Get_Started/Installation.htm

  • Launch Genymotion and Click “Settings”→ ADB and set the path for Android-SDK.
  • Launch Appium and Navigate to Android Settings. Change the Capabilities as per the selected Virtual device.
  • Launch the Appium Inspector.
  • To check the devices attached to the local machine
adb devices
  • Install the apk file to emulator
adb install/Users/USER_NAME/Workspace/qa/YourAPK.apk

IOS Automation

  1. Install the XCODE Dependencies
$ xcode-select --install
$ sudo xcode-select --reset
$ sudo xcode-select --switch /Applications/Xcode.app
$ brew install libimobiledevice --HEAD
There is also a dependency, made necessary by Facebook’s WebDriverAgent, for the Carthage dependency manager.
$ brew install carthage
Deviceconsole allows analyzing crash logs and console output from the device
$ npm install deviceconsole
Install and debug iPhone apps from the command line, without using Xcode
$ brew install ios-deploy
Xcpretty is a fast and flexible formatter for xcodebuild
$ gem install xcpretty
You need to authorize use of the iOS Simulator. If you’re only testing Android, this can be skipped.
$ npm install -g authorize-ios
$ authorize-ios
  1. Launch the IOS Simulator by opening XCODE or Launch it through command Line

See all the Available Simulator Devices Created along with UDID

xcrun simctl list

Install and Launch the Application

xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>

Need Help? xcrun simctl help

Verify Appium Installation is Successful

Install appium-doctor to verify that all of Appium’s dependencies are met :

$ npm install -g appium-doctor
$ appium-doctor
$ appium-doctor --ios
$ appium-doctor --android
  1. Install the Inspector that you can use to look at your app's elements, get basic information about them, and perform basic interactions with them I Suggest the Following based on my experience :

IOS - Appium Desktop Android - UI Automator Viewer

This is first among the series of posts related to Appium and Mobile. Please let me know your feedback and suggestion.

I hope you find this setup useful in powering your mobile automation tests.What are the exciting ideas that you have related to mobile automation — and how are you implementing them? Let us know in the comments.

If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter or Facebook. Thank you!

--

--