Testing for Accessibility on OS X

Whether you’re designing a new application 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.

Application developers should read this chapter to find out how to exercise the accessibility of their applications.

Using Accessibility Inspector

Apple provides the Accessibility Inspector testing tool that can be launched by selecting Xcode > Open Developer Tool > Accessibility Inspector in the menu bar or Dock. You can download Xcode from the Mac App Store for free. Accessibility Inspector presents a utility window that displays the attributes (and values), actions, and position in the accessibility hierarchy of the object currently under the mouse pointer.

If you’re beginning to access-enable your application for assistive technologies like VoiceOver, try using Accessibility Inspector to view the accessibility information other applications provide. Although Accessibility Inspector is not an assistive application, it uses the same APIs assistive applications use to get information from the accessibility objects it encounters.

To use Accessibility Inspector, first ensure that “Enable access for assistive devices" is enabled in the Accessibility pane of System Preferences. Launch the Accessibility Inspector and move your mouse over the UI element you wish to inspect. If you're using VoiceOver to navigate, you can move the mouse to the VoiceOver cursor by pressing Command-Option-Control-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 AXApplication. You can also perform the actions supported by the accessibility object, allowing you to see how this affects the values of various attributes and the application itself. If you click the rectangular button in the bottom right corner of the Accessibility Inspector panel, you'll see light blue overlay over the locked UI element.

Figure 4-1  The Accessibility Inspector locked on the Spotlight icon in System Preferences. The AXPress action for the element is selected and can be activated by clicking the Perform Action button.

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, while the Left and Right Arrows navigate to siblings of the current element.

You can use 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, and select its AXPosition property. Change the values of the X and Y text fields and click the Set Value button. The window will change its position on the screen. You can also perform certain actions such as AXPress and AXShowMenu by selecting the action and clicking the Perform Action button.

Figure 4-2  The Accessibility Inspector locked on the System Preferences main window. The AXPosition property for the element is selected and can be modified because it is writable (W).

As you access-enable your application, use Accessibility Inspector to make sure your objects contain the appropriate information. If you find that a specific object is not accessible, you can focus Accessibility Inspector on that object and examine its attribute values and perform its actions to find the problem.

Using Accessibility Verifier

Apple provides the Accessibility Verifier tool that can be launched by selecting Accessibility Inspector > Window > Accessibility Verifier. Accessibility Verifier displays the accessibility hierarchy comprising all currently instantiated objects in the selected application. To use Accessibility Verifier, be sure to enable assistive applications in the Accessibility pane of System 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):

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).

It’s important to note that eliminating all errors and warnings Accessibility Verifier displays does not guarantee a perfectly accessible application. You should always test your application with various assistive technologies like VoiceOver to make sure there are no problems.