"eraseText" cannot clear an edittext
Description
After editing an edittext with wrong data I try to go back to the edittext and remove its content before inputting a new content.
Problem
When selecting the edittext, the cursor is placed at the middle of the EditText and the eraseText instruction only removes what's on the left of the cursor.
Environment
Pixel 3a / Android 12 Maestro 1.17.2
Steps to reproduce
- tapOn:
id: "edittext_signup_email"
- inputText: "invalidemail.fr"
- tapOn:
id: "some_other_view"
- tapOn:
id: "edittext_signup_email"
- eraseText
- inputText: "[email protected]"
In case you cannot reproduce try to use a very long initial input.
Expected result
The EditText should contain "[email protected]"
Observed result
The EditText contains "[email protected]" <-- the end of the previous input remains.
Temporary fix
As a temporary fix, I select the Edittext and eraseText twice before editing it:
- tapOn:
id: "edittext_signup_email"
- eraseText
- tapOn:
id: "edittext_signup_email"
- eraseText
- inputText: "[email protected]"
We have made a lot of improvements and fixes since, can you upgrade to the latest version of Maestro and try again? If you still experience issues, we can re-open this. Thanks again for using Maestro!
@ArthurSav I still experience this issue with version 1.27.0
Environment
Pixel 6a / Android 13 Maestro 1.27.0
Steps to reproduce
- launchApp
- assertVisible:
text: "Sign in"
- tapOn: "Email"
- eraseText
Hi, is there any update on this? I'm still facing this issue on Maestro 1.28.0 Meanwhile, if you have any alternate options to clear the entire text please suggest.
Also running into this on iOS, only on maestro cloud. Please provide some guidance here -- I am trying to onboard our process onto this tool but this makes the cloud product unusable
Can confirm this is still a thing on 1.33.0.
My workaround is to use repeat to at least lower the amount of code (which is really just a slightly more DRY version of @RobinCaroff's original workaround, thank!):
- repeat:
times: 2
commands:
- tapOn: <field that needs to be erased>
- eraseText
Still running into the same problem with Maestro CLI v1.38.1 when executing tests on a physical Android device (OnePlus Nord, Android 12, connected to Windows 11 via USB).
There's some workarounds here.
One is:
- tapOn:
id: myTextField
point: "95%,50%"
- eraseText
This will erase more text than the simple version, by setting the text caret further along the input.
Another is to write a flow that does a longpress on the text field, hits Select All, then eraseText: 1.
Future folks: take a look at #1777 for more info - there's a bunch of good conversation there on other workarounds.