wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.15k stars 1.92k forks source link

Detox incorrectly interacts with elements #834

Closed LeoNatan closed 5 years ago

LeoNatan commented 6 years ago

This is an issue we found internally when testing wix/react-native-navigation.

When an overlay window is present, and it should swallow touches (returns a non-nil value from hitTest:withEvent:), elements on the main window still get tapped successfully (and incorrectly).

This stems from an Earl Grey issue (https://github.com/google/EarlGrey/issues/735):

There seems to be an issue, where isVisibleForInteraction: returns YES despite there being a UIWindow instance that should take the touch of the user, rather than it reaching the element.

In addition to its current logic, the method should check first if there are other windows visible and answering hitTest:withEvent: with a non-nil value; if so, it should fail the interaction visibility check.

LeoNatan commented 6 years ago

CC @yogevbd

cbrevik commented 5 years ago

Wonder if this might be the same issue we encounter in our app using react-navigation (v2.17.0)?

When we navigate from view A to view B, then B is rendered over A. The problem is that both A & B contains components which have the same testID. Detox then complains with Failed: Error: Multiple UI elements matched for the given criteria., even though view A is strictly not visible.

LeoNatan commented 5 years ago

@cbrevik This issue is unrelated. Here two native windows are incorrectly interacted with by Earl Grey.

Regarding your issue, there is nothing we can do about this. The framework you are using makes a mess. It is so wasteful to have all these views loaded. Please move to a better framework, such as react-native-navigation.

cbrevik commented 5 years ago

Thanks for the answer @LeoNatan.

Agreed, react-navigation can be a bit of a mess at times.

But sadly in this project, react-native-navigation did not fit well with our UX/design requirements. So a JS-based navigation lib sort of couldn't be avoided. I have used react-native-navigation in other apps though, and quite like it.

LeoNatan commented 5 years ago

I heard there are improvements in react-navigation that remove old views from the screen. Try using those improvements.

LeoNatan commented 5 years ago

It is now possible to specify a start position for X and Y, which should alleviate this problem.

https://github.com/wix/Detox/blob/master/docs/APIRef.ActionsOnElement.md#scrollpixels-direction-startpositionxnan-startpositionynan