Wait task | Zoho QEngine Help

Wait task

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.

1. Overview

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.


Event-based wait - Pauses the test case until a specified element reaches a chosen event, avoiding a fixed duration that finishes too early or runs longer than the page actually needs.

An event-based wait ends once one of the following four events occurs:

  1. event.CLICKABLE - Detects the moment an element is visible and enabled so it can be clicked. Ideal for buttons that remain disabled until form validation completes.
  2. event.SHOW - Confirms the moment an element becomes visible on the page. Applicable to content that renders after the page loads, such as a confirmation banner.
  3. event.HIDE - Tracks the moment an element is no longer displayed. Useful for a loading spinner or overlay that needs to clear before the next step can run.
  4. event.PRESENT - Recognizes the moment an element exists on the page, regardless of whether it's visible. Fits content that gets added to the page dynamically, before it's necessarily displayed.

2. Syntax

2.1 Fixed Wait

Use this syntax to pause execution for a specified amount of time.


wait(<time>);


ParameterData TypeDescription
timeLONGDuration to wait, in seconds.

Note: The maximum time you can specify in a wait task is 150 seconds.

2.2 Event-based wait

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>);


ParameterData TypeDescription
timeLONGMaximum duration to wait for the event, in seconds.
NotesNote: The maximum duration allowed for wait is 150 seconds.
locatorSTRINGIdentifies the element the wait condition applies to.

NotesNote: 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.
eventSTRING

The condition the task waits for:

  1. event.CLICKABLE - Detects when the target element is visible and enabled for interaction.
  2. event.SHOW - Detects when the target element becomes visible.
  3. event.HIDE - Confirms the target element is no longer displayed.
  4. event.PRESENT - Checks that the target element exists on the page.

3. Examples

Example 1: Pausing for a fixed duration between form steps

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.
5Duration to wait, in seconds.

Example 2: Waiting for the Add to Cart button to become clickable

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.
10Maximum time to wait for the button to become clickable, in seconds.
.theme-product-qty-and-add-cartLocator for the Add to Cart button.
event.CLICKABLEWaits until the button becomes clickable.

Example 3: Waiting for the cart confirmation message to appear

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-cartLocator for the Add to Cart button.
10Maximum time to wait for the message to appear, in seconds.
.theme-cart-add-success-messageLocator for the cart confirmation message.
event.SHOWWaits until the message becomes visible.

Example 4: Waiting for a loading spinner to disappear in an Expense tracker application

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.
20Maximum time to wait for the spinner to disappear, in seconds.
ui.expensetracker.loading-spinnerLocator for the loading spinner.
event.HIDEWaits until the spinner is no longer displayed.

4. Use cases

Scenario 1: Confirming the cart updates before checking out

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

  1. Open the product page in the same window.
  2. Add the product to the cart.
  3. Wait for the cart confirmation message to become visible.
  4. Confirm the message text.

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);

Scenario 2: Waiting for the reviews section to render before reading it

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

  1. Open the product page in the same window.
  2. Click the reviews link.
  3. Wait for the reviews section to become visible.
  4. Confirm the review count.

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);

Scenario 3: Waiting for a room booking confirmation in a facility management application

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

  1. Open the room booking form in the Facility Booking application.
  2. Submit a booking request for a specific room.
  3. Open the Rooms report.
  4. Locate the room's record.
  5. Wait for the room's Status field to update.
  6. Confirm the status reads "Reserved."

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);

5. Points to note

  1. Prefer the event-based form of wait wherever the next interaction is dependent on a specific element. A fixed wait can end before the page is actually ready, or run longer than needed and slow the test case down.
  2. The maximum duration allowed for wait is 150 seconds. If a condition consistently exceeds this limit, investigate the underlying page or process for potential performance issues.
  3. Combine wait with an assertion once the condition is met. This confirms the element doesn't just meet the wait condition, it also holds the expected content.

6. Related topics

  1. Click
  2. Assert Text
  3. Assert Value

7. What's next

Next step
Previous step
Next step

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.



Previous step

Before using wait tasks, know how the other General tasks such as Open URL, Click, Set Value, Assert Text, and Assert Value work.