Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIAlertController.StyleAlert button duplicity wrinkle #271

Open
gurgeous opened this issue Sep 16, 2016 · 6 comments
Open

UIAlertController.StyleAlert button duplicity wrinkle #271

gurgeous opened this issue Sep 16, 2016 · 6 comments

Comments

@gurgeous
Copy link
Contributor

I can't easily test UIAlertController.StyleAlert because each button has two accessible views with the same label:

Exception: MultipleElementsFoundException
Reason: Action 'Tap' was not performed because multiple UI elements matching ((respondsToSelector(isAccessibilityElement) && isAccessibilityElement) && accessibilityLabel("Download")) were found. Use grey_allOf(...) to create a more specific matcher.
Complete Error: Multiple elements were matched: (
    "<_UIAlertControllerActionView:0x7f9df3435eb0; AX=Y; AX.label='Download'; AX.frame={{188, 352}, {134.5, 44}}; AX.activationPoint={255.25, 374}; AX.traits='UIAccessibilityTraitButton'; AX.focused='N'; frame={{0, 0}, {134.5, 44}}; opaque; alpha=1>",
    "<UILabel:0x7f9df34369f0; AX=Y; AX.label='Download'; AX.frame={{216, 364}, {78.5, 20.5}}; AX.activationPoint={255.25, 374.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 12}, {78.5, 20.5}}; opaque; alpha=1; UIE=N; text='Download'>"
). Please use selection matchers to narrow the selection down to single element.

It's easy to workaround the issue with grey_allOf, but this is a common case that should be handled by the framework in my opinion.

@tirodkar
Copy link
Collaborator

Hmm, I wonder if that might be an issue when considering tapping on custom UIAlertControllers that have their own views in the buttons or so. BTW, are you able to tap on the alert using grey_text(@"Download")? as in here

@gurgeous
Copy link
Contributor Author

grey_text works great, thanks! This is the first I heard of it, though, and I've been perusing the project for a few weeks now. Is it documented somewhere?

@tirodkar
Copy link
Collaborator

It isn't documented anywhere per se, it's a part of disambiguating the matchers. Notice how in the trace,

"<_UIAlertControllerActionView:0x7f9df3435eb0; AX=Y; AX.label='Download'; AX.frame={{188, 352}, {134.5, 44}}; AX.activationPoint={255.25, 374}; AX.traits='UIAccessibilityTraitButton'; AX.focused='N'; frame={{0, 0}, {134.5, 44}}; opaque; alpha=1>",
"<UILabel:0x7f9df34369f0; AX=Y; AX.label='Download'; AX.frame={{216, 364}, {78.5, 20.5}}; AX.activationPoint={255.25, 374.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 12}, {78.5, 20.5}}; opaque; alpha=1; UIE=N; text='Download'>"

The text='Download' was what separated the two. We try to provide matchers that can help identify and pinpoint these differing characteristics.

@bootstraponline
Copy link
Contributor

Is it documented somewhere?

Yes, it's documented in the cheatsheet

@gurgeous
Copy link
Contributor Author

Just listing the method name doesn't count! :)

If this is the best way to find buttons, it should be more prominent in the docs.

@tirodkar
Copy link
Collaborator

@gurgeous, agreed :). We have the Selection API section in our docs to cover this. If you feel it's not clear enough when it comes to pointing to grey_text(), then feel free to add to it or provide a suggestion on how to make it more clear to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants