Click task | Zoho QEngine Help

Click task

In a nutshell

The Click task automates a click on any web element during test execution. It validates that a click produces its intended outcome, such as adding an item to a shopping cart or signing into an account. User interactions in web applications frequently depend on clicks, making the Click task one of the most commonly used actions in web test automation.

1. Overview

The Click task interacts with a web element on a webpage. It applies to elements such as buttons, hyperlinks, checkboxes, and radio buttons. Using Click on one of these triggers actions such as submitting a form, moving to a different page, or opening a menu.

While form action tasks are scoped to a specific element type, Click applies to nearly any interactive element on a web page. This task is often used repeatedly across a workflow, one action after another, with separate assertion tasks confirming the results afterward.

Notes

Note:

  1. For entering text into a field, prefer Set Value over Click, since Set Value populates the field directly rather than relying on UI-driven typing.

  2. For actions beyond a standard left-click, such as double-clicking, right-clicking, or hovering before clicking, use the corresponding tasks under Keyboard and Mouse Actions.

2. Syntax

click(<locator>);


ParameterData TypeDescription
locatorSTRING

Identifies the element to click.

NotesNote: Locators can be fetched in one of two ways, either by manually inspecting the webpage for the element, or by using an element already saved through a recording session. Learn more about Elements

3. Examples

Example 1: Navigating to the product listing page

Navigates to the product listing page from the ZWatch Commerce home page by clicking the Shop Now link.

// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Click the Shop Now link using the Click task
click("a[href*='all-products']");

where:


"https://zwatch.zohocommerce.com/"ZWatch Commerce home page URL.
"same window"Opens the page in the window already running the test.
a[href*='all-products']Locator for the Shop Now link.

Example 2: Jumping to the reviews section and confirming it's visible

Clicks the reviews link on the Blue Bay GMT product page to jump to the reviews section, then confirms it's visible with an assertion.

// Open the Blue Bay GMT product page on the ZWatch Commerce website using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/blue-bay-gmt/3531661000000075668", "same window");
// Click the reviews link using the Click task
click("a[href='#zpview_rating']");
// Confirm the reviews section is visible using the Assert Visible task
assertVisible("#zpview_rating", errorhandling.STOP_ON_ERROR);

where:


"https://zwatch.zohocommerce.com/products/blue-bay-gmt/3531661000000075668"Blue Bay GMT product page URL.
"same window"Opens the page in the window already running the test.
a[href='#zpview_rating']Locator for the reviews link.
#zpview_ratingLocator for the reviews section the link points to.
errorhandling.STOP_ON_ERRORStops the test if the reviews section doesn't become visible.

Example 3: Applying a coupon code at checkout

Applying a coupon at checkout by clicking the Apply Coupon button.

// Open the checkout page using the Open URL task
openURL("https://www.<website_name>.com/<checkout_page>", "same window");
// Click the Apply Coupon button using the Click task
click(ui.<checkout_page>.<apply_coupon_button>);

where:

"https://www.<website_name>.com/<checkout_page>"Checkout page URL.
"same window"Opens the page in the window already running the test.
ui.<checkout_page>.<apply_coupon_button>Locator for the Apply Coupon button.

Example 4: Submitting a support ticket in a Zoho Creator application

A support ticket form, built on Zoho Creator, gets submitted by clicking the Submit button.

// Open the support ticket form in the IT Helpdesk application using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/it-helpdesk#Form:New_Ticket", "same window");
// Enter the ticket subject using the Set Value task
setValue(ui.ithelpdesk.ticket-subject-field, "Unable to access shared drive");
// Select the ticket priority using the Select task
select(ui.ithelpdesk.priority-dropdown, "High", select.TEXT);
// Click the Submit button using the Click task
click(ui.ithelpdesk.submit-button);

where:


"https://creatorapp.zoho.com/<orgname>/it-helpdesk#Form:New_Ticket"Support ticket form URL.
"same window"Opens the form in the window already running the test.
ui.ithelpdesk.ticket-subject-fieldLocator for the ticket subject field.
"Unable to access shared drive"Subject entered for the ticket.
ui.ithelpdesk.priority-dropdownLocator for the priority dropdown.
"High"Priority selected for the ticket.
select.TEXTSelects the option by matching its visible text.
ui.ithelpdesk.submit-buttonStored locator for the Submit button.

4. Use cases

Scenario 1: Navigating to the contact page from the footer

Shoppers with questions about an order or product often look for a way to reach the store directly, usually through a footer link rather than hunting through the main navigation.

A tester uses Zoho QEngine to automate this validation. The test scrolls to the Contact link in the footer, clicks it, and confirms the contact page loads. If the validation failed, a shopper looking for support could be stuck with no working way to reach the store.


Steps

  1. Open the home page in the same window.
  2. Scroll to the Contact link in the footer.
  3. Click the Contact link.
  4. Confirm the contact page loads.

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: Scroll to the Contact link using the Scroll To task
scrollTo("a[href='/contact']");
// Step 3: Click the Contact link using the Click task
click("a[href='/contact']");
// Step 4: Confirm the Contact page loads using the Assert Text task
assertText("title", "Contact | Watch Shopping", errorhandling.STOP_ON_ERROR);
Scenario 2: Loading the next page of search results

Search results pages often paginate results across multiple pages, and shoppers rely on a "Next" control to move through them without losing their place.

A tester uses Zoho QEngine to automate this validation. The test scrolls to the Next button, clicks it, and confirms a new set of results loads. If the validation failed, shoppers could get stuck seeing the same results repeatedly with no way to browse further.

Steps

  1. Open the shop page in the same window.
  2. Scroll to the Next button.
  3. Click the Next button.
  4. Confirm the page number indicator updates.

Implementation

// Step 1: Open the shop page in the same window using the Open URL task
openURL("https://www.dailygoods.com/shop", "same window");
// Step 2: Scroll to the Next button using the Scroll To task
scrollTo(ui.shop.next-button);
// Step 3: Click the Next button using the Click task
click(ui.shop.next-button);
// Step 4: Confirm the page number indicator updates using the Assert Text task
assertText(ui.shop.page-number-indicator, "2", errorhandling.STOP_ON_ERROR);

Scenario 3: Advancing a candidate to the interview stage in a recruitment application

Consider an organization that uses a Zoho Creator Recruitment Portal application to manage job applicants. Each candidate's record has a custom action button, Move to Interview, on its Detail View. Clicking this button runs a Deluge workflow that updates the record's Status field to "Interview Scheduled" and sends a notification to the hiring manager. A recruiter working from the Candidates report opens a specific candidate's record and clicks this button to move them forward in the pipeline.

A tester uses Zoho QEngine to automate this validation. The test opens the Candidates report, opens the candidate's record, clicks Move to Interview, and confirms the Status field updates accordingly. If the validation failed, a strong candidate could sit unnoticed at an earlier stage with no hiring manager ever alerted.

Steps

  1. Open the Candidates report in the Recruitment Portal application.
  2. Click the candidate's row to open the record in Detail View.
  3. Click the Move to Interview custom action button.
  4. Confirm the Status field shows "Interview Scheduled" in the record's Detail View.

Implementation

// Step 1: Open the Candidates report in the Recruitment Portal application using the Open URL task
openURL("https://creatorapp.zoho.com/orgname/recruitment-portal#Report:Candidates", "same window");
// Step 2: Click the candidate's row to open the record in Detail View using the Click task
click(ui.recruitmentportal.candidate-row);
// Step 3: Click the Move to Interview custom action button using the Click task
click(ui.recruitmentportal.move-to-interview-button);
// Step 4: Confirm the Status field shows Interview Scheduled using the Assert Text task
assertText(ui.recruitmentportal.status-field, "Interview Scheduled", errorhandling.STOP_ON_ERROR);

5. Points to note

  1. Use Scroll To to bring an element into the visible viewport before clicking it. Click does not scroll automatically, and an element off-screen or hidden behind a sticky header may not respond correctly.
  2. Follow a major step, such as a page navigation or a data-fetching action, with a Wait task. Configure it to check if the element is interactable, rather than using a fixed delay.
  3. For entering text into a field, prefer Set Value over Click, since Set Value populates the field directly. Reserve Click for triggering actions such as Submit, or interacting with controls like checkboxes and dropdowns.
  4. For real keyboard input, such as typing with individual keystrokes, using shortcuts, or tabbing between fields, use Send Keys instead of Click, since it mimics actual user behavior.
  5. A completed Click task doesn't confirm the intended outcome occurred. Pair it with an assertion to verify the actual result. Learn more
  6. When locating the element to click, use logical or recorded locators, such as a button's visible text or a link's href attribute, over raw full XPath strings.

6. Related topics

  1. Open URL
  2. Set Value
  3. Assert Text

7. What's next

Next step
Previous step
Next step
Now that you've used the Click task to interact with an element, learn how to enter text into a field using the Set Value task.
Previous step
Before using the Click task, ensure that you've learned how to navigate to a URL using the Open URL task.