Detox icon indicating copy to clipboard operation
Detox copied to clipboard

waitFor with atIndex and whileElement fails if element is not visible initially

Open Legion2 opened this issue 2 years ago • 28 comments

Describe the bug

We have a scroll list and want to press a specific kind of element in that list. The list contains elements of different kinds, each kind have a unique testID, however multiple elements of a kind can be in the list, so we use atIndex(0) to find the first element of a kind. If the element is not visible initially we scroll down until we find the element. We use the following code:

  await waitFor(element(by.id('some-list-item')).atIndex(0))
      .toBeVisible()
      .whileElement(by.id('list'))
      .scroll(100, 'down', NaN, 0.8);

If the element is visible initially, the test succeeds. However, if the element is not visible, detox scrolls down step by step to the end of the list, but does not find the element, even though it is in the list.

Steps To Reproduce

  • [x] I have tested this issue on the latest Detox release and it still reproduces
  1. Create a list with 20 elements, the first 10 elements have the testID foo, the last elements have the testID bar, the elements must have a height so that only the first 10 elements are visible on the screen
  2. Write a detox test which contains:
  await waitFor(element(by.id('bar')).atIndex(0))
      .toBeVisible()
      .whileElement(by.id('list'))
      .scroll(100, 'down', NaN, 0.8);
  1. execute the test

Expected behavior

detox scrolls to the first bar element and then stops scrolling when it detects that the element is visible.

Detox Trace-Logs

detox[744985] TRACE: [EXEC_SUCCESS, #46] 
detox[744985] TRACE: [WSS_GET_FROM, #app] {"messageId":43,"type":"invokeResult","params":{"result":null}}
detox[744985] TRACE: [WSS_SEND_TO, #tester] {"messageId":43,"type":"invokeResult","params":{"result":null}}
detox[744985] TRACE: [WS_MESSAGE] {"messageId":43,"type":"invokeResult","params":{"result":null}}
 
detox[744985] TRACE: [WS_SEND] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["tab-bar-modal-button-Maßnahmen"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]},"messageId":44}
detox[744985] TRACE: [WSS_GET_FROM, #tester] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["tab-bar-modal-button-Maßnahmen"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]},"messageId":44}
detox[744985] TRACE: [WSS_SEND_TO, #app] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["tab-bar-modal-button-Maßnahmen"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]},"messageId":44}
detox[744985] TRACE: [WSS_GET_FROM, #app] {"messageId":44,"type":"invokeResult","params":{"result":null}}
detox[744985] TRACE: [WSS_SEND_TO, #tester] {"messageId":44,"type":"invokeResult","params":{"result":null}}
detox[744985] TRACE: [WS_MESSAGE] {"messageId":44,"type":"invokeResult","params":{"result":null}}
 
detox[744985] TRACE: [WS_SEND] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"waitForAssertMatcherWithSearchAction","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForAtIndex","args":[{"type":"Integer","value":0},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["some-list-item"]}}]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"scrollInDirectionStaleAtEdge","args":[{"type":"Integer","value":4},{"type":"Double","value":100},{"type":"Double","value":null},{"type":"Double","value":0.8}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["list"]}}]},"messageId":45}
detox[744985] TRACE: [WSS_GET_FROM, #tester] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"waitForAssertMatcherWithSearchAction","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForAtIndex","args":[{"type":"Integer","value":0},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["some-list-item"]}}]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"scrollInDirectionStaleAtEdge","args":[{"type":"Integer","value":4},{"type":"Double","value":100},{"type":"Double","value":null},{"type":"Double","value":0.8}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["list"]}}]},"messageId":45}
detox[744985] TRACE: [WSS_SEND_TO, #app] {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"waitForAssertMatcherWithSearchAction","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForAtIndex","args":[{"type":"Integer","value":0},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["some-list-item"]}}]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"scrollInDirectionStaleAtEdge","args":[{"type":"Integer","value":4},{"type":"Double","value":100},{"type":"Double","value":null},{"type":"Double","value":0.8}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["list"]}}]},"messageId":45}
detox[744985] TRACE: [WSS_GET_FROM, #app] {"messageId":45,"type":"testFailed","params":{"details":"'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.\nExpected: at least 75 percent of the view's area is displayed to the user.\n     Got: null\n"}}
detox[744985] TRACE: [WSS_SEND_TO, #tester] {"messageId":45,"type":"testFailed","params":{"details":"'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.\nExpected: at least 75 percent of the view's area is displayed to the user.\n     Got: null\n"}}
detox[744985] TRACE: [WS_MESSAGE] {"messageId":45,"type":"testFailed","params":{"details":"'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.\nExpected: at least 75 percent of the view's area is displayed to the user.\n     Got: null\n"}}
 
detox[744985] TRACE: [ARTIFACTS_LIFECYCLE] artifactsManager.onTestFnFailure({
  error: Error: Test Failed: 'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.
  Expected: at least 75 percent of the view's area is displayed to the user.
       Got: null

Device logs (adb logcat)

--------- beginning of main
08-08 19:36:30.040 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.040 16731 16803 I DetoxWSClient: Sending out action 'invokeResult' (ID #40)
08-08 19:36:30.040 16731 16803 I DetoxDispatcher: Done with action 'invoke'
08-08 19:36:30.044 16731 16805 D DetoxWSClient: Received action 'invoke' (ID #41, params={"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"waitForAssertMatcher","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["home-screen"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}},{"type":"Double","value":600}]})
08-08 19:36:30.044 16731 16803 I DetoxDispatcher: Handling action 'invoke' (ID #41)...
08-08 19:36:30.045 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [home-screen]
08-08 19:36:30.045 16731 16803 D Detox   : class androidx.test.espresso.Espresso, onView, [(with tag value: is "home-screen" and view has effective visibility=VISIBLE)]
08-08 19:36:30.045 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForSufficientlyVisible, []
08-08 19:36:30.045 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxAssertion, waitForAssertMatcher, [androidx.test.espresso.ViewInteraction@40169e9, at least 75 percent of the view's area is displayed to the user., 600.0]
08-08 19:36:30.046 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.046 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.048 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view (with tag value: is "home-screen" and view has effective visibility=VISIBLE)
08-08 19:36:30.048 16731 16803 I DetoxWSClient: Sending out action 'invokeResult' (ID #41)
08-08 19:36:30.048 16731 16803 I DetoxDispatcher: Done with action 'invoke'
08-08 19:36:30.053 16731 16805 D DetoxWSClient: Received action 'invoke' (ID #42, params={"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"assertMatcher","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["home-screen"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}}]})
08-08 19:36:30.053 16731 16803 I DetoxDispatcher: Handling action 'invoke' (ID #42)...
08-08 19:36:30.053 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [home-screen]
08-08 19:36:30.053 16731 16803 D Detox   : class androidx.test.espresso.Espresso, onView, [(with tag value: is "home-screen" and view has effective visibility=VISIBLE)]
08-08 19:36:30.054 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForSufficientlyVisible, []
08-08 19:36:30.054 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxAssertion, assertMatcher, [androidx.test.espresso.ViewInteraction@615466e, at least 75 percent of the view's area is displayed to the user.]
08-08 19:36:30.055 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.055 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.057 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view (with tag value: is "home-screen" and view has effective visibility=VISIBLE)
08-08 19:36:30.057 16731 16803 I DetoxWSClient: Sending out action 'invokeResult' (ID #42)
08-08 19:36:30.057 16731 16803 I DetoxDispatcher: Done with action 'invoke'
08-08 19:36:30.651 16731 16805 D DetoxWSClient: Received action 'invoke' (ID #43, params={"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["home-tab-bar-pressable-left"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]})
08-08 19:36:30.651 16731 16803 I DetoxDispatcher: Handling action 'invoke' (ID #43)...
08-08 19:36:30.652 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [home-tab-bar-pressable-left]
08-08 19:36:30.652 16731 16803 D Detox   : class androidx.test.espresso.Espresso, onView, [(with tag value: is "home-tab-bar-pressable-left" and view has effective visibility=VISIBLE)]
08-08 19:36:30.652 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxViewActions, click, []
08-08 19:36:30.652 16731 16803 D Detox   : class com.wix.detox.espresso.EspressoDetox, perform, [androidx.test.espresso.ViewInteraction@998b10f, com.wix.detox.espresso.action.RNClickAction@c90259c]
08-08 19:36:30.654 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.655 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.657 16731 16731 I ViewInteraction: Performing 'com.wix.detox.espresso.action.detoxsingletap@77dbba5 click' action on view (with tag value: is "home-tab-bar-pressable-left" and view has effective visibility=VISIBLE)
08-08 19:36:30.690 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.691 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:30.992 16731 16731 I Detox   : AnimatedModule is busy.
08-08 19:36:31.003 16731 16731 I chatty  : uid=10248(com.example) identical 1 line
08-08 19:36:31.020 16731 16731 I Detox   : AnimatedModule is busy.
08-08 19:36:31.040 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.105 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:31.106 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.106 16731 16803 I DetoxWSClient: Sending out action 'invokeResult' (ID #43)
08-08 19:36:31.106 16731 16803 I DetoxDispatcher: Done with action 'invoke'
08-08 19:36:31.112 16731 16805 D DetoxWSClient: Received action 'invoke' (ID #44, params={"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["tab-bar-modal-button"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]})
08-08 19:36:31.112 16731 16803 I DetoxDispatcher: Handling action 'invoke' (ID #44)...
08-08 19:36:31.112 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [tab-bar-modal-button]
08-08 19:36:31.112 16731 16803 D Detox   : class androidx.test.espresso.Espresso, onView, [(with tag value: is "tab-bar-modal-button" and view has effective visibility=VISIBLE)]
08-08 19:36:31.112 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxViewActions, click, []
08-08 19:36:31.113 16731 16803 D Detox   : class com.wix.detox.espresso.EspressoDetox, perform, [androidx.test.espresso.ViewInteraction@95ccd19, com.wix.detox.espresso.action.RNClickAction@d5721de]
08-08 19:36:31.114 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.114 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.115 16731 16731 I ViewInteraction: Performing 'com.wix.detox.espresso.action.detoxsingletap@a1f3fbf click' action on view (with tag value: is "tab-bar-modal-button" and view has effective visibility=VISIBLE)
08-08 19:36:31.146 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.147 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.448 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.513 16731 16731 I chatty  : uid=10248(com.example) identical 4 lines
08-08 19:36:31.514 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.514 16731 16803 I DetoxWSClient: Sending out action 'invokeResult' (ID #44)
08-08 19:36:31.514 16731 16803 I DetoxDispatcher: Done with action 'invoke'
08-08 19:36:31.521 16731 16805 D DetoxWSClient: Received action 'invoke' (ID #45, params={"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAssertion"},"method":"waitForAssertMatcherWithSearchAction","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForAtIndex","args":[{"type":"Integer","value":0},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["some-list-item"]}}]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxAction"},"method":"scrollInDirectionStaleAtEdge","args":[{"type":"Integer","value":4},{"type":"Double","value":100},{"type":"Double","value":null},{"type":"Double","value":0.8}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["list"]}}]})
08-08 19:36:31.521 16731 16803 I DetoxDispatcher: Handling action 'invoke' (ID #45)...
08-08 19:36:31.521 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [some-list-item]
08-08 19:36:31.521 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForAtIndex, [0, (with tag value: is "some-list-item" and view has effective visibility=VISIBLE)]
08-08 19:36:31.522 16731 16803 D Detox   : class androidx.test.espresso.Espresso, onView, [matches 0th view.]
08-08 19:36:31.522 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForSufficientlyVisible, []
08-08 19:36:31.523 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxAction, scrollInDirectionStaleAtEdge, [4, 100.0, NaN, 0.8]
08-08 19:36:31.523 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxMatcher, matcherForTestId, [list]
08-08 19:36:31.523 16731 16803 D Detox   : class com.wix.detox.espresso.DetoxAssertion, waitForAssertMatcherWithSearchAction, [androidx.test.espresso.ViewInteraction@edfb68d, at least 75 percent of the view's area is displayed to the user., com.wix.detox.espresso.scroll.DetoxScrollActionStaleAtEdge@cede042, (with tag value: is "list" and view has effective visibility=VISIBLE)]
08-08 19:36:31.525 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.525 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.527 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:31.529 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.529 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:31.531 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:31.531 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:31.531 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:32.586 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 300 iterations.
08-08 19:36:32.729 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:32.749 16731 16731 I Detox   : UIManagerModule is busy
08-08 19:36:32.753 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:32.855 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:32.856 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:32.875 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:32.877 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:32.877 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:32.878 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:32.878 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:32.878 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:33.870 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 300 iterations.
08-08 19:36:34.076 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:34.078 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:34.181 16731 16731 I chatty  : uid=10248(com.example) identical 4 lines
08-08 19:36:34.181 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:34.197 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:34.199 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:34.199 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:34.199 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:34.199 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:34.706 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 200 iterations.
08-08 19:36:35.397 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:35.417 16731 16731 I Detox   : UIManagerModule is busy
08-08 19:36:35.421 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:35.523 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:35.523 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:35.541 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:35.542 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:35.543 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:35.544 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:35.544 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:35.544 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:35.823 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 100 iterations.
08-08 19:36:36.471 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 300 iterations.
08-08 19:36:36.741 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:36.761 16731 16731 I Detox   : UIManagerModule is busy
08-08 19:36:36.770 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:36.873 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:36.873 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:36.890 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:36.891 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:36.892 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:36.892 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:36.893 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:36.893 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:37.443 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 200 iterations.
08-08 19:36:38.090 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:38.110 16731 16731 I Detox   : UIManagerModule is busy
08-08 19:36:38.120 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:38.222 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:38.222 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:38.230 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:38.231 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:38.232 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:38.232 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:38.232 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:38.232 16731 16731 D DetoxScrollHelper: scroll Point(0, 1731) --> Point(0, 1431)
08-08 19:36:38.819 16731 16731 W UiControllerImpl: Waiting for: MOTION_INJECTION_HAS_COMPLETED for 200 iterations.
08-08 19:36:39.145 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:40.157 16731 16731 I Detox   : AnimatedModule is busy.
08-08 19:36:40.170 16731 16731 I Detox   : AnimatedModule is busy.
08-08 19:36:40.186 16731 16731 E unknown:FabricViewStateManager: setState called without a StateWrapper
08-08 19:36:40.187 16731 16731 I Detox   : AnimatedModule is busy.
08-08 19:36:40.241 16731 16731 I Detox   : UIManagerModule is busy
08-08 19:36:40.259 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.360 16731 16731 I chatty  : uid=10248(com.example) identical 3 lines
08-08 19:36:40.360 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.368 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:40.368 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.369 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.369 16731 16731 I ViewInteraction: Performing 'scrollInDirectionStaleAtEdge' action on view (with tag value: is "list" and view has effective visibility=VISIBLE)
08-08 19:36:40.369 16731 16731 D DetoxScrollHelper: prescroll amountDP=100.0 amountPx=275 scrollableRangePx=1809 times=0 remainder=275
08-08 19:36:40.370 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.371 16731 16731 D IdlingResourceRegistry: All idling resources are idle.
08-08 19:36:40.385 16731 16731 I ViewInteraction: Checking 'MatchesViewAssertion(Detox){viewMatcher=at least 75 percent of the view's area is displayed to the user.}' assertion on view matches 0th view.
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: Test exception
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: java.lang.reflect.InvocationTargetException
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at java.lang.reflect.Method.invoke(Native Method)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:443)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod(MethodUtils.java:405)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.invoke.types.ClassTarget.execute(ClassTarget.java:23)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.invoke.types.Target.invoke(Target.java:59)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:35)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:26)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.invoke.MethodInvocation.invoke(MethodInvocation.java:20)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.InvokeActionHandler.handle(DetoxActionHandlers.kt:56)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.ActionsExecutor$executeAction$$inlined$let$lambda$1.run(DetoxActionsDispatcher.kt:64)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Handler.handleCallback(Handler.java:938)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Handler.dispatchMessage(Handler.java:99)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Looper.loop(Looper.java:223)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.adapters.server.ActionsExecutor$1.run(DetoxActionsDispatcher.kt:50)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at java.lang.Thread.run(Thread.java:923)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: Caused by: androidx.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: Expected: at least 75 percent of the view's area is displayed to the user.
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers:      Got: null
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at dalvik.system.VMStack.getThreadStackTrace(Native Method)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at java.lang.Thread.getStackTrace(Thread.java:1736)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:16)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:36)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:103)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction.check(ViewInteraction.java:31)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.espresso.DetoxAssertion.assertMatcher(DetoxAssertion.java:32)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.espresso.DetoxAssertion.waitForAssertMatcherWithSearchAction(DetoxAssertion.java:84)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	... 15 more
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: Caused by: junit.framework.AssertionFailedError: 'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: Expected: at least 75 percent of the view's area is displayed to the user.
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers:      Got: null
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.matcher.ViewMatchers.assertThat(ViewMatchers.java:17)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.wix.detox.espresso.assertion.ViewAssertions$MatchesViewAssertion.check(ViewAssertions.java:52)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$SingleExecutionViewAssertion.check(ViewInteraction.java:10)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:11)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:2)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Handler.handleCallback(Handler.java:938)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Handler.dispatchMessage(Handler.java:99)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.os.Looper.loop(Looper.java:223)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at android.app.ActivityThread.main(ActivityThread.java:7656)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at java.lang.reflect.Method.invoke(Native Method)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
08-08 19:36:40.389 16731 16803 I DetoxActionHandlers: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
08-08 19:36:40.389 16731 16803 I DetoxWSClient: Sending out action 'testFailed' (ID #45)
08-08 19:36:40.389 16731 16803 I DetoxDispatcher: Done with action 'invoke'

Environment (please complete the following information):

  • Detox: v18.20.1
  • React Native: 0.64.2
  • Node: v14.17.4
  • Device: Emulator Pixel 4a API 30 x64
  • OS: Ubuntu 21
  • Test-runner (select one): jest-circus

Legion2 avatar Aug 08 '21 17:08 Legion2

a workaround is to introduce truely unique id for elements that are repeating, so that would circumvent the need for 'atIndex()'

finalight avatar Aug 09 '21 07:08 finalight

The problem is, the data is loaded from a server I don't control, so I don't know the ID, I only know the type of element.

Legion2 avatar Aug 09 '21 07:08 Legion2

@Legion2 just to be sure: We are talking about an RN scroll list - not a FlatList. Right?

d4vidi avatar Aug 09 '21 09:08 d4vidi

@d4vidi no it's a FlatList

Legion2 avatar Aug 09 '21 09:08 Legion2

actually it is a SectionList

Legion2 avatar Aug 09 '21 09:08 Legion2

Good to know. We test scrolling views regularly on our CI - but not virtualized lists (as SectionList is).

d4vidi avatar Aug 09 '21 13:08 d4vidi

@Legion2 could you please review the recommendations in #2024, which sounds very similar?

d4vidi avatar Aug 09 '21 13:08 d4vidi

There are no recommendations, fixes or workarounds presented in that issue.

ghost avatar Aug 11 '21 08:08 ghost

No recommendations for workarounds - that is true, but for better inspecting the issues (i.e. with the view hierarchy viewer). In any case, we will try to prioritize this.

d4vidi avatar Aug 11 '21 18:08 d4vidi

In any case, this might be a duplicate of #2024.

d4vidi avatar Aug 11 '21 19:08 d4vidi

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.

stale[bot] avatar Sep 10 '21 21:09 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Sep 18 '21 23:09 stale[bot]

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.

stale[bot] avatar Dec 19 '21 14:12 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Dec 26 '21 17:12 stale[bot]

wait, why are we reopening this. did anyone attempt to solve it or what?

finalight avatar Dec 27 '21 09:12 finalight

@finalight it's been closed by the stale bot. We might have a look at it soon.

d4vidi avatar Dec 27 '21 10:12 d4vidi

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.

stale[bot] avatar Jan 26 '22 23:01 stale[bot]

not stale

d4vidi avatar Jan 30 '22 13:01 d4vidi

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.

stale[bot] avatar Mar 06 '22 12:03 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Mar 13 '22 18:03 stale[bot]

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.

stale[bot] avatar Apr 13 '22 07:04 stale[bot]

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.

stale[bot] avatar Jun 18 '22 16:06 stale[bot]

@d4vidi did you get a chance to look at this?

I'm facing a similar issue. The Waitfor command with 'Scroll' at the end just passes by the element if the element is an indexed element.

await waitFor(element(by.text('Shop')).atIndex(0))
      .toBeVisible()
      .whileElement(by.type('android.widget.ScrollView')
      .scroll(500, 'down', NaN, 0.9);

detox just scrolls past the element. But if I remove the index or put a more specific matcher, it stops at th element as intended. one observation is that the code runs on CI fine(a linux machine in circleci) but not on my windows machine.

update: I was able to reproduce it https://github.com/pradeipp/rn-detox-test-myApp/commit/02f0df6df447a05b72cc325682f91fff8e016135

if you run the test with the index on, it just scrolls past the button and says it couldn't find it. But if you remove the index, the 'should scroll down until it finds a button' test passes.

pradeipp avatar Nov 11 '22 07:11 pradeipp

Hi @d4vidi @noomorph any plans on addressing this? I'm having a hard time using workarounds in multiple places inside my app

pradeipp avatar Jan 17 '23 06:01 pradeipp

@pradeipp thanks for reporting that. We are very low on resources ATM, and would very much appreciate contribution. In a nutshell, it's either a problem in the way the Javascript creates the associated visibility matcher, or otherwise somehow related to the native Android code; I would start by debugging the actual handler.

Related: https://wix.github.io/Detox/docs/introduction/debugging#native-application-code

d4vidi avatar Jan 17 '23 16:01 d4vidi

Thanks @d4vidi I'll give it a shot for whatever it's worth. Would appreciate if someone more knowledgeable on this topic took a look too(reaching out to future viewers of this post/comment)

pradeipp avatar Jan 18 '23 06:01 pradeipp

i've faced same issue. it is happening only for android, work on iOS as expected

bemaverick avatar Feb 14 '24 14:02 bemaverick

I had the same problem, and after checking the documentation of the method toBeVisible, I realized that it only passes if the element is at least 75% visible.

In my case, I'm testing a very long list that doesn't fit the viewport area, so it never gets even close to 75% visible.

We can change the amount of visibility we expect by passing an argument to the method. For example, if you want the assertion to pass when at least 5% of the element is visible, you can call toBeVisible(5).

This fixed the issue for me, but I'm considering changing the test to check the visibility of the first item instead of the whole list.

nicolasiensen-tonies avatar Feb 15 '24 10:02 nicolasiensen-tonies