Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Delay / Sleep

A delay makes BugBug wait a fixed number of seconds before a step starts.

You usually don't need it: BugBug already waits for the page and the element with waiting conditions, only as long as necessary. A fixed delay makes tests slower and can still be too short on a slow day. But a delay can be a quick fix when you don't have time to find out what the step is waiting for.

How the delay works

  1. The delay runs first. BugBug waits for the delay, then starts checking the step's waiting conditions.

  2. It doesn't use up the timeout. The step's timeout starts when the delay ends.

  3. It applies to one step. To wait between two steps, set the delay on the second one.

For example, with a delay of 3 and a timeout of 30, BugBug waits 3 seconds, then has up to 30 seconds to wait for the conditions and run the step.

Add a delay to a step

Open the step and enter a whole number of seconds, up to 300, in the Delay / Sleep field. Leave it empty to use the project's default delay.

Delay / Sleep field in the step settings

In YAML the field is execution.sleep, and in the API and MCP sleep, both in seconds:

Default delay for the project

Project settings have a default delay that applies to every step without its own delay. It's 0 seconds by default. Keep it at 0: a delay on every step makes all tests slower.

Better options than a delay

Problem
Instead of a delay

The element appears after a while

Nothing: Element is visible already waits for it.

A loader or modal covers the element

Element is not covered waits for it to disappear.

The page keeps loading data

Page network requests are finished waits for the requests.

The button is disabled until the form is valid

Element must be active waits for it.

The element must reach a specific state

Add Element must have expected attribute, for example data-state="ready".

A step needs more time than usual

Raise the timeout of that step.

FAQ

Is the delay in seconds or milliseconds?

Seconds, as a whole number from 0 to 300. For a 30-second delay, enter 30.

Does the delay run before or after the step?

Before. BugBug waits for the delay, then checks the step's waiting conditions and runs it. The delay doesn't count towards the step's timeout.

How do I make the test wait 30 seconds before the next step?

Set Delay / Sleep to 30 on the next step. There's no separate wait step. If you need to wait for something specific, a waiting condition or an assertion is faster and more reliable.

Can an Execute JavaScript step wait, for example with await?

Yes. The code can use await, and BugBug waits until it finishes, within the step's timeout. For example, await new Promise((resolve) => setTimeout(resolve, 3000)); waits 3 seconds. For a plain fixed wait, the Delay / Sleep field is simpler.

What does the default delay in project settings do?

It adds the same delay before every step that doesn't have its own. It's 0 by default, and it's best to keep it that way.

Last updated

Was this helpful?