Check task | Zoho QEngine Help

Check task

In a nutshell

The Check task automates checking a checkbox on a webpage. It performs the same action as a user clicking the checkbox to mark it as selected. This lets your test confirm choices that depend on a checked state, such as accepting terms and conditions before an account can be created.

1. Overview

The Check task sets a checkbox on a web page to its checked state. It's used to automate interactions with checkbox controls representing binary choices, such as accepting terms and conditions or applying an optional discount during checkout. This also extends to default toggle switches, since these are typically built on a checkbox element underneath.

This task is useful for validating workflows where checking a box can change the application's behavior, unlock additional actions, or save a user's preference, rather than simply changing the visual state of the checkbox.

NotesNote: The Select and Check tasks are two distinct actions that serve different purposes when interacting with web elements. The Select task focuses on setting a value to a dropdown field, while the Check task interacts with the checkbox.

2. Syntax

check(<locator>);


ParameterData TypeDescription
locatorSTRINGLocator that identifies the checkbox on the webpage.

NotesNote: Locators can be fetched in one of two ways, either by manually inspecting the webpage to identify the element, or by using a recorded element saved during a recording session. Learn more about Elements

3. Examples

Example 1: Applying a discount at checkout

Checks the discount checkbox on the ZWatch Commerce checkout page so the discount is applied to the order total.

// Open the checkout page on the ZWatch Commerce website using the Open URL task
openURL("https://zwatch.zohocommerce.com/checkout", "same window");
// Check the discount checkbox using the Check task
check(ui.zwatch.GMT.discount);

where:


"https://zwatch.zohocommerce.com/checkout"Checkout page URL.
"same window"Opens the page in the window already running the test.
ui.zwatch.GMT.discountStored locator for the discount checkbox.

Example 2: Accepting terms and conditions before signup

A signup form requires the terms and conditions checkbox to be checked before the Create Account button becomes enabled.

// Open the account signup page on the ZWatch Commerce website using the Open URL task
openURL("https://zwatch.zohocommerce.com/signup", "same window");
// Check the terms and conditions checkbox using the Check task
check(ui.zwatch.terms-checkbox);
// Confirm the Create Account button is enabled using the Assert Visible task
assertVisible(ui.zwatch.create-account-button, errorhandling.STOP_ON_ERROR);
// Click the Create Account button using the Click task
click(ui.zwatch.create-account-button);

where:


"https://zwatch.zohocommerce.com/signup"Account signup page URL.
"same window"Opens the page in the window already running the test.
ui.zwatch.terms-checkboxStored locator for the terms and conditions checkbox.
ui.zwatch.create-account-buttonStored locator for the Create Account button.

Example 3: Checking a vendor agreement checkbox in a Vendor management application

Checks the Terms Accepted checkbox on a vendor registration form, built on Zoho Creator, using the Check task.

// Open the vendor registration form in the Vendor Compass application using the Open URL task
openURL("https://creatorapp.zoho.com/zylker/vendor-compass#Form:Vendor_Registration", "same window");
// Check the Terms Accepted checkbox using the Check task
check(ui.vendorcompass.terms-accepted-checkbox);

where:


"https://creatorapp.zoho.com/zylker/vendor-compass#Form:Vendor_Registration"Vendor registration form URL.
"same window"Opens the form in the window already running the test.
ui.vendorcompass.terms-accepted-checkboxStored locator for the Terms Accepted checkbox on the form.

4. Use cases

Scenario 1: Saving customer details for a faster future checkout

Online stores often offer a "save my details" option at checkout, so returning customers don't have to retype their shipping address on their next order. This only works if checking that box during checkout actually persists the customer's details for their next visit.

Zoho QEngine automates a check of this workflow. It checks the save-details checkbox during checkout, returns to the checkout page, and verifies the shipping address is pre-filled. If the checkbox failed to save anything, returning customers would have to re-enter their details every time, undermining the whole point of the feature.


Steps
  1. Open the checkout page in the same window.
  2. Check the "Save my details for next time" checkbox.
  3. Complete the order.
  4. Reopen the checkout page.
  5. Confirm the shipping address field is pre-filled.

Implementation

