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

Infinite loop when using repeat while true with maestro.copiedText #2110

Open
1 task done
hormesiel opened this issue Oct 23, 2024 · 2 comments
Open
1 task done

Infinite loop when using repeat while true with maestro.copiedText #2110

hormesiel opened this issue Oct 23, 2024 · 2 comments

Comments

@hormesiel
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and didn't find mine.

Steps to reproduce

I'm trying to find a "bullet-proof" workaround to issues #495 and #1777 by using repeat and maestro.copiedText to clear edit texts on Android no matter their content's length, and to keep my code DRY. Unfortunately this doesn't work ; for some reason the while condition never evaluates to true which causes an infinite loop.

# _utils/edit-text-clear-text.yaml
appId: ""

---

- copyTextFrom: ${EDIT_TEXT_LABEL}
- repeat:
    while:
      true: ${maestro.copiedText} # <-- PROBLEM HERE
      true: ${maestro.copiedText != ''} # <-- This won't work either
      true: ${maestro.copiedText.length > 0} # <-- This won't work either
    commands:
      - tapOn: ${EDIT_TEXT_LABEL}
      - eraseText
      - copyTextFrom: ${EDIT_TEXT_LABEL}
# some-flow.yaml

# [...]

- tapOn: "E-mail"
- runFlow:
    file: _utils/edit-text-clear-text.yaml
    env:
      EDIT_TEXT_LABEL: "E-mail"
- inputText: ${SIGN_UP_EMAIL}

Actual results

Maestro never gets out of the repeat loop, even after the edit text has been entirely cleared.

Expected results

Maestro should get out of the repeat loop once the edit text's value is empty.

About app

Closed source app and I can't share any binary sorry.

About environment

  • Windows 11 (64-bit)

Logs

No response

Maestro version

1.38.1

How did you install Maestro?

install script (https://get.maestro.mobile.dev)

Anything else?

No response

Copy link

linear bot commented Oct 23, 2024

@hormesiel
Copy link
Author

This doesn't work either 😔:

# _utils/edit-text-clear-text.yaml

- copyTextFrom: ${EDIT_TEXT_LABEL}
- repeat:
    while:
      true: ${output.editTextIsNotEmpty} # <-- changed this
    commands:
      - tapOn: ${EDIT_TEXT_LABEL}
      - eraseText
      - copyTextFrom: ${EDIT_TEXT_LABEL}
      - evalScript: ${output.editTextIsNotEmpty = maestro.copiedText != ''} # <-- added this

neither do this:

# _utils/edit-text-clear-text.yaml

- copyTextFrom: ${EDIT_TEXT_LABEL}
- repeat:
    while:
      true: ${output.copiedTextIsNotEmpty} # <-- changed this
    commands:
      - tapOn: ${EDIT_TEXT_LABEL}
      - eraseText
      - copyTextFrom: ${EDIT_TEXT_LABEL}
      - runScript: # <-- added this
          file: copied-text-is-not-empty.js
          env:
            copiedText: ${maestro.copiedText}
// _utils/copied-text-is-not-empty.js

//output.copiedTextIsNotEmpty = maestro.copiedText.length > 0
output.copiedTextIsNotEmpty = copiedText.length > 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant