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.
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
testmanagerd procccess requires UIAutomation authentication.
automationmodetool enable-automationmode-without-authentication command may help to disable it.
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.
Here’s an example test: