Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Find by label not working on React Native v0.60 #1539

Closed
1 task done
elyalvarado opened this issue Jul 17, 2019 · 2 comments
Closed
1 task done

Find by label not working on React Native v0.60 #1539

elyalvarado opened this issue Jul 17, 2019 · 2 comments

Comments

@elyalvarado
Copy link
Contributor

Describe the bug
Finding any element by their accessibilityLabel using the by.label matcher is not working on Android when using React Native version .060.3

To Reproduce

  • I have tested this issue on the latest Detox release and it still reproduces

Provide the steps necessary to reproduce the issue. If you are seeing a regression, try to provide the last known version where the issue did not reproduce.

  1. Any test that passes with a by.label matcher on iOS fails on Android.

Demo project reproducing the issue

Expected behavior
Tests should work as in iOS and previous versions.

Environment (please complete the following information):

  • Detox: 13.1.1
  • React Native: 0.60.3
  • Node: 10.16.0
  • Device: Android Emulator Nexus_5X_API_28
  • OS: Android 9

Device and Verbose Detox Logs
Provide the device and "trace" Detox logs so we can understand what happened. You can obtain them by passing the loglevel param: detox test --loglevel trace

Example: should find a view by accesibility label [FAIL]
Example: should find a button by accesibility label
detox[23640] TRACE: [Detox.js/DETOX_AFTER_EACH] failed test: "Example should find a view by accesibility label"
detox[23640] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterEach({ title: 'should find a view by accesibility label',
  fullName: 'Example should find a view by accesibility label',
  status: 'failed',
  timedOut: false })
detox[23640] TRACE: [Detox.js/DETOX_BEFORE_EACH] running test: "Example should find a button by accesibility label"
detox[23640] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeEach({ title: 'should find a button by accesibility label',
  fullName: 'Example should find a button by accesibility label',
  status: 'running' })
detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"reactNativeReload","params":{},"messageId":-1000}
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=tester action=reactNativeReload (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=testee action=ready (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"messageId":-1000,"type":"ready","params":{}}

detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","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":"matcherForContentDescription","args":["See your changes button"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForSufficientlyVisible","args":[]}}]},"messageId":4}
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=testee action=error (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"messageId":4,"type":"error","params":{"error":"'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"}}

Example: should find a button by accesibility label [FAIL]

detox[23640] TRACE: [Detox.js/DETOX_AFTER_EACH] failed test: "Example should find a button by accesibility label"
detox[23640] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterEach({ title: 'should find a button by accesibility label',
  fullName: 'Example should find a button by accesibility label',
  status: 'failed',
  timedOut: false })
detox[23640] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterAll()
detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"cleanup","params":{"stopRunner":false},"messageId":-49642}
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=tester action=cleanup (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [DetoxServer.js/MESSAGE] role=testee action=cleanupDone (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"messageId":-49642,"type":"cleanupDone","params":{}}

detox[23640] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 23701]: /usr/local/share/android-sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63683 -e detoxSessionId e83bc21c-1c07-cdef-1188-896c97b6b5f7 -e debug ZmFsc2U= com.detox603.test/androidx.test.runner.AndroidJUnitRunner
detox[23640] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7
detox[23640] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 23701]: /usr/local/share/android-sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63683 -e detoxSessionId e83bc21c-1c07-cdef-1188-896c97b6b5f7 -e debug ZmFsc2U= com.detox603.test/androidx.test.runner.AndroidJUnitRunner
detox[23640] TRACE: [exec.js/SPAWN_END, #15] /usr/local/share/android-sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63683 -e detoxSessionId e83bc21c-1c07-cdef-1188-896c97b6b5f7 -e debug ZmFsc2U= com.detox603.test/androidx.test.runner.AndroidJUnitRunner terminated with SIGINT
detox[23640] DEBUG: [DetoxServer.js/DISCONNECT] role=testee, sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7
detox[23640] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=tester not connected, cannot fw action (sessionId=e83bc21c-1c07-cdef-1188-896c97b6b5f7)
detox[23640] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
 FAIL  e2e/firstTest.spec.js (22.747s)
  Example
    ✓ should have welcome screen (1273ms)
    ✓ should find an element by testID (1141ms)
    ✕ should find a view by accesibility label (1190ms)
    ✕ should find a button by accesibility label (1174ms)

  ● Example › should find a view by accesibility label

    '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

      13 |
      14 |   it('should find a view by accesibility label', async () => {
    > 15 |     await expect(element(by.label('Edit App.js Container'))).toBeVisible();
         |                                                              ^
      16 |   });
      17 |
      18 |   it('should find a button by accesibility label', async () => {

      at Client.execute (../node_modules/detox/src/client/Client.js:92:28)
      at InvocationManager.execute (../node_modules/detox/src/invoke.js:11:33)
      at MatcherAssertionInteraction.execute (../node_modules/detox/src/android/expect.js:128:35)
      at ExpectElement.toBeVisible (../node_modules/detox/src/android/expect.js:275:112)
      at toBeVisible (firstTest.spec.js:15:62)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)

  ● Example › should find a button by accesibility label

    '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

      17 |
      18 |   it('should find a button by accesibility label', async () => {
    > 19 |     await expect(element(by.label('See your changes button'))).toBeVisible();
         |                                                                ^
      20 |   });
      21 | });
      22 |

      at Client.execute (../node_modules/detox/src/client/Client.js:92:28)
      at InvocationManager.execute (../node_modules/detox/src/invoke.js:11:33)
      at MatcherAssertionInteraction.execute (../node_modules/detox/src/android/expect.js:128:35)
      at ExpectElement.toBeVisible (../node_modules/detox/src/android/expect.js:275:112)
      at toBeVisible (firstTest.spec.js:19:64)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)

detox[23639] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' "e2e"
@abury
Copy link

abury commented Aug 13, 2019

We're seeing this behavior on RN 0.59.5 as well

@elyalvarado
Copy link
Contributor Author

I'm going to close this as it was a React Native issue and not a Detox one. This issue was introduced in RN 0.60.0 with the following commit:

And was fixed in RN 0.60.5 which includes the following PR: #25963

Anyone having one of the affected versions (0.60.0-0.60.4) can as a work-around conditionally add a comma at the end of the label to match if the platform is Android.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants