In a nutshell
The Assert Text task verifies that the visible text content of a web element exactly matches the expected value. The comparison is case-sensitive, so differences in capitalization will cause the assertion to fail. This confirms that the application is displaying the correct information, such as a record count, status, or field value, instead of assuming a previous step completed successfully.
The Assert Text task verifies that a specific web page element displays the expected visible text. It locates the target UI element, retrieves its rendered text, and compares it against an expected value.
This task is commonly used to validate scenarios such as confirming a success message after a form submission, verifying that a page heading matches a search term, or ensuring a total updates correctly after a discount is applied.
The task also includes configurable error handling, determining how the test responds if the text does not match. The test can either stop execution immediately or log the mismatch and continue running. Optionally, the result of the validation can be stored in a variable, enabling subsequent test steps to evaluate and act on the outcome.
Note: Assert Text compares only the element's visible text, not hidden text, attributes, or the underlying HTML content, and it doesn't validate that the element is visible on the page as its own outcome. Use Assert Visible instead to confirm an element is present and displayed to the user. assertText(<locator>, <text>, <errorHandling>);
| Parameter | Data Type | Description |
| locator | STRING | Identifies the element that should contain the expected text. 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. |
| text | STRING | Text expected to be found in the element. |
| errorHandling | STRING | Determines how the test behaves if the text doesn't match:
|
Return Type: Boolean
This script verifies the tagline on the ZWatch Commerce homepage against its expected text.
// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// <Wait> for the homepage banner to become visible
wait(10, ".theme-banner-heading", event.SHOW);
// Confirm the homepage banner shows the expected tagline
assertText(".theme-banner-heading", "Live Inspired", errorhandling.STOP_ON_ERROR);where:
| "https://zwatch.zohocommerce.com/" | ZWatch Commerce home page URL. |
| "same window" | Opens the page in the window already running the test. |
| 10 | Maximum time to wait for the banner to become visible, in seconds. |
| .theme-banner-heading | Locator for the homepage banner heading. |
| event.SHOW | Waits until the banner becomes visible. |
| "Live Inspired" | Expected tagline text. |
| errorhandling.STOP_ON_ERROR | Stops the test if the tagline doesn't match. |
This script clicks the Contact link from the home page and confirms the page title matches the Contact page, verifying that navigation landed on the intended page rather than an unexpected one.
// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Click the Contact link using the Click task
click("a[href='/contact']");
// Confirm the page title matches the expected value
assertText("title", "Contact | Watch Shopping", errorhandling.STOP_ON_ERROR);where:
| "https://zwatch.zohocommerce.com/contact" | ZWatch Commerce home page URL. |
| "same window" | Opens the page in the window already running the test. |
| "a[href='/contact']" | Locator for the Contact link on the home page. |
| title | Locator for the page's title element. |
| "Contact | Watch Shopping" | Expected page title text. |
| errorhandling.STOP_ON_ERROR | Stops the test if the title doesn't match. |
This script attempts to submit the signup form with the email field left blank and confirms the inline error message appears beneath the field.
// Open the signup page using the Open URL task
openURL("https://www.<website_name>.com/<signup_page>", "same window");
// Attempt to submit the form without entering an email, using the Click task
click(ui.<signup_page>.<submit_button>);
// Confirm the inline "Email is required" error appears beneath the email field
assertText(ui.<signup_page>.<email_required_error>, "Email is required", errorhandling.CONTINUE_ON_ERROR);where:
| "https://www.<website_name>.com/<signup_page>" | Signup page URL. |
| "same window" | Opens the page in the window already running the test. |
| ui.<signup_page>.<submit_button> | Locator for the submit button. |
| ui.<signup_page>.<email_required_error> | Locator for the error message element. |
| "Email is required" | Expected inline error message text. |
| errorhandling.CONTINUE_ON_ERROR | Continues the test and returns the result instead of stopping if the message doesn't match. |
This script confirms the registration count on an event dashboard, built on Zoho Creator, increases by one after a new registration is submitted through the Event Registration form.
// Step 1: Open the event dashboard page in the Event Manager application using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/event-manager#Page:Event_Details", "same window");
// Step 2: Confirm the registration count currently reads 41 registered
assertText(ui.eventmanager.registration-count, "41 registered", errorhandling.STOP_ON_ERROR);
// Step 3: Open the Event Registration form using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/event-manager#Form:Event_Registration", "same window");
// Step 4: Enter the registrant's name using the Set Value task
setValue(ui.eventmanager.registrant-name-field, "Jordan Lee");
// Step 5: Enter the registrant's email using the Set Value task
setValue(ui.eventmanager.registrant-email-field, "jordan.lee@example.com");
// Step 6: Submit the registration using the Click task
click(ui.eventmanager.submit-button);
// Step 7: Open the event dashboard page again using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/event-manager#Page:Event_Details", "same window");
// Step 8: Confirm the registration count reflects the new signup
assertText(ui.eventmanager.registration-count, "42 registered", errorhandling.STOP_ON_ERROR);where:
| "https://creatorapp.zoho.com/<orgname>/event-manager#Page:Event_Details" | Event dashboard page URL. |
| "same window" | Opens the page in the window already running the test. |
| "41 registered" | Registration count before the new signup. |
| "https://creatorapp.zoho.com/<orgname>/event-manager#Form:Event_Registration" | Event Registration form URL. |
| ui.eventmanager.registrant-name-field | Locator for the registrant's name field. |
| "Jordan Lee" | Name entered for the new registrant. |
| ui.eventmanager.registrant-email-field | Locator for the registrant's email field. |
| "jordan.lee@example.com" | Email entered for the new registrant. |
| ui.eventmanager.submit-button | Locator for the form's submit control. |
| "42 registered" | Expected registration count text. |
| errorhandling.STOP_ON_ERROR | Stops the test if the count doesn't match. |
Shoppers searching for a specific watch model expect the results heading to reflect what they searched for, not a generic or stale label.
A tester uses Zoho QEngine to confirm that performing a product search updates the results heading to display the entered search term. If this validation failed, shoppers may view irrelevant search results without realizing the search itself hadn't worked correctly.
Steps
Implementation
// Step 1: Open the ZWatch Commerce home page in the same window using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Step 2: Click the search icon to reveal the search input using the Click task
click(".theme-search");
// Step 3: Enter a search term using the Set Value task
setValue("[data-search-input]", "Chrono 44");
// Step 4: Submit the search using the Send Keys task
sendKeys("[data-search-input]", [keys.ENTER]);
// Step 5: Confirm the results heading reflects the search term using the Assert Text task
assertText(".search-results-heading", "Results for Chrono 44", errorhandling.STOP_ON_ERROR);Some signup forms validate a password field as the customer types, showing an inline hint if the password doesn't meet requirements, rather than waiting until submission.
A tester uses Zoho QEngine to confirm that entering a weak password causes the inline hint to appear with the correct message. If this validation failed, customers could submit a weak password with no warning until the form rejects it later.
Steps
Implementation
// Step 1: Open the signup page in the same window using the Open URL task
openURL("https://www.<website_name>.com/<page_name>", "same window");
// Step 2: Enter a weak password using the Set Value task
setValue(ui.<page_name>.<element_name>, "12345");
// Step 3: Confirm the inline validation message appears using the Assert Text task
assertText(ui.<page_name>.<element_name>, "Password is too weak", errorhandling.STOP_ON_ERROR);Consider an organization that uses a Zoho Creator Event Management application to manage event registrations. The Event Registration form has its Restrict Form Entries property configured with a maximum entry limit and a custom message, "Registration is closed," to display once that limit is reached. For testing, this limit is set to 1 entry so the closed-registration condition can be reproduced without needing real event capacity data. Once the limit is hit, the form becomes inaccessible, showing the closed-registration message in place of the form fields, so no one can submit a registration for an event that's already full.
A tester uses Zoho QEngine to confirm that submitting one registration to reach the configured limit causes the form to show the closed-registration message instead of its fields on the next visit. If this validation failed, a registrant could still access the form and submit for an event that's already full.
Steps
Implementation
// Step 1: Open the Event Registration form in the Event Manager application using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/event-manager#Form:Event_Registration", "same window");
// Step 2: Submit a registration to reach the configured entry limit using the Click task
click(ui.eventmanager.register-button);
// Step 3: Open the Event Registration form again using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/event-manager#Form:Event_Registration", "same window");
// Step 4: Confirm the closed-registration message appears instead of the form using the Assert Text task
assertText(ui.eventmanager.restricted-access-message, "Registration is closed", errorhandling.STOP_ON_ERROR);Now that you've used the Assert Text task to confirm text on a page, learn how to verify an input's value using the Assert Value task.
Before using the Assert Text task, ensure that you've learned how to enter a value into a field using the Set Value task.