Accessibility and UI Testing in iOS

But First… Accessibility

Here the screen appears to be locked, but the user is actually interacting with an app via accessibility gestures.
Note the rectangle around the FaceTime app — that is the Accessibility cursor.
UIAccessibility: var accessibilityLabel: String? { get set }
UIAccessibility: var accessibilityIdentifier: String? { get set }
UIAccessibility: var isAccessibilityElement: Bool { get set }

The default value for this property is false unless the receiver is a standard UIKit control, in which case the value is true.

UIAccessibilityContainer: var accessibilityElements: [Any]? { get set }

XCUITest

From your XCode file menu, select New -> Target, and select iOS UI Testing Bundle
An example of a UI Test in progress.
Tap the play button to run all of the tests included in that target, file, or test method.
An example of how your Applitools dashboard may look.

Making Your UI Tests CI-friendly

xcodebuild test -workspace App.xcworkspace scheme “$SCHEME” -configuration Debug -destination platform=”iOS Simulator”,name=”$DEVICE”,OS=$OS -only-testing:UITests/Tests/test01 DEVICE_NAME=”${DEVICE}” BATCH_ID=${APPLITOOLS_BATCH_ID} MARKET=${MARKET}

Our local UI testing script summons the iOS simulator, then proceeds to build the project using xcodebuild.

Debugging

I was unable to tap a button because of a ratings prompt!
By doing “po self.app”, I am able to see the entire accessibility hierarchy of my app in its current state.

Common Pitfalls/Other Tricks

sleep(1.0)

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store