Adding Accessibility Identifiers to an iOS App
Accessibility Identifiers are the easiest way of locating an element in the app. They are also very simple to add — below is my short guide on how to do that, very basic Xcode/macOS knowledge is required.
In this tutorial, we will be adding an Accessibility Identifier to Appium test app called IOS UI Catalog. You can grab it from this repository — https://github.com/appium/ios-uicatalog
1. Once you have it, open your Xcode and load the project.
2. open the storyboard for the iPhone in Xcode’s interface builder.
3. Select an element using the main view or from the tree view on the left. For this tutorial, we will be adding an Accessibility Identifier to the “Action Sheets” table cell view.
4. Switch to “Identity inspector” if it’s not selected already
5. In the “User Defined Runtime Attributes”, click the plus button and change the following:
a) Replace KeyPath with “accessibilityIdentifier”
b) Change the type to string
c) Set the value to what you want the Accessibility ID to be — i set it to “action_sheets_button” (screenshot of final attribute below)
6. Build the app for your device
7. Open the app using Appium GUI
8. When you select the Action Sheets button, notice that the “name” attribute is now the Accessibility Identifier that you gave it!
To test your accessibility Identifier, use the Appium GUI’s locator tester.
- change strategy to “accessibility id”
- type in “action_sheets_button” in the value field
- hit Search
And the element should be located!