Running Appium on Mac OS X

Appium on OS X supports iOS and Android testing.

System setup (iOS)

Authorizing iOS on the computer

You need to authorize use of the iOS Simulator by running the authorize-ios binary made available through npm. Install the program by running

npm install -g authorize-ios

And the invoke the program using

sudo authorize-ios

If you are running Appium.app, you can authorize iOS through the GUI.

You need to do this every time you install a new version of Xcode.

Testing against multiple iOS SDKs

Xcode version 7.1 allows for automatic testing against iOS versions 7.1 and later.

If you're using multiple Xcode versions, you can switch between them using:

sudo xcode-select --switch <path to required xcode>

Testing using Xcode 8 (including iOS 10) with XCUITest

In order to automate iOS devices with Xcode 8 (which includes all testing of iOS 10+), you need to install the Carthage dependency manager:

brew install carthage

Testing Mac apps

Currently, the Mac app driver for appium does not ship with the AppiumForMac binary, which means, in order to automate Mac apps you must manually install the AppiumForMac application and grant it the appropriate OS X Accessibility permissions.

To Install Appium for Mac: 1. Download a release and unzip the application into your /Applications folder 2. Follow the brief supplemental installation instructions to enable appium to have access to OS X's Accessibility APIs

For more information on using Appium for mac, checkout the docs.

System setup (Android)

Instructions for setting up Android and running tests on Mac OS X are the same as those on Linux. See the Android setup docs.

Running iOS tests on OS X using Jenkins

First download the jenkins-cli.jar and verify the Mac successfully connects to Jenkins master. Ensure you've run the authorize-ios command mentioned above.

wget https://jenkins.ci.cloudbees.com/jnlpJars/jenkins-cli.jar

java -jar jenkins-cli.jar \
 -s https://team-appium.ci.cloudbees.com \
 -i ~/.ssh/id_rsa \
 on-premise-executor \
 -fsroot ~/jenkins \
 -labels osx \
 -name mac_appium
 ```

Next define a LaunchAgent for Jenkins to launch automatically on login. A LaunchDaemon will not work because daemons don't have GUI access. Make sure the plist doesn't contain the `SessionCreate` or `User` key as that may prevent tests from running. You'll see a `Failed to authorize rights` error if misconfigured.

$ sudo nano /Library/LaunchAgents/com.jenkins.ci.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> Label com.jenkins.ci ProgramArguments java -Djava.awt.headless=true -jar /Users/appium/jenkins/jenkins-cli.jar -s https://instructure.ci.cloudbees.com on-premise-executor -fsroot /Users/appium/jenkins -executors 1 -labels mac -name mac_appium -persistent KeepAlive StandardOutPath /Users/appium/jenkins/stdout.log StandardErrorPath /Users/appium/jenkins/error.log


Finally set the owner, permissions, and then start the agent.

sudo chown root:wheel /Library/LaunchAgents/com.jenkins.ci.plist sudo chmod 644 /Library/LaunchAgents/com.jenkins.ci.plist

launchctl load /Library/LaunchAgents/com.jenkins.ci.plist launchctl start com.jenkins.ci



### Files generated by iOS test runs

Testing on iOS generates files that can sometimes get large. These include logs,
temporary files, and derived data from Xcode runs. Generally the following locations
are where they are found, should they need to be deleted:

$HOME/Library/Logs/CoreSimulator/*


For Instruments-based tests (iOS _not_ using `XCUITest` as `automationName`):

/Library/Caches/com.apple.dt.instruments/*


For XCUITest-based tests:

$HOME/Library/Developer/Xcode/DerivedData/* ```