0

I would like to know if there is a possibility to use in EarlGrey something like

[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Log in")] performAction:grey_tap().elementByIndex(0)]

(either with grey_accessibilityLabel or grey_text)

Very often in our APP exist situations where multiple elements could be found, need a solution to prevent it.

I know that is better to use Accessibility ID to do not face such problems but current state of the APP is that it doesn't have any IDs.

1 Answers1

-1

I asked a similar question a while back -

EarlGrey - How do I check if multiple objects are being shown on the screen

EarlGrey encourages using unique matchers for finding elements since using elementByIndex() can cause issues if the order isn't always maintained. You could also write a custom matcher that performs the checks you need as is highlighted in the answer.

Community
  • 1
  • 1
gran_profaci
  • 8,087
  • 15
  • 66
  • 99
  • 1
    if you have multiple elements matching but only one of them is visible on screen, you can combine the matcher with grey_sufficientlyVisible() to match just the visible element. – khandpur Mar 04 '16 at 22:35