mobile-dev-inc / maestro

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

setLocation causes issue if called multiple times #921

Open Aquantis-94 opened 1 year ago

Aquantis-94 commented 1 year ago

If the setLocation action is used multiple times within a test it appears to not release the first location, and as such it will then jump between all mocked locations.

Below is the use case example, we want to create points at two points on a map by navigating to the location using setLocation. There are no issues after the first setLocation call - it correctly sets the location and is then able to execute the evalScript/runFlow. It is after it calls setLocation a second time where it begins to flick between the new and previous locations. See attached screen recording for example.

appId: ${appID}
name: example
id: example
---
- runScript: ../../globals.js

- tapOn: "location-button"
- tapOn: "toggle-gps-lock-fab"

#Set location to address #1
- setLocation:
    longitude: -1.5455
    latitude: 53.9853

- evalScript: ${output.global.STREETNAME = "Park Road"}
- runFlow: ../../Functions/CreateAddress.yaml

#Set location to address #2
- setLocation:
    longitude: -1.5450
    latitude: 53.9854

- evalScript: ${output.global.STREETNAME = "Park Avenue"}
- runFlow: ../../Functions/CreateAddress.yaml

I have managed to replicate this in google maps, in a much simpler example script (attached). In this example it is simply setting location, doing an action, setting new location, another action.

appId: ${appID}
name: googleExample
id: googleExample
---
#Set location to address #1
- setLocation:
    longitude: -1.5455
    latitude: 53.9853

- tapOn: "Search here"
- inputText: "Dummy text to fill time"
- back 
- back

#Set location to address #2
- setLocation:
    longitude: -1.5450
    latitude: 53.9854

- tapOn: "Search here"
- inputText: "Some really obnoxiously long text to give the location time to update to the new currently mocked location set by maestro while still simulating an action."
- back 
- back

The test finishes quickly, but you can see that right at the end the location begins to jump between set locations. Below are the screen recordings and example scripts used to replicate this in both scenarios.

appExample.zip googleExample.zip

axelniklasson commented 1 year ago

@Aquantis-94 could you try using the travel command in the meantime and let us know if that works for you? If you upgrade to the most recent version of maestro, are you still experiencing issues?

rschattauer commented 1 month ago

I have the same issue. setLocation once works, doing it again fails to set the new location and keeps the old one. For me travel only worked on the emulator, but not on a real device. Any update?