Detox: toExist() not working correctly on Android

Created on 29 Apr 2020  路  18Comments  路  Source: wix/Detox

Describe the bug

When having a FlatList with a few elements horizontally that have to be scrolled through in order to see each of them, using the toExist() expectation for one of the images/elements invisible in the list doesn't work on Android. The same with attempting to scroll to the element using the whileElement().scroll(), it returns the element not visible exception.

To Reproduce

Steps to reproduce:

  1. Have an app with a FlatList containing several elements horizontally
  2. Put individual IDs on each of them and use the toExist() function on Android for one of the invisible elements
  3. Use the whileElement().scroll() function to attempt to scroll to the last element in the list
  4. Run the same tests on iOS and see them passing

Expected behavior
Tests pass and Detox scrolls on the second second test on Android

Environment:

  • Detox: 16.3.0
  • React Native: 0.62.2
  • Node: 14.0.0
  • Device: iPhone 11
  • Xcode: 11.4.1
  • iOS: 13.4.1
triagbug android 馃搶 pinned

All 18 comments

It makes sense the element doesn鈥檛 exist. Flat list uses virtualization, and views are created on demand. While/scroll is a different matter, and should scroll the list until the view exists/visible.

On iOS it successfully expects all the elements in the list to exist, not Android.

And yes, the issue is the same when using the while/scroll. Perhaps it's expecting it to exist before scrolling?

Maybe virtualization is somehow disabled on iOS.

In that case the issue could be with while/scroll

I can confirm that while / scroll does work as intended on iOS but doesn't on Android as it requires the element to exist

@d4vidi @rotemmiz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@j320 we would very much appreciate it if you try to use Android Studio's layout inspector in order to see whether in the use case you described the element _does_ indeed exist or not,

But while/scroll should work regardless if the element exists or not, it should scroll until the element is found.

@j320 I agree regarding while/scroll, but still trying to understand whether the bug is associated with a free-standing toExist() or not. Regardless of the result, thanks for reporting this!

I confirm that Android Studio layout inspector doesn't display the non-visible elements in the Flat list, while Xcode does for iOS.

Great - so to be concise, there seems to be an issue with while/scroll on Android. I would appreciate a better specification of the problem, however, as in essence, this is a use case that is commonly tested by Detox' own test suite.

We don鈥檛 have FlatList in the Detox suite.

Right, thanks for refreshing my memory - it's just a set of linearly placed items.

I think the problem is as follows:

FlatList doesn鈥檛 create all of its items (potentially 1000s)
Detox is supposed to scroll the list until the item appears
On Android, Detox fails to scroll because it doesn鈥檛 find the element in the hierarchy

The fix should be for Detox to attempt the scroll action even if the item doesn鈥檛 exist.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

Has this been looked at?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

Was this page helpful?
0 / 5 - 0 ratings