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

ability to select non-accessible elements #31

Closed
doronpr opened this issue Oct 5, 2016 · 7 comments
Closed

ability to select non-accessible elements #31

doronpr opened this issue Oct 5, 2016 · 7 comments

Comments

@doronpr
Copy link
Contributor

doronpr commented Oct 5, 2016

For example, the navigator's Back UIAButton

@talkol talkol added this to the Version 1 milestone Oct 6, 2016
@talkol talkol self-assigned this Oct 6, 2016
@talkol
Copy link

talkol commented Oct 11, 2016

should be possible with a mixture of current matchers

I would look at a combination of native class + ancestor + button trait

please confirm that you found a working matcher, share a gist with it and close this issue :)

@talkol talkol assigned doronpr and unassigned talkol Oct 11, 2016
@doronpr
Copy link
Contributor Author

doronpr commented Oct 12, 2016

👍

@doronpr doronpr closed this as completed Oct 12, 2016
@talkol
Copy link

talkol commented Oct 13, 2016

you have a gist to share with how to match iOS back button? (for future generation benefit)

@doronpr
Copy link
Contributor Author

doronpr commented Oct 13, 2016

oops forgot to share a gist! Here it is -
There are two options that worked for me:
element(by.type('_UINavigationBarBackIndicatorView')).tap();
or
element(by.label('Back').withAncestor(by.type('UINavigationItemButtonView'))).tap();

@talkol
Copy link

talkol commented Oct 13, 2016

I like the 2nd one better but I would prefer to avoid the label because: (1) can be localized (2) if you have a title on the previous screen does it have its title there instead of generic "Back"?

What about replacing the by.label part with traits and look for a button?

How does this gist work when we have custom buttons in the nav bar?

@doronpr
Copy link
Contributor Author

doronpr commented Oct 13, 2016

So:
element(by.type('UINavigationItemButtonView')).tap();
and
element(by.traits(['button']).withAncestor(by.type('UINavigationBar'))).tap();

both works for the back button. BUT I suspect that these selectors could incorrectly match other navigation button (custom). Not sure though, we should probably try them against different variations of the nav bar. I can't however seem to find an explicit way to get to the Back button without an accessibility ID or label (except for the _UINavigationBarBackIndicatorView which is using an internal class so not ideal).

For custom button, you can use this (it does not match the Back button):
element(by.type('UINavigationButton'))

@talkol
Copy link

talkol commented Oct 17, 2016

hmm.. interesting. Maybe we can use not() then, to avoid matching the custom buttons. It's an undocumented matcher that works just like and().

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants