mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.43k stars 250 forks source link

inputText is typing too fast and skipping characters when app stutters/jank #395

Open edgarlealbd opened 1 year ago

edgarlealbd commented 1 year ago

When running with Android emulator and calling inputText, it appears that the app suffers some stutter or jank and the command misses some characters. For example:

When executing inputText to type Lorem ipsum, sometimes it'll actually type Loemipsu. The skipped characters are random, so it does not appear to be a keyboard auto-correction. Sometimes, the same test will type characters correctly and tests will succeed.

I've tested that on debug builds, which are not optimized and the app can suffer from stutters or jank, and the problem is more frequent, but the same also works with an optimized release build.

My (hopefully) temporary workaround for this is to have one command per character, like this:

- inputText: "l"
- inputText: "o"
- inputText: "r"
- inputText: "e"
- inputText: "m"

Is there any way to set typing or command speed? If not, this could be a possible implementation for cases like this. E2E should have some breathing space when typing to avoid errors like this.

pwicherski commented 1 year ago

@edgarlealbd is your problem maybe happening inside an Android webview, like some webform or login screen inside the app?

Is it a clear native app, or some sort of prebuilt via React Native?

edgarlealbd commented 1 year ago

@pwicherski the typing in question is not happening inside a WebView. The app is built with Flutter.

edgarlealbd commented 1 year ago

Update: I can't reproduce the error locally with an Android 10 emulator, only with an Android 12 (API 31).

Leland-Takamine commented 1 year ago

We've opened up a fix for this. The fix should be included in the next release of Maestro once this is landed #417

amanjeetsingh150 commented 1 year ago

Hey @edgarlealbd @pwicherski

I have just merged the fix can you upgrade the local maestro to head and try these commands to check if this is fixed. Would recommend to do it multiple times as this was inconsistent. To upgrade:

 brew uninstall maestro
 brew install maestro-head --HEAD

Let me know if this works will release this in the new version

To go back on stable after checking

 brew uninstall maestro-head
 brew install maestro
edgarlealbd commented 1 year ago

@amanjeetsingh150 I'm getting java-related errors when running with the head version from homebrew:

I have a Mac Pro M1 Max.

Exception in thread "main" java.lang.UnsupportedClassVersionError: maestro_android/MaestroDriverGrpc has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at maestro.drivers.AndroidDriver.<init>(AndroidDriver.kt:65)
    at maestro.Maestro$Companion.android(Maestro.kt:402)
    at maestro.Maestro$Companion.android$default(Maestro.kt:401)
    at maestro.cli.util.MaestroFactory.createMaestro(MaestroFactory.kt:40)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:74)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:36)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
    at picocli.CommandLine.access$1200(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
    at picocli.CommandLine.execute(CommandLine.java:2058)
    at maestro.cli.AppKt.main(App.kt:109)
amanjeetsingh150 commented 1 year ago

Hey @edgarlealbd , have created fix for this can you try with latest head again by:

brew uninstall maestro-head 
brew install maestro-head --HEAD

Let me know if this seems consistent now.

amanjeetsingh150 commented 1 year ago

Hey @edgarlealbd can you confirm that the latest version works fine for you?

edgarfroes commented 1 year ago

@amanjeetsingh150 I thought that I already commented this out. It's is working fine now.

amanjeetsingh150 commented 1 year ago

Awesome @edgarfroes thanks 🙌

janyk commented 1 year ago

Hey @amanjeetsingh150 - this, or similar is still happening - installed Maestro today - using RN, pretty small app right now

Video below - let me know if you need anymore details?

https://user-images.githubusercontent.com/13877025/215972194-a7ba6890-ea3a-4944-8341-ccec9fea8ff4.mp4

amanjeetsingh150 commented 1 year ago

Hey, @janyk @artem888 is working on a fix here. Should be fixed by this: https://github.com/mobile-dev-inc/maestro/pull/720. Can you open a separate issue though for this it will be easy to follow up.

robotlovesyou commented 1 year ago

@amanjeetsingh150 FYI, this is still happening on iOS. I have the latest Maestro CLI installed. The app is react native, running in debug mode (so, quite slow)

sregg commented 1 year ago

I'm seeing the same issue with v1.26.0 - inputText: 'simon@cookin.com' inputs son@cooking.com

ezgif-5-31067a889d

retyui commented 1 year ago

Workaround:

Create sub-flow myInput.yaml:

appId: com.myapp
env:
  TEXT: ${TEXT}
  ATTEMPTS_LIMIT: ${ATTEMPTS_LIMIT || 5}
---
- evalScript: ${output.status = 'unknown'}
- evalScript: ${output.attempt = 1}
- repeat:
    while:
      true: ${output.status === 'unknown'}
    commands:
      - inputText: "${TEXT}" # Fill text field

      - runFlow:
          when:
            visible: "${TEXT}" # check if entered text is correct
          commands:
            - evalScript: ${output.status = 'success'}

      - runFlow:
          when:
            true: ${output.status != 'success'}
          commands:
            - eraseText # Clear text field

      - evalScript: ${output.attempt = output.attempt + 1}
      - runFlow:
          when:
            true: ${output.attempt >= ATTEMPTS_LIMIT}
          commands:
            - evalScript: ${output.status = 'timeout'}

And then use that sub-flow instead of inputText:

- runFlow:
    file: myInput.yaml
    env:
      TEXT: "My text"
      ATTEMPTS_LIMIT: 3 # optional (by default 5)
lossen commented 1 year ago

I'm facing the same issue in version 1.26.1 And I have this behaviour not only for - inputText: command, but for - 'inputRandomEmail' command too.

instead of ailnuta@gmail.com I got ailnut@ail.comagm Upgraded to 1.27.0 - issue still here

el-ethan commented 1 year ago

I am seeing a slightly different, but potentially related issue. I have the following flow:

appId: my-app
---

- tapOn: "Username"
- inputText: "Ethan"
- tapOn: "Password"
- inputText: "blklbl"
- tapOn: "Sign In"
- assertVisible: .*Current Duty Status.*

What I am seeing is that the flow usually works without issue. However, every so often (on ~20% of runs or somewhere in that ballpark) an extra "y" will be added at the end of the password, causing the test to fail (since it becomes the wrong password with a "y" at the end). It is always a "y" character for some reason. I can open a separate issue if that makes sense, but thought it might be related to this existing issue.

axelniklasson commented 1 year ago

@lossen @el-ethan does this happen on Android or on iOS? If this is an issue on iOS, please file a new bug report with as much details as possible and we'll take it from there to reduce noise in this issue.

retyui commented 1 year ago

for me is only happens on iOS

sregg commented 1 year ago

Typing a couple of characters at a time seems to work well:

- tapOn: 'Email address'
- inputText: 'si'
- inputText: 'mon'
- inputText: '+'
- inputText: 'em'
- inputText: 'ail'
- inputText: '@'
- inputText: 'coo'
- inputText: 'kin'
- inputText: '.com'

instead of

- tapOn: 'Email address'
- inputText: 'simon+email@cookin.com'

Looking forward to seeing this PR merged though 🤞

sregg commented 11 months ago

Any news on this? It's still happening with version 1.30.4

ferdy-roz commented 11 months ago

+1

artem888 commented 11 months ago

hey folks! we applied one more fix, which hopefully should fix majority of the issues with inputText. it's going to be released in the next maestro cli version

ferdy-roz commented 11 months ago

sweet! that's exciting, thanks for working on this issue. is there a planned release date for that version?

artem888 commented 11 months ago

sweet! that's exciting, thanks for working on this issue. is there a planned release date for that version?

we're planning to release it early next week

ferdy-roz commented 11 months ago

sounds good. by any chance is this fix to inputText going to also touch eraseText? That one seems to be pretty buggy in maestro cloud as well, but maybe it's a related issue.

artem888 commented 11 months ago

@ferdy-roz not really, since eraseText is a separate command. but might be flaky for similar reasons, going to check that

ferdy-roz commented 11 months ago

Looks like inputText might be fixed, but yes eraseText still has issue in Maestro Cloud

artem888 commented 11 months ago

@ferdy-roz that's good to hear, I'll try to fix eraseText in the next version. can you please provide me with uploadId or appId for the failing maestro cloud upload?

ferdy-roz commented 11 months ago

@artem888 where do I find that in the cloud console?

artem888 commented 11 months ago

@ferdy-roz should be a part of the console link, i.e.

Screenshot 2023-08-16 at 14 18 49
axelniklasson commented 11 months ago

@ferdy-roz You can also simply provide a link to an Upload details page in your Cloud console where this error happens if that is easier 🙂

ferdy-roz commented 11 months ago

@artem888 got one today: efaf4b2b-73f0-43df-ba49-0b1e8d39beca&analysisId=bcc544be-addf-4943-ba36-6d7ce7fb1427

or console link

Ademsk1 commented 11 months ago

Are there certain API levels that this could not work in? I haven't had any issues prior, working on API 33, but now I've gone down to API 29 I'm noticing it consistently, on fresh boots of the device. I am using a webview btw, if that is an issue

Maestro version: 1.31 Phone: Pixel 5 API level: 29

If you need any more info just let me know

AttieG commented 9 months ago

I'm getting the same issue on a webview. When using inputText some characters are not typed. I am running the Webview inside of a Flutter app. Maestro: 1.33.1 Android 11 Pixel 3a Virtual device

This is quite painful as I do not wish to split up the password and username that comes from environment variables into multiple inputText commands.

GunnarAK commented 9 months ago

I'm also confronted with the issue in a React Native app. It happens around 40% of the test runs, but it always occurs around the + symbol. See screenshot.

image

It's either the above, or the first e that gets placed at the end of the email, resulting in someEmail+2e@domain.come.

This raises concern in if the password that gets typed in is also correct, since that contains much more special characters too.

Current fix is to split the input over two or more lines. In my case:

- inputText: someEmail
- inputText: +e2e@domain.com
Environment Details

System: OS: macOS 13.5.1 CPU: (12) arm64 Apple M2 Pro Memory: 495.14 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.17.1 path: /var/folders/xf/zkm337511h90gglzjm93phk80000gn/T/yarn--1698054147244-0.21111488938809386/node Yarn: version: 1.22.19 path: /var/folders/xf/zkm337511h90gglzjm93phk80000gn/T/yarn--1698054147244-0.21111488938809386/yarn npm: version: 9.6.7 path: ~/.nvm/versions/node/v18.17.1/bin/npm Watchman: version: 2023.09.25.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.13.0 path: /Users/gunnark/.rvm/gems/ruby-3.2.1/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.0 - iOS 17.0 - macOS 14.0 - tvOS 17.0 - watchOS 10.0 Android SDK: Not Found IDEs: Android Studio: 2022.3 AI-223.8836.35.2231.10671973 Xcode: version: 15.0/15A240d path: /usr/bin/xcodebuild Languages: Java: version: 11.0.20 path: /usr/bin/javac Ruby: version: 3.2.1 path: /Users/gunnark/.rvm/rubies/ruby-3.2.1/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.4 wanted: 0.72.4 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false

tiagodread commented 7 months ago

+1

We're also facing this issue on Android/flutter based app. Sometimes the inputText miss some chars and the flow fails.

Maestro v1.34.1 Platform: Android / Flutter

axelniklasson commented 7 months ago

Hey folks, is anyone able to provide a reproduction scenario of this happening on Android? I understand that the issue seems to be flaky which makes it very hard to debug on our end, so would appreciate if anyone could share an app binary and Flow where this happens with me (axel@mobile.dev) and we'll see whether we can reproduce and come up with a fix. Thanks!

pascaldornfeld commented 6 months ago

I found the same issue today in maestro cloud.

image

Thats the cloud link: https://console.mobile.dev/uploads/6739cd0f-8c2a-4f61-a721-f688a094737e?teamId=43872dfc-a4b8-4040-9de5-2ec41fc01754&appId=551173e3-eefd-4185-a865-048b6f2861fa&analysisId=a5cb3836-8d05-46d5-84da-4e2e73ac2682&checkIdx=2

mitramejia commented 1 month ago

I am seeing a slightly different, but potentially related issue. I have the following flow:

appId: my-app
---

- tapOn: "Username"
- inputText: "Ethan"
- tapOn: "Password"
- inputText: "blklbl"
- tapOn: "Sign In"
- assertVisible: .*Current Duty Status.*

What I am seeing is that the flow usually works without issue. However, every so often (on ~20% of runs or somewhere in that ballpark) an extra "y" will be added at the end of the password, causing the test to fail (since it becomes the wrong password with a "y" at the end). It is always a "y" character for some reason. I can open a separate issue if that makes sense, but thought it might be related to this existing issue.

Im having exactly this issue on android

mitramejia commented 1 month ago

I am seeing a slightly different, but potentially related issue. I have the following flow:

appId: my-app
---

- tapOn: "Username"
- inputText: "Ethan"
- tapOn: "Password"
- inputText: "blklbl"
- tapOn: "Sign In"
- assertVisible: .*Current Duty Status.*

What I am seeing is that the flow usually works without issue. However, every so often (on ~20% of runs or somewhere in that ballpark) an extra "y" will be added at the end of the password, causing the test to fail (since it becomes the wrong password with a "y" at the end). It is always a "y" character for some reason. I can open a separate issue if that makes sense, but thought it might be related to this existing issue.

Looks like using android SDK 34 resolves this issue:

maestro cloud --android-api-level 34 tests/

I ran 15+ test runs in maestro cloud without problems. Have not tested with Android SDK 31-33. Shout out to @Fishbowler for his help debugging this.