Appium isn’t limited to automating mobile systems. As long as there is an open way to interact with a user interface, a driver can be written for it, and included in Appium. Using a project called Appium For Mac Appium can automate native macOs apps.

Requirements

On top of standard Appium requirements Mac2 driver also expects the following prerequisites:

  • macOS 10.15 or later
  • Xcode 12 or later
  • Xcode Helper app should be enabled for Accessibility access. Security & Privacy -> Privacy -> Accessibility list of your System Preferences.
  • testmanagerd procccess requires UIAutomation authentication. automationmodetool enable-automationmode-without-authentication command may help to disable it.

Mac Capabilities

Capability Name Description
platformName Set to mac
automationName Set to mac2
appium:systemPort The number of the port for the internal server to listen on. If not provided then Mac2Driver will use the default port is 10100
appium:systemHost The name of the host for the internal server to listen on. The default host is 127.0.0.1
appium:webDriverAgentMacUrl Appium will connect to an existing WebDriverAgentMac instance at this URL instead of starting a new one
appium:showServerLogs Include xcodebuild output log. Default is false
appium:serverStartupTimeout The number of milliseconds to wait util the WebDriverAgentMac project is built and started. Default is 120000
appium:bundleId The bundle identifier of the application to automate
appium:noReset Whether to restart the app

Absolute AXPath

AppiumForMac is a little tricky, since elements can only be found using a special kind of XPath selector called “absolute AXPath”. All the AXPath selectors use Accessibility API identifiers and properties.

AppiumForMac provides a tool for generating the AXPath of any element on the screen. First, launch the AppiumForMac app manually using Finder or Launchpad. It won’t display a window, but will appear in the dock. If you hold the fn key on your keyboard down for about three seconds, AppiumForMac will find the AXPath string to select whichever element your mouse pointer is currently hovering over. It stores the AXPath selector into your clipboard, so you can paste it into your test code. You’ll know when it has worked because the AppiumForMac icon jumps out of the dock.

This behavior will work anywhere on your screen, because AppiumForMac can actually automate anything which is available to the Accessibility API.

Run Test

Here’s an example test:

Copy to Clipboard