Detox icon indicating copy to clipboard operation
Detox copied to clipboard

[Android] Detox fails to type text in invisible input

Open eilinwis opened this issue 1 year ago • 3 comments

What happened?

Hello! I'm testing a screen with hidden input Works fine on iOS but fails on android

await element(by.id(input)).typeText(text)

and i get this error: Test Failed: Action will not be performed because the target view does not match one or more of the following constraints: ((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area) and (((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)) and (view.onCreateInputConnection() is not null or is assignable from class <class android.widget.SearchView>)))

this is what .getAttributes() shows: { identifier: 'input', visibility: 'visible', visible: false, label: '', alpha: 1, elevation: 0, height: 133, width: 1000, focused: true, enabled: true, text: '', length: 0, textSize: 39, placeholder: '' }

What was the expected behaviour?

Text will be typed into input form

Was it tested on latest Detox?

  • [X] I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: 20.9.1 React Native version: 0.71.6 Has Fabric (React Native's new rendering system) enabled: no Node version: 16.0.0 Device model: Android emulator API 31 AOSP Android version: 12 Test-runner (select one): jest

Detox logs

Detox logs
14:22:58.950 detox[66416] i user Typing '0.1 into field with ID input'
  origin: at e2e/steps/general.js:124:13
14:22:58.953 detox[66416] i ws-client send message
  data: {"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":["input"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"typeText","args":["0.1"]}}]},"messageId":26}

 RUNS  e2e/tests/logged_in_user/send.spec.js
14:22:58.953 detox[66415] i ws-server@58493 get
  data: {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.
14:22:58.953 detox[66416] B ws-client type input text: "0.1"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["input"]}}]}},{"typ
  data: {
    "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": [
                  "input"
                ]
              }
            }
          ]
        }
      },
      {
        "type": "Invocation",
        "value": {
          "target": {
            "type": "Class",
            "value": "com.wix.detox.espresso.DetoxViewActions"
          },
          "method": "typeText",
          "args": [
            "0.1"
          ]
        }
      }
    ]
  }
  stack: typeText (/e2e/steps/general.js:65:33)
  Generator.next (<anonymous>)
  asyncGeneratorStep (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
  _next (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
  /node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
  new Promise (<anonymous>)
  /node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12
  apply (/e2e/steps/general.js:63:28)
  /e2e/screens/send_summary.js:31:30
  Generator.next (<anonymous>)
  asyncGeneratorStep (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
  _next (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
  /node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
  new Promise (<anonymous>)
  /node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12
  apply (/e2e/screens/send_summary.js:30:19)
  Object.<anonymous> (/e2e/tests/logged_in_user/send.spec.js:191:25)
  Generator.next (<anonymous>)
  asyncGeneratorStep (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
  _next (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
  processTicksAndRejections (node:internal/process/task_queues:96:5)
14:22:58.954 detox[66415] i ws-server@58656 send
  data: {
    "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": [
                    "input"
                  ]
                }
              }
            ]
          }
        },
        {
          "type": "Invocation",
          "value": {
            "target": {
              "type": "Class",
              "value": "com.wix.detox.espresso.DetoxViewActions"
            },
            "method": "typeText",
            "args": [
              "0.1"
            ]
          }
        }
      ]
    },
    "messageId": 26
  }

 RUNS  e2e/tests/logged_in_user/send.spec.js
14:22:58.965 detox[66415] i ws-server@58656 get
  data: {"messageId":26,"type":"testFailed","params":{"details":"Action will not be performed because the target view does not match one or more of the following constraints:\n((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area) and (((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)) and (view.onCreateInputConnection() is not null or is assignable from class <class android.widget.SearchView>)))\nTarget view: \"ReactEditText{id=6479, visibility=VISIBLE, width=1000, height=133, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@71528, tag=input, root-is-layout-requested=false, has-input-connection=true, editor-info=[inputType=0x4002 imeOptions=0x6 privateImeOptions=null actionLabel=null actionId=0 initialSelStart=0 initialSelEnd=0 initialCapsMode=0x2000 hintText= label=null packageName=null autofillId=null fieldId=0 fieldName=null extras=null hintLocales=null contentMimeTypes=null ], x=0.0, y=-274997.0, text=, hint=, input-type=16386, ime-target=true, has-links=false}\""}}
14:22:58.966 detox[66415] i ws-server@58493 send
  data: {
    "messageId": 26,
    "type": "testFailed",
    "params": {
      "details": "Action will not be performed because the target view does not match one or more of the following constraints:\n((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area) and (((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)) and (view.onCreateInputConnection() is not null or is assignable from class <class android.widget.SearchView>)))\nTarget view: \"ReactEditText{id=6479, visibility=VISIBLE, width=1000, height=133, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@71528, tag=input, root-is-layout-requested=false, has-input-connection=true, editor-info=[inputType=0x4002 imeOptions=0x6 privateImeOptions=null actionLabel=null actionId=0 initialSelStart=0 initialSelEnd=0 initialCapsMode=0x2000 hintText= label=null packageName=null autofillId=null fieldId=0 fieldName=null extras=null hintLocales=null contentMimeTypes=null ], x=0.0, y=-274997.0, text=, hint=, input-type=16386, ime-target=true, has-links=false}\""
14:22:58.968 detox[66416] i ws-client get message
  data: {"messageId":26,"type":"testFailed","params":{"details":"Action will not be performed because the target view does not match one or more of the following constraints:\n((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area) and (((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)) and (view.onCreateInputConnection() is not null or is assignable from class <class android.widget.SearchView>)))\nTarget view: \"ReactEditText{id=6479, visibility=VISIBLE, width=1000, height=133, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@71528, tag=input, root-is-layout-requested=false, has-input-connection=true, editor-info=[inputType=0x4002 imeOptions=0x6 privateImeOptions=null actionLabel=null actionId=0 initialSelStart=0 initialSelEnd=0 initialCapsMode=0x2000 hintText= label=null packageName=null autofillId=null fieldId=0 fieldName=null extras=null hintLocales=null contentMimeTypes=null ], x=0.0, y=-274997.0, text=, hint=, input-type=16386, ime-target=true, has-links=false}\""}}
   
14:22:58.968 detox[66416] E ws-client type input text: "0.1"
  error: Test Failed: Action will not be performed because the target view does not match one or more of the following constraints:
  ((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area) and (((view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)) and (view.onCreateInputConnection() is not null or is assignable from class <class android.widget.SearchView>)))
  Target view: "ReactEditText{id=6479, visibility=VISIBLE, width=1000, height=133, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@71528, tag=input, root-is-layout-requested=false, has-input-connection=true, editor-info=[inputType=0x4002 imeOptions=0x6 privateImeOptions=null actionLabel=null actionId=0 initialSelStart=0 initialSelEnd=0 initialCapsMode=0x2000 hintText= label=null packageName=null autofillId=null fieldId=0 fieldName=null extras=null hintLocales=null contentMimeTypes=null ], x=0.0, y=-274997.0, text=, hint=, input-type=16386, ime-target=true, has-links=false}"
14:22:58.969 detox[66416] B artifacts-manager onTestFnFailure

Device logs

device.log

More data, please!

Assumption - may be it happens cause there is a tap before the input itself? And detox cannot tap on invisible elements I ViewInteraction: Performing 'Click to focus & type text (0.1)' action on view (view.getTag() is "input" and view has effective visibility <VISIBLE>)

eilinwis avatar Jun 16 '23 13:06 eilinwis

I have the same issue I hope there will be a fix soon.

IvayloMetodiev avatar Jul 19 '23 11:07 IvayloMetodiev

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 repository, read this discussion.

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

I have this problem too. And so does this guy https://github.com/wix/Detox/issues/1556.

I'm currently blocked trying to log in to our app due to needing to type into a hidden input.

image

tamlyn avatar Nov 20 '23 16:11 tamlyn