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

Textfield not working #4437

Closed
2 tasks done
alexandravychytill opened this issue Apr 2, 2024 · 16 comments · Fixed by #4442 or #4444
Closed
2 tasks done

Textfield not working #4437

alexandravychytill opened this issue Apr 2, 2024 · 16 comments · Fixed by #4442 or #4444

Comments

@alexandravychytill
Copy link

alexandravychytill commented Apr 2, 2024

What happened?

With new release (20.19.5) type text for web textfield not working on iOS. It has no error, but there gets no text inserted.

What was the expected behaviour?

await web.element(by.web.id(elementId)).typeText(text) should actually insert the text

Was it tested on latest Detox?

  • 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.19.5
React Native version: 0.72.0
Has Fabric (React Native's new rendering system) enabled: yes
Node version: >=16
Device model: iPhone 15
iOS version: 17.2
macOS version: 14.4
Xcode version: 15.2
Test-runner (select one): jest

Detox logs

Detox logs
paste logs here!

Device logs

Device logs
paste your device.log here!

More data, please!

No response

@gosha212
Copy link
Contributor

gosha212 commented Apr 2, 2024

@asafkorem

@asafkorem
Copy link
Contributor

asafkorem commented Apr 2, 2024

@alexandravychytill

Detox version: 20.19.4

Are you using 20.19.4 or 20.19.5?
If it's the first, please try to upgrade to 20.19.5 since we made a related fix on this version.

If it still happens after the version upgrade, can you please provide a snippet of the text field that you're trying to tap into so we'll be able to reproduce and investigate that?

@asafkorem
Copy link
Contributor

asafkorem commented Apr 2, 2024

Oh, you're the reporter of this issue #4426.

JS exception: The input element's type ('email') does not support selection

We made a test that (allegedly?) reproduces your issue and it passes with the fix from the patch version 🙁
I'll need a code snippet or something I can work with

@alexandravychytill
Copy link
Author

So I just updated to new version and the logs say "passed " but actually there is no insert of any text.

Textfield:
<input aria-invalid="false" id="P0-0" type="email" class="MuiInputBase-input MuiInput-input css-mnn31">

@asafkorem
Copy link
Contributor

asafkorem commented Apr 2, 2024

Thanks, I see you're using MUI, I'll check if it might be related. What happens if you change the type attribute to text instead of email? Could you please try that just for the investigation (in case you have access for the page's code)?

@alexandravychytill
Copy link
Author

Hello
So unfortunately I do not have access to the page code.

@asafkorem
Copy link
Contributor

asafkorem commented Apr 2, 2024

I'll investigate this. I'll keep you updated, thanks for the report!

@alexandravychytill
Copy link
Author

Thanks,
Do you have perhaps already some updates?

@asafkorem
Copy link
Contributor

@alexandravychytill, I was unable to reproduce your issue, as the previous workaround we implemented seemed effective (and underwent testing). Consequently, I opted to bypass the workaround and avoid text selection on input elements that initially don't support setSelectionRange. I believe this approach will resolve your issue: #4442

@asafkorem
Copy link
Contributor

@alexandravychytill please try the latest version https://github.com/wix/Detox/releases/tag/20.20.1

@alexandravychytill
Copy link
Author

Hello
So still it is not working for me with newest Version(20.20.1). Can you perhaps provide me a Website with a working input textfield (that is working for you)? Because for me still it is not filling in any text when executing test. And also to add, I am using Simulator Tool Version 15.2 , iPhone 15 with Version 17.2.

@asafkorem
Copy link
Contributor

@asafkorem
Copy link
Contributor

asafkorem commented Apr 10, 2024

Let's try another thing. On the inner-element you're trying to interact with, let's run a custom JS action that changes its value:

const inputElement = web.element(by...);

await inputElement.runScript(function get(element) {
  element.value = "desired text to type";
});

@asafkorem
Copy link
Contributor

asafkorem commented Apr 10, 2024

Oh, I think I figured the issue. I believe it doesn't work because the element's value is controlled by React state. If the code snippet I provided in the previous comment doesn't work, please try the following:

await inputElement.runScript(function get(element) {
  element.value = "desired text to type";

   // Dispatch an 'input' event to ensure React's internal state is updated
   const event = new Event('input', { bubbles: true });
   element.dispatchEvent(event);
});

If it still doesn't work, can you please provide me with the link to the web-page you're trying to interact with? I'll try to debug our mechanism against this page.

@alexandravychytill
Copy link
Author

Great this worked now. I just found another bug for iOS, will create a new Bug Issue for that :)

@asafkorem
Copy link
Contributor

@alexandravychytill the fix has released with 20.20.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment