Assert Value task | Zoho QEngine Help

Assert Value

In a nutshell

The Assert Value task retrieves the current underlying value held by a form element and compares it with the expected value defined in your test. The comparison is case-sensitive, so differences in capitalization will cause the assertion to fail. This confirms that a value set earlier in the test, such as text typed into a quantity, username, or password field, still holds as expected when a later step checks it.

1. Overview

This task evaluates the data inside form components such as text boxes, password fields, or dropdown menus. When dealing with dropdowns, the system specifically checks the selected option's underlying value attribute rather than the visible text label shown on the screen.

The task functions as a checkpoint that reacts differently depending on the output. When a mismatch occurs, it can either stop the test immediately or log the failure while execution continues. The output can also be saved to a variable, allowing subsequent steps to make decisions based on the result.

NotesNote: Assert Value checks the value held by a form element and not visible text on the page. Use Assert Text for content displayed outside a form element.

2. Syntax

assertValue(<locator>, <value>, <errorHandling>);

(or)

<variable> = assertValue(<locator>, <value>, <errorHandling>);

ParameterData TypeDescription
locatorSTRING

Identifies the element that should hold the expected value.

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.

valueSTRINGValue expected to be held in the element.
errorHandlingSTRING

Determines how the test behaves if the value doesn't match:

  1. errorhandling.STOP_ON_ERROR - Stops the test case if the value doesn't match.
  2. errorhandling.CONTINUE_ON_ERROR - Records the result and continues running the test case regardless of a mismatch.


Return Type
Boolean

3. Examples

Example 1: Confirming a search term stays in the search box

After entering a search term, the value in the search box gets checked to confirm if it is registered correctly.

// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Click the search icon to reveal the search input using the Click task
click(".theme-search");
// Enter a search term using the Set Value task
setValue("[data-search-input]", "Chrono 44");
// Confirm the search box holds the entered term
assertValue("[data-search-input]", "Chrono 44", 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.
.theme-searchLocator for the search icon.
[data-search-input]Locator for the search box.
"Chrono 44"Expected value held in the search box.
errorhandling.STOP_ON_ERRORStops the test if the search box doesn't hold the entered term.

Example 2: Checking a username field before submitting a login form
A login form's username field gets checked against the expected entry before the form is submitted.
// Open the login page using the Open URL task
openURL("https://www.<website_name>.com/<login_page>", "same window");
// Enter the username using the Set Value task
setValue(ui.<login_page>.<username_field>, "chris.morgan");
// Confirm the username field holds the entered value
assertValue(ui.<login_page>.<username_field>, "chris.morgan", errorhandling.STOP_ON_ERROR);

where:


"https://www.<website_name>.com/<login_page>"Login page URL.
"same window"Opens the page in the window already running the test.
ui.<login_page>.<username_field>Locator for the username field.
"chris.morgan"Expected value held in the username field.
errorhandling.STOP_ON_ERRORStops the test if the field doesn't hold the entered value.

Example 3: Verifying a quantity field before adding to cart

A quantity field on a checkout page gets checked to confirm it holds the intended amount before the order proceeds.

// Open the checkout page using the Open URL task
openURL("https://www.<website_name>.com/<checkout_page>", "same window");
// Enter a quantity using the Set Value task
setValue(ui.<checkout_page>.<quantity_field>, "3");
// Confirm the quantity field holds the entered amount
assertValue(ui.<checkout_page>.<quantity_field>, "3", errorhandling.CONTINUE_ON_ERROR);

where:


"https://www.<website_name>.com/<page_name>"Checkout page URL.
"same window"Opens the page in the window already running the test.
ui.<page_name>.<element_name>Locator for the quantity field.
"3"Expected value held in the quantity field.
errorhandling.CONTINUE_ON_ERRORContinues the test and returns the result instead of stopping if the value doesn't match.

Example 4: Confirming a tenant name in a Zoho Creator application

A lease form's tenant name field, on Zoho Creator, gets checked after the field is filled.

// Open the lease form in the Lease Tracker application using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/lease-tracker#Form:New_Lease", "same window");
// Enter the tenant name using the Set Value task
setValue(ui.leasetracker.tenant-name-field, "Morgan Blake");
// Confirm the tenant name field holds the entered value
assertValue(ui.leasetracker.tenant-name-field, "Morgan Blake", errorhandling.STOP_ON_ERROR);

where:


"https://creatorapp.zoho.com/orgname/lease-tracker#Form:New_Lease"Lease form URL.
"same window"Opens the form in the window already running the test.
ui.leasetracker.tenant-name-fieldLocator for the tenant name field.
"Morgan Blake"Expected value held in the tenant name field.
errorhandling.STOP_ON_ERRORStops the test if the field doesn't hold the entered value.

Example 5: Confirming a dropdown selection by its underlying value

After selecting a strap material from a dropdown, its underlying value gets checked to confirm the correct option was selected, not just its visible label.

// 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: Select the Leather option in the Strap Material dropdown by its position
select("select[data-zs-attribute-name='Strap Material']", "1", select.INDEX);
// Step 3: Confirm the dropdown's underlying value matches the Leather option's value attribute
assertValue("select[data-zs-attribute-name='Strap Material']", "3531661000000075706", errorhandling.STOP_ON_ERROR);

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.
select[data-zs-attribute-name='Strap Material']Locator for the Strap Material dropdown.
"1"Index of the Leather option, starting from 0.
select.INDEXSelects the option by its position rather than its text or value.
"3531661000000075706"The Leather option's actual underlying value attribute, not its index or visible label.
errorhandling.STOP_ON_ERRORStops the test if the dropdown's value doesn't match.

4. Use cases

Scenario 1: Confirming a search term doesn't persist after a page reload

Shoppers sometimes refresh a page mid-search. Depending on how the search field is configured, it may retain the previous search term instead of clearing it, which could confuse results on the next attempt.

A tester uses Zoho QEngine to check whether the search field clears after a reload rather than retaining the earlier term. If the field doesn't clear, an old search term could linger and interfere with a shopper's next search.

Steps

  1. Open the home page in the same window.
  2. Enter a search term into the search box.
  3. Reload the home page.
  4. Confirm the search box no longer holds the entered term.

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: Reload the home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Step 5: Confirm the search box no longer holds the entered term
assertValue("[data-search-input]", "", errorhandling.STOP_ON_ERROR);
Scenario 2: Verifying a saved draft retains entered details

Registration forms that support saving a draft need to restore the entered details when the customer returns.

A tester uses Zoho QEngine to confirm that reloading a saved registration draft restores the entered email address rather than losing it. If the draft doesn't restore correctly, customers returning to continue a registration could find their progress lost.

Steps

  1. Open the registration form in the same window.
  2. Enter an email address.
  3. Save the draft.
  4. Reload the registration form.
  5. Confirm the email field still holds the entered value.

Implementation

// Step 1: Open the registration form in the same window using the Open URL task
openURL("https://www.<website_name>.com/<registration_page>", "same window");
// Step 2: Enter an email address using the Set Value task
setValue(ui.<registration_page>.<email_field>, "jamie.rivera@example.com");
// Step 3: Save the draft using the Click task
click(ui.<registration_page>.<save_draft_button>);
// Step 4: Reload the registration form using the Open URL task
openURL("https://www.<website_name>.com/<registration_page>", "same window");
// Step 5: Confirm the email field still holds the entered value
assertValue(ui.<registration_page>.<email_field>, "jamie.rivera@example.com", errorhandling.STOP_ON_ERROR);
Scenario 3: Confirming a lease renewal form retains the tenant's details
Consider a property management organization that uses a Zoho Creator Lease Tracker application to manage tenant leases. Each tenant's lease record in the Leases report has a Renew Lease custom action button in its Detail View. Clicking this button opens the Lease Renewal form, passing the tenant's existing details, including Tenant Name, as query parameters so the form loads pre-filled rather than blank.

A tester uses Zoho QEngine to confirm that clicking Renew Lease on a tenant's record carries their details over to the Lease Renewal form correctly. If the validation failed, a property manager could send a renewal form with missing or incorrect tenant details.

Steps

  1. Open the Leases report in the Lease Tracker application.
  2. Click the tenant's lease record to open it in Detail View.
  3. Click the Renew Lease custom action button.
  4. Confirm the Tenant Name field on the Lease Renewal form is pre-filled with the correct value on edit.

Implementation

// Step 1: Open the Leases report in the Lease Tracker application using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/lease-tracker#Report:Leases", "same window");
// Step 2: Click the tenant's lease record to open it in Detail View using the Click task
click(ui.leasetracker.lease-record-row);
// Step 3: Click the Renew Lease custom action button using the Click task
click(ui.leasetracker.renew-lease-button);
// Step 4: Confirm the Tenant Name field on the Lease Renewal form is pre-filled with the correct value
assertValue(ui.leasetracker.tenant-name-field, "Morgan Blake", errorhandling.STOP_ON_ERROR);

5. Points to note

  1. Assert Value is intended for validating form element values, not visible page text. Use Assert Text to validate visible text.
  2. Assert Value requires an exact, case-sensitive match against the full value. A partial substring or different casing returns a failed assertion.
  3. When validating fields that recalculate asynchronously like a total after a coupon is applied, the data might not update instantly. Store the result in a variable, then check its status in a conditional loop to retry the validation or run an alternative step, using a Wait task to allow time for the update rather than letting a brief delay fail the entire test.

6. Related links

  1. Assert Text
  2. Set Value
  3. Wait

7. What's next

Next step
Previous step
Next step
Now that you've used the Assert Value task to confirm an input's value, learn how to pause a test case using the Wait task.

Previous step

Before using the Assert Value task, ensure that you've learned how to confirm text on a page using the Assert Text task.