Testing for Accessibility on OS X
Whether you’re designing a new app or access-enabling an existing one, you should plan to test the accessibility of your product. Testing for accessibility is a bit different than standard user interface testing, and Apple provides a couple of tools that make the process easier. After you’ve discovered accessibility bugs with VoiceOver, inspect your app with these tools to resolve the problems.
App developers should read this chapter to find out how to exercise the accessibility of their apps.
Using the Accessibility Inspector
Apple provides the Accessibility Inspector testing tool that can be launched by choosing Xcode > Open Developer Tool > Accessibility Inspector in the menu bar or Dock. You can download Xcode from the Mac App Store for free. The Accessibility Inspector presents a utility window that displays the information properties (and values), action methods, and position in the accessibility hierarchy of the object currently under the mouse pointer.
If you’re beginning to access-enable your app for assistive technologies like VoiceOver, try using the Accessibility Inspector to view the accessibility information other apps provide. Although the Accessibility Inspector is not an accessibility client, it uses the same APIs accessibility clients use to get information from the accessibility objects it encounters.
To use the Accessibility Inspector, first make sure that it has permission to control your computer. In Security & Privacy preferences, open the Privacy pane. In the left column, select the Accessibility option. In the right column, make sure the Accessibility Inspector app is checked as shown in.
Now, launch the Accessibility Inspector and move your mouse over the UI element you want to inspect. If you’re using VoiceOver to navigate, you can move the mouse to the VoiceOver cursor by pressing Control-Option-Command-F5. You can lock the Accessibility Inspector on the item under the mouse to examine its attributes, perform its actions, and access its parent and children (if any), by pressing Command-F7. When you do this, the Accessibility Inspector display pauses, allowing you to move the mouse without changing the object on which the tool is focused. In the main utility window, you can go to the object’s parent, children, or other related objects, such as the containing window or the top-level app (
AXApplication). You can also perform the actions supported by the accessibility object, allowing you to see how these actions affect the values of various attributes and the app itself. If you click the rectangular button in the bottom-right corner of the Accessibility Inspector panel, you’ll see a light blue overlay over the locked UI element.
AXPress action for the element is selected and can be activated by clicking the Perform Action button.
The Accessibility Inspector also includes the ability to navigate the Accessibility tree hierarchy using visible buttons or keyboard commands. While holding the Control and Command keys, use the arrow keys to navigate. The up and down arrows navigate to parents or children, and the left and right arrows navigate to siblings of the current element.
You can use the Accessibility Inspector to modify any properties that are marked as writable, as denoted by a W in parentheses. For example, navigate up to the
AXWindow attribute, and select its
AXPosition property (see ). Change the values of the X and Y text fields, and click the Set Value button. The window changes its position on the screen. You can also perform certain actions, such as
AXShowMenu, by selecting the action and clicking the Perform Action button.
As you access-enable your app, use the Accessibility Inspector to make sure your objects contain the appropriate information. If you find that a specific object is not accessible, you can focus the Accessibility Inspector on that object, examine its information property values, and trigger its action methods to find the problem.
Using Accessibility Verifier
Apple provides the Accessibility Verifier tool that can be launched by choosing Accessibility Inspector > Window > Accessibility Verifier. Accessibility Verifier displays the accessibility hierarchy comprising all currently instantiated objects in the selected app. To use Accessibility Verifier, be sure to enable it in Security & Privacy preferences.
Use Accessibility Verifier to perform any or all of the following tests (select the tests you want to run by clicking the Choose Tests button):
Parent/Child. This test checks the integrity of the accessibility hierarchy by making sure each parent-child pair forms a closed loop. For example, if a child listed in a parent object’s
accessibilityChildrenproperty does not refer to that object as its parent, this parent-child pair is invalid. Invalid parent-child pairs can prevent an accessibility client from correctly traversing an app’s accessibility hierarchy.
Window. This test checks that all objects contained in a window contain a reference to that window in their
accessibilityWindowproperty. An object contained in a window is not necessarily the child of that window, but it should refer to its containing window as a convenience for accessibility clients.
Missing AXDescription. This test checks the element’s
accessibilityLabelproperty. All accessible elements must provide some context-specific, descriptive label.
Role Verification. This test verifies that an accessibility object implements all the properties and methods required for its role.
When you click Verify, Accessibility Verifier runs the tests you selected and displays the results for each. The problems are reported as warnings or errors, depending on their severity (you can filter the results by selecting a severity level in the Report Level pop-up menu).
Eliminating all errors and warnings that Accessibility Verifier displays does not guarantee a perfectly accessible app. Always test your app with various accessibility clients, such as VoiceOver, to make sure there are no problems.