Skip to navigation

wait

The wait action pauses test execution for a specified duration before proceeding to the next step. This is useful for adding delays, for example, to allow time for animations to complete or to make recordings easier to follow.

The value assigned to the wait key is the duration to pause in milliseconds, 0 or more. You can also set it to:

  • true to pause for 5000 milliseconds. Reports show the step as "wait": 5000.
  • false to skip the step.
  • An environment variable, such as "$WAIT_DURATION", that holds a number of milliseconds.

For comprehensive options, see the wait reference.

Examples

The docs tests run the two fixed-duration examples. The variable and default-duration examples are illustration-only.

Wait for 3 seconds

{
"tests": [
{
"steps": [
{
"description": "Perform an action.",
"goTo": "https://example.com"
},
{
"description": "Wait for 3000 milliseconds (3 seconds).",
"wait": 3000
},
{
"description": "Perform the next action.",
"screenshot": "after_wait.png"
}
]
}
]
}

Wait for 500 milliseconds

{
"tests": [
{
"steps": [
{
"description": "Click something.",
"find": {
"selector": "#myButton",
"click": true
}
},
{
"description": "Wait for half a second.",
"wait": 500
},
{
"description": "Check the result.",
"find": "Action complete!"
}
]
}
]
}

Wait for a duration set by a variable

Set the duration from an environment variable so one value drives every wait in a suite. Load the variable first, then reference it with $VAR.

{
"tests": [
{
"steps": [
{
"description": "Load WAIT_DURATION from a .env file.",
"loadVariables": ".env"
},
{
"description": "Wait for the number of milliseconds in WAIT_DURATION.",
"wait": "$WAIT_DURATION"
}
]
}
]
}

Wait for the default duration

Pass true to pause for the default 5000 milliseconds without naming a number.

{
"tests": [
{
"steps": [
{
"description": "Pause for the default 5000 milliseconds.",
"wait": true
}
]
}
]
}