Mobile Testing

how to install Appium on MAC OS with all external tools and components. I will try to explain each step respectively. Let’s start.
Step-1: Install JAVA JDK

You should go to the below link and install JAVA JDK for MAC OS.

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

After installation check below path to find JAVA HOME, for my version it is as shown below.

/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

java-home-on-mac

Then set JAVA HOME on your Mac as shown below:
Shell
1

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

Then, run below command to check your JAVA HOME.
Shell
1

echo $JAVA_HOME

Note that this sets JAVA_HOME only for a session. If you want it to persist always for all sessions, you need to add the command to your ~/.profile file.

Open a new terminal window.
Open a .profile file by typing: emacs .profile
Type below commands:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
export JAVA_HOME;
Then, do the (ctrl-x, ctrl-s; ctrl-x, ctrl-c) to save and exit emacs.
Open a new terminal and run below command:
$JAVA_HOME/bin/java -version
You should see below screenshot with your java version number.

java version on mac

If you have MAC OS 10.5 or newer you can just use below command:
Shell
1
2

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

then source the profile file:
Shell
1

source ~/.profile

Then check the result:
Shell
1

echo $JAVA_HOME

java-settings-in-macos
Step-2: Install Android Studio

You need to go to the below address, download Android Studio for Mac and do the followings as stated below.

https://developer.android.com/studio/

[1] To install Android Studio on your Mac, proceed as follows:

Launch the Android Studio DMG file.
Drag and drop Android Studio into the Applications folder, then launch Android Studio.
Select whether you want to import previous Android Studio settings, then click OK.
The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.

android studio for mac

When u open and select the default settings, Android Studio will start to download the required libraries as shown below.

android studio download packages on mac

android-studio-installed-on-mac

Do below settings in .profile file. Open a terminal and type
Swift
1

nano ~/.profile

Then, paste below commands: (Change your user name! Not use my username “onur”).
Shell
1

export ANDROID_HOME=/Users/onur/Library/Android/sdk

Shell
1

export PATH=$ANDROID_HOME/platform-tools:$PATH

Shell
1

export PATH=$ANDROID_HOME/tools:$PATH

java-settings-in-macos
Step-3: Install Homebrew
Open a terminal window and run below command to install brew:
Shell
1

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

home brew installation on mac

Close all terminal windows and reopen a terminal window and check the Android home by typing below command:
Shell
1

echo $ANDROID_HOME

android-home-on-mac-check
Step-4: Install Node.js and npm

Go to https://nodejs.org/en/download/ download and install node package. It is pretty straight forward.

To see if Node is installed, type in node -v Terminal.

To see if NPM is installed, type in npm -v Terminal.

In order to update Node and NPM, you can use Homebrew to update these two:

Make sure Homebrew has the latest version of the Node package. In Terminal type brew update
Upgrade Node: brew upgrade node

Step-5: Install Appium on Terminal

In order to install appium via terminal you need to run below commands:
Shell
1
2
3

npm install -g appium #get appium

npm install wd #get appium client

Note: If you face with permission problems as shown below, please run below commands on terminal. [owner] is your user name. To find it, you can run below command first:

permission-error-npm-on-mac

Shell
1
2
3

id -un #Gives you your user name (Use it as owner below.)

sudo chown -R [owner] /usr/local/lib/node_modules

Then, try to run appium installation commands. They will work as shown below.

appium-installation-on-mac-using-terminal
Step-6: Install Carthage
First, change the permissions as shown below command:
Shell
1

sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7

Then, go to the below directory:
Shell
1

cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

Then, install Carthage:
Shell
1

brew install carthage

carthage-installation-on-mac

And run below command:
Shell
1

npm i -g webpack

install-webpack-on-mac

If everything is successful, then try to start appium as below commands:

cd

appium

start-appium-on-mac-on-terminal
Step-7: Download Appium Desktop

Let’s go this link: https://github.com/appium/appium-desktop/releases/ and download appium for mac. You should click and download .dgm file. For example, “Appium-1.10.0.dmg“. When the download finishes, double click the .dgm file and drag and drop the Appium into Applications as shown below.

appium installation on mac

Then, you will see appium logo in your applications when you click to the launchpad icon as shown below.

appium mac
Step-8: Install libimobiledevice

In order to run our tests on real devices, we need to install libimobiledevice dependency by executing brew install libimobiledevice command on terminal.

libimobiledevice
Step-9: Install XCode

Download Xcode from Mac AppStore and install Xcode.

xcode-installation

Once installed, Launch Xcode and select Xcode > Preferences > Components to install the simulators that you might want to test against.

xcode-install-simulator
Step-10: Install Authorize-ios

authorize-ios is a utility which pre-authorizes to run UIAutomation scripts on iOS devices. We need this tool for running our tests on real devices.

In order to install it, open a terminal window and run the following command:

Shell
1

npm install -g authorize-ios

authorize-ios-installation
Step-11: Install ios-deploy

To deploy our apps to our devices by using ios-deploy. We can install and debug apps from the command line without using Xcode.

In the terminal, enter the following:

Shell
1

brew install ios-deploy

install-ios-deploy
Step-12: Install ideviceinstaller

ideviceinstaller helps us to install, uninstall, upgrade, archive, restore and enumerate installed or archived apps. We need this utility to run tests on real devices. In order to install it, run below commands:
Shell
1
2
3

sudo xcode-select -r

brew install ideviceinstaller

install-ideviceinstaller
Step-13: Install ios_webkit_debug_proxy

In order to access web views on real iOS devices, we need to install this tool. Run the below command:
Shell
1

brew install ios-webkit-debug-proxy

ios-webkit-debug-proxy
Step-14: Install Appium Doctor

Appium Doctor checks most of the preconditions for appium to run successfully. In order to install it, run below command:

Shell
1

npm install -g appium-doctor

appium-doctor

Let’s run appium doctor and see what we should do for Appium.

appium-doctor-results
Step-15: Install Maven

It is used for building and managing Java-based projects by using dependencies. Open a terminal and run below command.

Shell
1

brew install maven

Then, check installation with below command:
Shell
1

mvn -version

maven-installation-on-macos

Then, add the maven path to your profile file.
Shell
1

export PATH=/usr/local/Cellar/maven/3.6.0/bin:$PATH

All tools for iOS and Android automation for MAC environment is ready now. We can go on to start Android and iOS test automation from here.