In some testing scenarios, you may want to configure additional waits before executing subsequent test steps. In browser and mobile tests, there are three ways to configure additional waits:
In most cases, Configure Find and wait until steps are the recommended method for configuring additional waits because the total wait time is dynamic. If the application is ready before the set timeout, mabl completes the step and continues to execute the next steps.
Wait steps, on the other hand, always wait for a specific amount of time. Wait steps can be useful for isolating performance issues during test execution or capturing a screenshot of the page at a specific point in the test. As a general rule, we recommend using wait steps sparingly because they can slow down the feedback cycle of your tests.
This article explains how to add the three different types of waits to a browser or mobile test.
Intelligent Wait
When a browser test executes in the cloud, mabl uses Intelligent Wait to make sure your application is in the correct state before interacting with elements on the page. In some cases, however, you may want to configure additional waits.
Configure Find
All find actions in mabl, including assertions and clicks, automatically wait up to 30 seconds for the target element to appear. If the element takes longer than 30 seconds to appear in your app, or if the element comes into existence without being fully realized, you can use Configure Find.
Configure Find allows you to:
- specify which element attributes mabl should look for
- set a timeout to define how long mabl should look for the element
Defining a timeout for a Configured Find
The default timeout for Configure Find steps is 15 seconds, but you may set the timeout to wait up to 15 minutes (900 seconds) before finding and interacting with the target element. For more information on using Configure Find, check out this guide.
Wait until steps
Wait until steps wait up to a maximum number of seconds for an element to reach a given state. If the element reaches that state before the timeout, the wait is complete and mabl moves on to the next step.
There are two wait until steps:
- Wait until present: waits for an element to appear on the page.
- Wait until not present: waits for an element to leave the page. Use it when a loading spinner, overlay, or toast notification needs to disappear before the test can continue.
Waiting until an element is present
A wait until present step pauses the test until a matching element appears on the page. If the step reaches its maximum wait time before the element is present, the step fails. Use it to explicitly make the test wait for something to load, such as a search result, modal, or table row.
There are three ways to add one. Which you use depends on whether the element is on screen at the moment you add the step.
- If the element is visible and you can click on it: Add a new wait until present step: + (Add step) > Wait > Add wait until. Select the element that mabl should wait for, check the attributes that mabl should target, set a maximum wait of up to 900 seconds, and choose whether mabl should auto-heal if no matching element is found.
- If the element isn't on the page when you add the step (browser only): Add a custom find step: + (Add step) > Find elements. Enter a CSS selector, Playwright locator, or XPath expression in the Locator field, set the Action to "Wait until present," and set a timeout.
- If you can click on the element while it's present: record a click on the element, then click on the three-dot menu for that step and select Wait until present. mabl automatically sets the timeout to 15 seconds, but you can update it by editing the step.
Waiting until an element is not present
A Wait until not present step pauses the test until a matching element is absent from the DOM. If the element is still present by the time the step reaches its maximum wait time, the step fails. Use it when the test needs to wait for something to go away rather than appear: a loading spinner that must finish, an overlay that must close, or a toast notification that must clear before the test can interact with the element underneath.
There are three ways to add one. Which you use depends on whether the element is on screen at the moment you add the step.
- If the element is visible and you can click on it: Add a new wait until not present step: + (Add step) > Wait > Add wait until not present. Select the element that needs to not be present when the step executes and set a timeout.
- If the element isn't on the page when you add the step (browser only): Add a custom find step: + (Add step) > Find elements. Enter a CSS selector, Playwright locator, or XPath expression in the Locator field, set the Action to "Wait until not present," and set a timeout.
- If you can click on the element before it disappears: record a click on the element, then click on the three-dot menu for that step and select Wait until not present. mabl automatically sets the timeout to 15 seconds, but you can update it by editing the step.
Hidden elements
"Not present" means the element is absent from the DOM, not that it's invisible on screen. If the element remains in the HTML but is hidden with an attribute like display, visibility, or opacity, it still counts as present and the step waits until the timeout.
Wait steps
Wait steps, also known as static waits, tell mabl to wait a specific amount of time before moving on to the next step.
To insert a wait step in the mabl Trainer, take the following steps:
- Click on the plus icon at the bottom of the Trainer window to add a step.
- Click on Wait > Add wait.
- Enter the number of seconds to wait before executing the next step, up to 900 seconds.
- Click OK to add the step.