Skip to content
New issue

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

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

Already on GitHub? # to your account

atIndex() seems to be broken on Android #498

Closed
jukben opened this issue Jan 8, 2018 · 4 comments
Closed

atIndex() seems to be broken on Android #498

jukben opened this issue Jan 8, 2018 · 4 comments

Comments

@jukben
Copy link

jukben commented Jan 8, 2018

Description

atIndex() don't work as intended on Android.

Steps to Reproduce

it('should have at least 1 small story tile', async () => {
    await expect(
      element(by.id('latest:small-story-tile')).atIndex(0)
    ).toExist();
  });

This piece of code throws an error on Android, on iOS everything is OK. It seems to me that atIndex is ignored.

Error: 'matches 0th view.' matches multiple views in the hierarchy.

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 6.0.4
  • Node: v9.3.0
  • Device: Nexus 5 API 25 Android 7.1.1 x86
  • Xcode: 9.2
  • macOS: 10.13.2

Device and verbose Detox logs

detox build -c android.emu.release && detox test -c android.emu.release 2> stderr

Could be similar to #337 (or it might be a duplicate but this is NOT alert related as far I know.)

Anyway, thanks for this library! 💪 You did a great job. I'd love to hear some feedback from you, maybe I didn't understand the atIndex method properly.

@rotemmiz
Copy link
Member

rotemmiz commented Jan 8, 2018

iOS and Android native view hierarchies may not always be similar to each other, in fact, they are mostly different. Using atIndex is more like an opportunistic approach of finding a view rather than something deterministic, the index of a view may change on different devices, different OS versions, or different RN versions.
It is really advised to just create better testIDs, it can even be done in list views.

BTW, iOS and Android actually have opposite order to their indexes... take a look at our matchers e2e test suite.
https://github.com/wix/detox/blob/master/detox/test/e2e/b-matchers.js#L17

@simonracz
Copy link
Contributor

All that @rotemmiz said is true, but on top of that I just noticed we have a bug with atIndex, if the parameter is 0. Silly mistake by me.
here

@simonracz
Copy link
Contributor

@jukben I made a PR to fix the atIndex(0) issue. Please try it again after a new release.

@jukben
Copy link
Author

jukben commented Jan 9, 2018

Thanks for your responses! I will do. 🙏

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

No branches or pull requests

5 participants