For example, the navigator's Back UIAButton
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 :)
馃憤
you have a gist to share with how to match iOS back button? (for future generation benefit)
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();
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?
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'))
hmm.. interesting. Maybe we can use not() then, to avoid matching the custom buttons. It's an undocumented matcher that works just like and().
Most helpful comment
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();