mobile-dev-inc / maestro

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

Output of relativePoint cannot be used with swipe command start and end parameters #2149

Open tafty opened 2 days ago

tafty commented 2 days ago

Is there an existing issue for this?

Steps to reproduce

The output of the relativePoint JavaScript function can be passed into the tapOn command as the point parameter but cannot be passed into the swipe command as either the start or end parameters.

For example, the below works as expected with tapOn:

- evalScript: ${output.startPoint = relativePoint(0.5, 0.8)}

- tapOn:
    point: ${output.startPoint}

But using the same variable with swipe gives a runtime error when starting the Maestro script:

- evalScript: ${output.startPoint = relativePoint(0.5, 0.8)}

- swipe:
    start: ${output.startPoint}
    end: 50%,12%

The error shown is:

You need to provide start and end coordinates with %, Found: (50%, 12%, ${output.startPoint})

There's nothing in the docs to indicate that the output of relativePoint shouldn't be used with the swipe command. Am I doing something wrong? I guess the error implies that the inline JavaScript value is not being evaluated correctly for the swipe command...?

Actual results

Maestro script does not run and gives error: You need to provide start and end coordinates with %, Found: (50%, 12%, ${output.startPoint})

Expected results

The JavaScript variable is evaluated correctly to it's point coordinates and passed into the swipe command.

About app

A cross platform, closed source React Native (0.73.9) app. Currently writing tests using an iOS simulator

About environment

Maestro:

 maestro -version
1.39.1

Java:

java -version
openjdk version "17.0.10" 2024-01-16 LTS
OpenJDK Runtime Environment Zulu17.48+15-CA (build 17.0.10+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.48+15-CA (build 17.0.10+7-LTS, mixed mode, sharing)

M2 Max Macbook Pro running MacOS Sonoma 14.7

Logs

Logs 18:12:49.631 [ INFO] MAESTRO.logSystemInfo: ---- System Info ---- 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: Maestro Version: 1.39.1 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: CI: Undefined 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: OS Name: Mac OS X 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: OS Version: 14.7 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: Architecture: aarch64 18:12:49.632 [ INFO] MAESTRO.logSystemInfo: Java Version: 17 18:12:49.720 [ INFO] MAESTRO.logSystemInfo: Xcode Version: 16.1 18:12:49.723 [ INFO] MAESTRO.logSystemInfo: Flutter Version: Undefined 18:12:49.725 [ INFO] MAESTRO.logSystemInfo: Flutter Channel: Undefined 18:12:49.725 [ INFO] MAESTRO.logSystemInfo: ---------------------

Maestro version

1.39.1

How did you install Maestro?

Homebrew

Anything else?

The use case associated with this issue is that I have a utility YAML file that scrolls down a long screen and takes screenshots of each section. I need to be able to pass in a parameter for the start percentage of the swipe because some screens have tabs at the bottom whilst others do not. Passing a parameter into relativePoint also fails with the same error but I've boiled my example down to the simplest representation of the problem.

linear[bot] commented 2 days ago

MA-2593 Output of relativePoint cannot be used with swipe command start and end parameters