Conditionals

Certain commands allow the use of conditional statements to allow the user to execute them only in certain cases.

There are currently two supported conditional statements:

when

The when statement allows a command to be executed only when one, or more, conditional statements are met.

The check for the conditional statement is performed once upon evaluation of the command.

Conditions

when supports four different conditions:

  1. visible - run the command only when the proceeding selector element is visible

  2. notVisible - run the command only when the proceeding selector element is NOT visible

  3. true - run the command only when the given value is true or not empty

  4. platform - run the command only when the platform is one of android|ios|web

These conditionals can be used individually or combined into a complex statement

Supported Commands

The commands which can take the when statement are as follows:

  • runScript (not yet supported by Moropo)

Example

simple statement

- runFlow
    file: test.yaml
    when:
      visible:
        text: some text

complex statement

- runFlow
    file: test.yaml
    when:
      visible:
        text: some text
      notVisible:
         text: some different text
      true: ${SOME_VARIABLE == 'value'}
      platform: ios

while

The while statement allows a command to be executed only when one, or more, conditional statements are met.

The check for the conditional statement is performed each time the conditional is not satisfied.

Conditions

while supports four different conditions:

  1. visible - run the command only while the proceeding selector element is visible

  2. notVisible - run the command only while the proceeding selector element is NOT visible

  3. true - run the command only while the given value is true or not empty

  4. platform - run the command only while the platform is one of android|ios|web

These conditionals can be used individually or combined into a complex statement

Supported Commands

The commands which can take the while statement are as follows:

Example

simple statement

- repeat
    commands:
      - scroll:
        direction: DOWN
    while:
      visible:
        text: some text

complex statement

- repeat
   commands:
      - scroll:
        direction: DOWN
    while:
      visible:
        text: some text
      notVisible:
         text: some different text
      true: ${SOME_VARIABLE == 'value'}
      platform: ios

Last updated