How to setup Appium on Mac OS to run automated tests from JAVA classes on Android and iOS devices How to setup Appium on Mac OS to run automated tests from JAVA classes on Android and iOS devices android android

How to setup Appium on Mac OS to run automated tests from JAVA classes on Android and iOS devices


Answered by Igor VishnevskiyI have been looking for the answer everywhere on the internet and could not find anything. It took me some time to make this work. I hope this quick guide will help the next engineer to save some time on setting up Appium to run automation on Android devices. Appium will not run if NODE or Appium itself is installed using SUDO and MAC won't let you install neither without using SUDO. There is a workaround though. My steps make it possible to install and setup Appium the right way without need to use SUDO for installation. Everything is tested and it works. Below are the steps. Enjoy!

There could be one problem while setting up Appium using bellow steps. If you face some errors while creating or saving data into certain directories, that is caused by the luck of write permissions set to those directories. What you will need to do is to set CHMOD to 777 to the directories where components of Appium are trying to write while installing and then rerun all steps again.

Step 1:Install JAVA 6. You will need JAVA 6 with Appium. JAVA 6 for Mac OS has to be downloaded from Apple's support page:http://support.apple.com/kb/DL1572

Step 2:In your bash add the following path using following format:

export PATH=$HOME/local/bin:$PATH

Step 3:Setup Maven (Download and set Bash profile PATH for Maven):

http://maven.apache.org/download.cgi

------>This is what your Bash Profile should look like:

export PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/platform-tools":$PATHexport PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/tools":$PATHexport PATH=$HOME/local/bin:$PATHexport ANDROID_HOME=/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140321/sdkexport PATH="/Users/your_username/Desktop/apache-maven-3.2.2/bin":$PATHexport JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

Obviously to run tests on Android device, you will need to download Android SDK and add it to your Bash Profile as well. To run tests on iOS devices, you will only need to install XCode, no need to add that to your Bash profile. But Android SDK has to be added.

Step 4:Copy and paste following sequence of commands into your Terminal window and press ENTER. Copy and pasting it all together will work. It will take some time to install NODE, so be patient.

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc. ~/.bashrcmkdir ~/localmkdir ~/node-latest-installcd ~/node-latest-installcurl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1./configure --prefix=~/localmake install

Step 5:After installation from Step 4 is complete, run following command in your Terminal window:

curl https://www.npmjs.com/install.sh | sh

Step 6:Then in your Terminal window execute following command:

npm install -g grunt-cli

Step 7:Then in your Terminal window execute following command:

npm install -g appium

Step 8:Then in your Terminal window execute following command:

npm install wd

Step 9:Then in your Terminal window execute following command to start the Appium server:

appium &

(step 9 will start the server).

Step 10:From the separate terminal Windowcd to root directory of your JAVA project in your workspace.(example: cd /Users/ivishnevskiy/Documents/workspace/ApiumJUnit)

Step 11:Attach your Android device to USB and to your MAC computer.

Step 12:In the same Terminal window from Step 10, run following command to launch the Appium test:

mvn -Dtest=test.java.com.saucelabs.appium.AndroidContactsTest test

where test.java.com.saucelabs.appium is a package nameandAndroidContactsTest is a class name.

If you still need help setting it up. Let me know. I can help. My LinkedIn:http://www.linkedin.com/pub/igor-vishnevskiy/86/51a/b65/

AFTER SETTING APPIUM UP ON YOUR DEVICE, FOLLOW MY NEXT TUTORIAL TO CREATE IN ECLIPSE AND RUN YOUR FIRST TEST ON THE ACTUAL iOS DEVICE (NOT EMULATOR):https://stackoverflow.com/questions/24919159/


I used this post to help me set up Appium on my Mac. I also used other sources to do my installation completely. Here are step by step instructions to upgrade to appium 1.7.x seamlessly on your Mac OS X.

Please make a note of the following details BEFORE you start the upgrade process

  • If Appium is not installed on your system previously, please use ONLY the commands related to "Install" below
  • If you face any problem of deleting folder/directories using command line, please go to Finder and delete it
  • Once you upgrade to new OS on your Mac machine, App Store and iTunes may open late and work slow for the first time

Step by Step Instructions

  1. Need to install OS 10.12.x or higher version.

  2. Need to install Xcode 9.x. Sign in with your developer account (https://developer.apple.com/download/more/) and download it OR Download it free from the Mac App store

Note - If you face problems while installing the new version of Xcode then please uninstall the old versions.

  1. Need to install the Command line tools for Xcode 9.x.

Launch Terminal and enter the below command

xcode-select --install
  1. Uninstall HomeBrew

Uninstall Command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
  1. Install HomeBrew

Install Command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Uninstall all instances of Node

    • go to /usr/local/lib and delete any node and node_modules

    • go to /usr/local/include and delete any node and node_modules directoryif you installed with brew install node, then run brew uninstall node in your terminal

    • check your Home directory for any local or lib or include folders, and delete any node or node_modules from there. (To reach home directory open Terminal and enter cd)

    • go to /usr/local/bin and delete any node executable

  2. Install Node

Command:

brew install node
  1. Install ideviceinstaller:

Command:

brew install ideviceinstaller
  1. Uninstall Appium from terminal

Command:

npm uninstall -g appiumnpm cache clean --force
  1. Install Appium

Command:

npm install -g appium@1.7.2** (Or we can just do npm install -g appium)
  1. Need to Install supporting tools for Appium 1.7.2

Command:

brew install carthagenpm install -g ios-deploynpm install -g deviceconsole
  1. For downloading simulators go to Xcode --> Preferences --> Components, and download necessary simulators.


Steps that need to follow:

  1. install xcode
  2. install xcode command line tool
  3. install Appium GUI *.dmg file Appium
  4. Install homebrew (assuming you have ruby installed on your mac, if not install ruby first)
  5. Install Java (it should come with mac OS)
  6. Install node and Maven using brew command from terminal
  7. Install Appium server using node
    • npm install –g appium
    • appium &
  8. Authorize your iOS simulator and device to access by Appium by typing the command from terminal: sudo authorize_ios

:)

I have made a video about how to configure appium on a Mac computer which can be viewed here.

And slides can be viewed here.