maestro
maestro copied to clipboard
If statement
Hi, in my use case, we need to log into the app at first launch, then some other UI test happens. But on the second launch, the login screen doesn't show. In this situation we need an if statement to separate these two work flows.
# flow.yaml
appId: com.example.app
---
- launchApp
- if assertVisible : "Phone Number"
then :
- tapOn: "Phone Number"
- inputText: "+123456789"
- tapOn: "Confirm"
- elif OTHER_CONDITION
then :
- ...
- else :
- tapOn: "Search"
- ...
- fi
To support this particular use case Maestro offers an initFlow
: https://docs.mobile.dev/reference/app-state-restoration
The idea is that you would extract your login flow into a separate file and refer to it in your actual test
That said, an if
statement still has its own use cases and we will consider adding it
.+1 for this enhancement suggestion, it would be fairly critical in some areas
Adding a +1 here. we have a similar case where there is a flow (or a set of steps) we would like to run if an element is visible/invisible.
In my mind the ideal syntax would be (recalling similar syntax of the extendedWaitUntil
):
- runFlow: open-rh.yml
visible: Element
notVisible: Element
but I guess the possibility to add elif and/or else would be interesting
I guess this use case is partially covered by https://github.com/mobile-dev-inc/maestro/pull/245 ? without the else
Nice find, looks like it's gone in to 1.10.x although nothing's been announced for it yet
This is indeed covered with the conditional runFlow execution
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!