// Step 1: Open the checkout page on the ZWatch Commerce website in the same window using the Open URL task
openURL("https://zwatch.zohocommerce.com/checkout", "same window");
// Step 2: Check the save-details checkbox using the Check task
check(ui.zwatch.save-details-checkbox);
// Step 3: Complete the order using the Click task
click(ui.zwatch.place-order-button);
// Step 4: Reopen the checkout page using the Open URL task
openURL("https://zwatch.zohocommerce.com/checkout", "same window");
// Step 5: Confirm the shipping address field is pre-filled using the Assert Text task
assertText(ui.zwatch.shipping-address-field, "221B Baker Street", errorhandling.STOP_ON_ERROR);

Scenario 2: Opting into SMS notifications from account settings

Retail apps often let customers manage how they're contacted from an account settings page. This includes a checkbox to enable order updates by SMS instead of, or alongside, email. The setting needs to persist after the customer saves it, not just appear checked until the page is reloaded.

Zoho QEngine automates a check of whether this setting actually sticks. It checks the SMS notifications checkbox, saves the settings, then reloads the page to confirm the checkbox is still checked. If the setting silently failed to save, customers who opted in would never receive the SMS updates they signed up for.


Steps
  1. Open the account settings page in the same window.
  2. Check the SMS notifications checkbox.
  3. Save the settings.
  4. Reload the account settings page.
  5. Confirm the checkbox remains checked.

Implementation

// Step 1: Open the account settings page on the ZWatch Commerce website in the same window using the Open URL task
openURL("https://zwatch.zohocommerce.com/account/settings", "same window");
// Step 2: Check the SMS notifications checkbox using the Check task
check(ui.zwatch.sms-notifications-checkbox);
// Step 3: Save the settings using the Click task
click(ui.zwatch.save-settings-button);
// Step 4: Reload the account settings page using the Open URL task
openURL("https://zwatch.zohocommerce.com/account/settings", "same window");
// Step 5: Confirm the SMS notifications checkbox remains checked using the Assert Visible task
assertVisible(ui.zwatch.sms-notifications-checkbox-checked, errorhandling.STOP_ON_ERROR);

Scenario 3: Enabling automatic reordering in an inventory management application

Consider a retail organization that uses a Zoho Creator Inventory Management application to manage stock replenishment. A warehouse manager enables automatic reordering for a product by selecting the Auto Reorder checkbox on the Product form. When this option is enabled, the application automatically creates a purchase order whenever the product's stock falls below the configured reorder level.

A tester uses Zoho QEngine to verify that the Auto Reorder option is saved correctly. If the option isn't persisted, purchase orders won't be generated automatically when stock reaches the reorder level, leading to stock shortages.


Steps
  1. Open the Product form in the Inventory Management application.
  2. Select the Auto Reorder checkbox.
  3. Save the settings.
  4. Confirm the option persisted after saving.

Implementation

// Step 1: Open the Product form in the Inventory Management application using the Open URL task
openURL("https://creatorapp.zoho.com/zylker/inventory-manager#Form:Product_Settings", "same window");
// Step 2: Select the Auto Reorder checkbox using the Check task
check(ui.inventorymanager.auto-reorder-checkbox);
// Step 3: Save the settings using the Click task
click(ui.inventorymanager.save-button);
// Step 4: Confirm the Auto Reorder checkbox remains checked after saving using the Assert Visible task
assertVisible(ui.inventorymanager.auto-reorder-confirmed-icon, errorhandling.STOP_ON_ERROR);

5. Points to note

  1. Use the Check task only to set a checkbox to its checked state. It does not toggle or clear a checkbox that is already checked. Use Uncheck to clear a checked box instead.
  2. Follow the Check task with an assertion to confirm the checkbox reflects the expected state. Learn more
  3. Prefer logical locators, such as field labels or names, over raw full XPath strings when locating the checkbox.

6. Related topics

  1. Uncheck
  2. Select
  3. Deselect
  4. Clear
  5. Upload

7. What's next

Next step
Previous step
Next step

Now that you've used the Check task to check a checkbox, learn how to clear a checked checkbox using the Uncheck task.


Previous step

Before using the Check task, ensure that you've learned how to remove a previously selected option from a dropdown using the Deselect task.