maestro icon indicating copy to clipboard operation
maestro copied to clipboard

"eraseText" cannot clear an edittext

Open RobinCaroff opened this issue 3 years ago • 6 comments

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]"

RobinCaroff avatar Dec 13 '22 14:12 RobinCaroff

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 avatar May 03 '23 14:05 ArthurSav

@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

phuchuynhStrong avatar May 09 '23 03:05 phuchuynhStrong

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.

aakashfmk avatar Jun 11 '23 14:06 aakashfmk

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

ferdy-roz avatar Aug 03 '23 16:08 ferdy-roz

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

TheLastProject avatar Sep 28 '23 17:09 TheLastProject

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).

hormesiel avatar Oct 23 '24 06:10 hormesiel

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.

Fishbowler avatar Feb 08 '25 17:02 Fishbowler

Future folks: take a look at #1777 for more info - there's a bunch of good conversation there on other workarounds.

Fishbowler avatar Mar 26 '25 10:03 Fishbowler