In a nutshell
The Wait task pauses a test case for a specified duration, or until a specific element on the page reaches an expected state. It supports two types: a fixed wait that holds for a set number of seconds, and an event-based wait that holds until an element becomes clickable, visible, hidden, or present. This keeps a test synchronized with the web page, such as holding until a cart total finishes recalculating before checking it.
The Wait task pauses execution for a set duration, or until a specified element on the page reaches a particular state. It fits any point where a page needs a moment to load, render, or respond to a prior action. This task is typically used in cases like a confirmation message that takes a moment to appear after a form is submitted.
The Wait task supports two types:
Fixed wait - Pauses the test case for a set duration in seconds, regardless of what happens on the page. Suited to a short, predictable delay where no specific element governs how long to wait.
An event-based wait ends once one of the following four events occurs:
Use this syntax to pause execution for a specified amount of time.
wait(<time>);
| Parameter | Data Type | Description |
| time | LONG | Duration to wait, in seconds. Note: The maximum time you can specify in a wait task is 150 seconds. |
Use this syntax to pause the execution until a specified element reaches a particular state, or until the timeout is reached.
wait(<time>, <locator>, <event>);
| Parameter | Data Type | Description |
| time | LONG | Maximum duration to wait for the event, in seconds. Note: The maximum duration allowed for wait is 150 seconds. |
| locator | STRING | Identifies the element the wait condition applies to. Note: You can find a locator by manually inspecting the webpage for the element, or by using an element already saved through a recording session. Learn more about Elements. |
| event | STRING | The condition the task waits for:
|
This script opens the ZWatch Commerce home page and pauses the test case for a fixed duration to allow the page to finish loading before the next task runs.
// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Pause for 5 seconds to allow the page to finish loading
wait(5);where:
| "https://zwatch.zohocommerce.com/" | ZWatch Commerce home page URL. |
| "same window" | Opens the page in the window already running the test. |
| 5 | Duration to wait, in seconds. |
This script waits for the Add to Cart button to become clickable before clicking it.
// Step 1: Open the Diver Chronomat product page on the ZWatch Commerce website using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722", "same window");
// Step 2: Wait until the Add to Cart button becomes clickable
wait(10, ".theme-product-qty-and-add-cart", event.CLICKABLE);
// Step 3: Click the Add to Cart button using the Click task
click(".theme-product-qty-and-add-cart");where:
| "https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722" | Diver Chronomat product page URL. |
| "same window" | Opens the page in the window already running the test. |
| 10 | Maximum time to wait for the button to become clickable, in seconds. |
| .theme-product-qty-and-add-cart | Locator for the Add to Cart button. |
| event.CLICKABLE | Waits until the button becomes clickable. |
This script waits for the cart confirmation message to become visible after adding an item to the cart.
// Open the Diver Chronomat product page on the ZWatch Commerce website using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722", "same window");
// Click the Add to Cart button using the Click task
click(".theme-product-qty-and-add-cart");
// Wait until the cart confirmation message becomes visible
wait(10, ".theme-cart-add-success-message", event.SHOW);where:
| "https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722" | Diver Chronomat product page URL. |
| "same window" | Opens the page in the window already running the test. |
| .theme-product-qty-and-add-cart | Locator for the Add to Cart button. |
| 10 | Maximum time to wait for the message to appear, in seconds. |
| .theme-cart-add-success-message | Locator for the cart confirmation message. |
| event.SHOW | Waits until the message becomes visible. |
This script waits for a loading spinner to disappear on a Zoho Creator report before its results can be checked.
// Open the Expense Records report in the Expense Tracker application using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/expense-tracker#Report:Expense_Records", "same window");
// Wait until the loading spinner is hidden
wait(20, ui.expensetracker.loading-spinner, event.HIDE);where:
| "https://creatorapp.zoho.com/orgname/expense-tracker#Report:Expense_Records" | Expense Records report URL. |
| "same window" | Opens the report in the window already running the test. |
| 20 | Maximum time to wait for the spinner to disappear, in seconds. |
| ui.expensetracker.loading-spinner | Locator for the loading spinner. |
| event.HIDE | Waits until the spinner is no longer displayed. |
Adding an item to the cart triggers a confirmation message that takes a moment to appear, and checking the cart's state too soon could result in error before that update finishes.
A tester uses Zoho QEngine to automate this validation. When the test case runs, it adds a product to the cart, waits for the confirmation message to appear, and confirms its text. This ensures the application has completed the cart update before the assertion runs, rather than checking for a message that hasn't appeared yet.
Steps
Implementation
// Step 1: Open the Diver Chronomat product page on the ZWatch Commerce website in the same window using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722", "same window");
// Step 2: Add the product to the cart using the Click task
click(".theme-product-qty-and-add-cart");
// Step 3: Wait until the cart confirmation message becomes visible
wait(10, ".theme-cart-add-success-message", event.SHOW);
// Step 4: Confirm the message text using the Assert Text task
assertText(".theme-cart-add-success-message", "Added to cart", errorhandling.STOP_ON_ERROR);Clicking a link to jump to a page's reviews section relies on that section already being rendered, and reading it before it's fully rendered could result in an incomplete view.
A tester uses Zoho QEngine to automate this validation. When the test case runs, it clicks the Reviews link, waits for the reviews section to become visible, and confirms the review count. This ensures the reviews section has rendered before the count is checked, rather than reading a count from a section that hasn't loaded yet.
Steps
Implementation
// Step 1: Open the Blue Bay GMT product page on the ZWatch Commerce website in the same window using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/blue-bay-gmt/3531661000000075668", "same window");
// Step 2: Click the reviews link using the Click task
click("a[href='#zpview_rating']");
// Step 3: Wait until the reviews section becomes visible
wait(10, "#zpview_rating", event.SHOW);
// Step 4: Confirm the review count using the Assert Text task
assertText("#zpview_rating", "9 Reviews", errorhandling.STOP_ON_ERROR);Consider an organization that uses a Zoho Creator Facility Booking application to manage meeting room reservations. Submitting a booking request triggers a workflow that updates the corresponding room's Status field in the Rooms report, and that update takes a moment to complete. Checking the room's record immediately after submission could still show it as available.
A tester uses Zoho QEngine to automate this validation. When the test case runs, it submits a booking, opens the room's record in the Rooms report, and waits for the Status field to update before confirming it reads "Reserved."
Steps
Implementation
// Step 1: Open the room booking form in the Facility Booking application using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/facility-booking#Form:Room_Reservation", "same window");
// Step 2: Submit the booking request using the Click task
click(ui.facilitybooking.submit-button);
// Step 3: Open the Rooms report using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/facility-booking#Report:Rooms", "same window");
// Step 4: Locate the room's record using the Click task
click(ui.facilitybooking.room-record-row);
// Step 5: Wait until the room's Status field shows the updated value
wait(15, ui.facilitybooking.room-status, event.SHOW);
// Step 6: Confirm the status reads Reserved using the Assert Text task
assertText(ui.facilitybooking.room-status, "Reserved", errorhandling.STOP_ON_ERROR);Now that you've learned all the General tasks, learn how to put them together into a test case using the web testing recorder or the web testing builder and editor.
Before using wait tasks, know how the other General tasks such as Open URL, Click, Set Value, Assert Text, and Assert Value work.