> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# if

> Run steps conditionally based on an assertion.

A conditional is a single `if` key holding exactly one assertion condition plus
a `then` list. The condition is an `assert`, a screen check, an element check,
or a `javascript` expression. Mobile conditionals do **not** support `else`. Use
a separate step instead.

## Parameters

| Parameter | Type      | Required | Description                                                                                                                                |
| --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| condition | `command` | Yes      | Exactly one assertion command: `assert`, `checkScreenContains`, `checkScreenDoesNotContain`, a `checkElement<...>` alias, or `javascript`. |
| `then`    | `step[]`  | Yes      | Steps to run when the condition passes.                                                                                                    |

## Examples

```yaml theme={null}
- if:
    checkElementVisible: the cookie banner # condition: run `then` only when this passes
    then:
      - tap: Accept all
```

```yaml theme={null}
- if:
    assert: A success banner is visible
    then:
      - tap: Continue
```

## Related

* [Test format](/core-concepts/test-format)
