KIF test failing - view is not enabled for interaction

2.2k Views Asked by At

Trying to run a KIF test. I want to tap the button with accessibility label "LOG IN" but it times out with the message "view is not enabled for interaction".

[tester tapViewWithAccessibilityLabel:@"SIGN IN"];

The button is there, and it has this text in its label. How do I "enable" this UI element?

3

There are 3 best solutions below

0
On

You get this error message if isUserInteractionActuallyEnabled of a view yields NO. For example have a look at the definition of tapAccessibilityElement:inView: in KIFUITestActor.m. The method isUserInteractionActuallyEnabled is implemented in UIView-KIFAdditions.m and basically checks the property isUserInteractionEnabled of a view and does some more elaborate checks if you tap a button in a navigation bar or an action sheet.

0
On

FOR KIF: Another way to tell information for user interaction on views is to turn on the Accessibility Inspector within the iOS simulator. This will let you click on views and see if they're actually clickable/or blocked by other views inadvertently. It will also show you if the view has an accessibility label, trait (button, label, static text), and/or frame. Useful for checking your user interaction - ie. if it's static text or a button etc.

TO TURN ON ACCESSIBILITY INSPECTOR: Run your app, open the simulator--->click on the home button---->go to settings--->general--->accessibility--->toggle the accessibility inspector to ON--->run your app again or click on HOME button again, then click on your app.

1
On

You should try to set accessibilityLabel in Xcode's interface builder under the identity inspector at the user defined runtime attributes (with the key path set to "accessibilityLabel", type set to "String" and value set to "SIGN IN".

There are other ways to set accessibilityLabel like from code you can say:

[_buttonName setValue:@"SIGN IN" forKey:@"accessibilityLabel"];

I hope this one helped.