Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 2.12 KB

conditions.md

File metadata and controls

87 lines (66 loc) · 2.12 KB

Conditions

{% hint style="warning" %} By design, Maestro discourages the usage of conditional statements unless absolutely necessary as they could easily ramp up the complexity of your tests. {% endhint %}

runFlow conditionally

- runFlow:
    when:
      visible: Some Text
    file: {reference to another yaml file}

{% content-ref url="nested-flows.md" %} nested-flows.md {% endcontent-ref %}

Or, if you don't wish to extract your commands into a separate flow file, you can run the commands inline like this:

- runFlow:
    when:
      visible: Some Text
    commands:
        - tapOn: Some Text

{% content-ref url="../api-reference/commands/runflow.md" %} runflow.md {% endcontent-ref %}

runScript conditionally

- runScript:
    when:
      visible: Some Text
    file: {reference to a javascript file}

{% content-ref url="../api-reference/commands/runscript.md" %} runscript.md {% endcontent-ref %}

Multiple conditions

- runFlow:
    when:
      visible: Some Text
      platform: iOS
    file: {reference to another yaml file}

Note that multiple conditions are applied as AND conditions.

Conditions

Supported conditions include:

visible: { Element matcher }        # True if matching element is visible
notVisible: { Element matcher }     # True if matching element is not present
true: { Value }                     # True if given value is true or not empty
platform: { Platform }              # True if current platform is given platform (Android|iOS|Web)

All of the normal element matchers are supported.

{% content-ref url="../api-reference/selectors.md" %} selectors.md {% endcontent-ref %}

JavaScript

Usage of JavaScript conditions is possible via true condition:

- runFlow:
    when:
      true: ${MY_PARAMETER == 'Something'}
    file: subflow.yaml

{% content-ref url="javascript/" %} javascript {% endcontent-ref %}