Question

I'm writing a KIF test to test the onboarding flow of the iPhone app I'm working on. When asking the ALAssetsLibrary for access the usual alert view pops up, but KIF doesn't recognize the accessibility labels of this alert view.

Screenshot

My test fails when I test for the following:

[tester waitForViewWithAccessibilityLabel:@"OK"];

This while my Accessibility Inspector in my iOS Simulator clearly states that this is the right label for this view.

I'm wondering if this is because these alert views are outside the sandbox, does anybody know if this is the case and if there might be some work around for testing it with KIF?

Any help is greatly appreciated.

Was it helpful?

Solution

The problem might be that UIAlertViews are shown in an other window, or like you suspect, the alert view is presented from another process which should be unreachable to the apps code. Is there a way to check for views in another UIWindow instance?

Update

As noted here: https://groups.google.com/forum/#!msg/kif-framework/iDBomK8kyL8/wLtlh80YrpsJ

As I understand it touch events are routed by iOS to a UIWindow, which is then responsible for dealing with them as it sees fit. KIF and friends use a technique where touch events are synthetically created and then sent to a UIWindow. Since your app code doesn't have access to the UIWindow which is presenting the alert box, your app has no way to send it a touch event.

Of course you can manually loop through the windows of the UIApplication with [[UIApplication sharedApplication] windows] or use [[UIApplication sharedApplication] keyWindow], but I don't think the testing framework supports that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top