-
Notifications
You must be signed in to change notification settings - Fork 369
Instrumenting your Application for Calabash iOS
To get the most from Calabash iOS, you should instrument your app for testing.
Xamarin Studio users can find more information on the Custom Controls with Xamarin Studio, and Accessibility for Calabash iOS page.
Don't be confused: instrumenting your app has nothing to do with Apple's Instruments.app or the instruments
command line tool. When you instrument an app, you add information and behaviors that make it easy to gain insights into the runtime behavior of an application.
There are two categories of instrumentation that can improve your Calabash iOS testing experience.
- Add meaning Accessibility properties to your UIView instances.
- Use backdoors to implement complex behaviors that are usually achieved by complex UI interactions.
Queries that use the marked:
syntax search your app for views with matching accessibilityIdentifiers
and accessibilityLabels
. marked:
will also match on text
, but let's put that aside for now.
Whenever possible, use accessibilityIdentifier
instead of accessibilityLabel
. Accessibility labels are used for Voice Over. As such, they should be localized and should follow a specific capitalization format to assist Voice Over enunciation.
For more information about Accessibility Label best practices, see the Apple documentation
button.accessibilityIdentifier = @"center-to-location";
button.accessibilityLabel = @"Center map";
switch.accessibilityIdentifier = @"coffee need refill?";
button.accessibilityLabel = @"Refill coffee?";
webView.accessibilityIdentifier = @"landing page";
webView.accessibilityLabel = NSLocalizedString(@"Landing page",
@"The web view start page.");
===
The WWDC 2013 video is highly recommended because it contains an excellent demonstration.
Buttons in UIToolbars
and UINavigationBars
are generated at runtime from UIBarButtonItem
instances. There is no way to set the accessibilityIdentifier
on a UIBarButtonItem instance and have it apply to the button that is created at runtime. Further, UIKit
will often overwrite an accessibilityLabel
that you put on UIBarButtonItem
instances. The exception is when the item is created using the initWithCustomView:
selector; items created with this selector often respect labels and identifiers at runtime.
Content in progress.
Content in progress.