In a nutshell
The Select task automates choosing an option from a dropdown field on a webpage. It works the way you would click the dropdown open and pick a value during a test. It matches the option in one of three ways: by its position in the list, by the visible text, or by the underlying value the page submits.
The Select task sets a dropdown field on a web page to one of its available options. It fits any form field that limits input to a fixed list of choices. Each dropdown holds its own set of values behind the options shown to the user. Common examples include a payment method during checkout, a product variant on a shopping site, or a language selector on a multilingual page.
The Select task supports three types that identify which option to pick inside the dropdown:
Note: Select is scoped specifically to dropdowns. For checkboxes, use the Check or Uncheck task instead.select(<locator>, <text>, <select_type>);
| Parameter | Data Type | Description |
| locator | STRING | Address to locate the dropdown containing the options to choose from. Note: You can inspect from the webpage to find the locators of the elements or <record> and store the elements. Learn more about <Elements> |
| text | STRING | The text or attribute value to match, according to the select type used. |
| select_type | STRING | The method used to match the option inside the dropdown:
|
Example 1: Selecting a strap material option by position
A customer browsing the Diver Chronomat product page on the ZWatch Commerce store wants the Leather strap variant, selected from the Strap Material dropdown by its position in the list.
// 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: Select the second option in the dropdown, using index 1 since QEngine counts positions starting from 0
select("select[data-zs-attribute-name='Strap Material']", "1", select.INDEX);where:
| "https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722" | URL of the Diver Chronomat product page. |
| "same window" | Opens the product page in the window already running the test. |
| select[data-zs-attribute-name='Strap Material'] | Locator for the Strap Material dropdown on the Diver Chronomat page. |
| "1" | Index of the Leather option in the dropdown, starting from 0. |
| select.INDEX | Selects the option by its position rather than its text or value. |
During checkout, a customer selects United States as their shipping country, and the store needs to confirm that selection actually registered before the order proceeds.
// Step 1: Open the checkout page on the ZWatch Commerce store using the Open URL task
openURL("https://zwatch.zohocommerce.com/checkout", "same window");
// Step 2: shippingCountry holds the visible text of the country to select from the dropdown
shippingCountry = "United States";
// Step 3: Select the country from the shipping country dropdown using its visible text
select(ui.zwatch.checkout-dropdown, shippingCountry, select.TEXT);
// Step 4: Confirm the United States option is now selected, stopping the test if it isn't
assertSelected(ui.zwatch.checkout-dropdown.unitedStates, errorhandling.STOP_ON_ERROR);where:
| "https://zwatch.zohocommerce.com/checkout" | URL of the checkout page on the ZWatch Commerce website. |
| "same window" | Opens the checkout page in the window already running the test. |
| shippingCountry | Variable storing the visible text of the country to select. |
| ui.zwatch.checkout-dropdown | Stored locator for the shipping country dropdown. |
| select.TEXT | Selects the option by matching its visible text. |
| ui.zwatch.checkout-dropdown.unitedStates | Stored locator for the United States option within the dropdown. |
| errorhandling.STOP_ON_ERROR | Stops the test case if the United States option isn't selected. |
A different customer wants the Chain strap variant, but the dropdown submits a numeric variant ID rather than the word "Chain," so the test needs to select by that underlying value instead of the label.
// Step 1: Open the Diver Chronomat product page on the ZWatch Commerce store using the Open URL task
openURL("https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722", "same window");
// Step 2: chainValue holds the Chain option's underlying value attribute, a numeric variant ID rather than the visible "Chain" text
chainValue = "3531661000000075708";
// Step 3: Select the Chain strap option from the dropdown by its underlying value attribute
select("select[data-zs-attribute-name='Strap Material']", chainValue, select.VALUE);where:
| "https://zwatch.zohocommerce.com/products/diver-chronomat/3531661000000075722" | URL of the Diver Chronomat product page. |
| "same window" | Opens the product page in the window already running the test. |
| chainValue | Variable storing the Chain option's underlying value attribute. |
| select[data-zs-attribute-name='Strap Material'] | Locator for the Strap Material dropdown on the Diver Chronomat page. |
| select.VALUE | Selects the option by its underlying value attribute instead of its visible text. |
This script selects the Follow-up option in the Appointment Type dropdown on a patient intake form, built on Zoho Creator, using the Select task.
// Step 1: Open the patient intake form page in the Zylker Patient Management application using the Open URL task
openURL("https://creatorapp.zoho.com/zylker/patient-management#Form:patient_intake", "same window");
// Step 2: Select "Follow-up" from the Appointment Type dropdown by its visible text
select(ui.zylker.appointment-type-dropdown, "Follow-up", select.TEXT);where:
| "https://creatorapp.zoho.com/zylker/patient-management#Form:patient_intake" | URL of the patient intake form in the Zylker Patient Management application. |
| "same window" | Opens the form in the window already running the test. |
| ui.zylker.appointment-type-dropdown | Stored locator for the Appointment Type dropdown on the intake form. |
| "Follow-up" | Visible text of the appointment type option to select. |
| select.TEXT | Selects the option by matching its visible text. |
Scenario 1: Selecting a strap variant and confirming it's added to the cart
An online watch store allows customers to personalize their purchase by choosing a strap material before adding the product to the cart. Each strap option represents a different product variant, and the selected variant determines the item that is added to the order.
To ensure this workflow functions correctly, a tester uses Zoho QEngine to automate the validation. The test verifies that selecting the Leather strap updates the selected variant correctly and allows the customer to add the item to the cart successfully. If the dropdown selection fails, the wrong variant may be added to the order, or the add to cart action may not proceed as expected.
Steps
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: Select the option at index 1 in the Strap Material dropdown by its position
select("select[data-zs-attribute-name='Strap Material']", "1", select.INDEX);
// Step 3: Add the selected variant to the cart using the Click task
click(".theme-product-qty-and-add-cart");
// Step 4: Confirm the cart success message appears using the Assert Visible task
assertVisible(".theme-cart-add-success-message");Scenario 2: Selecting a shipping country by value and confirming the selection
During checkout, an online watch store asks customers to choose their shipping country from a dropdown. The country names shown on screen, such as "United States," don't always match what the page actually submits behind the scenes, since the underlying value attribute can differ from the visible label.
A tester needs to confirm that choosing a country by its submitted value, rather than its visible text, correctly updates the dropdown before checkout proceeds. If this selection doesn't register properly, the order could be shipped against the wrong country code, even though the customer sees the correct country name on screen.
Steps
Implementation
// Step 1: shippingCountry holds the value attribute submitted for United States, since the dropdown's underlying value differs from the country name shown on screen
shippingCountry = "US";
// Step 2: 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 3: Select the stored country from the shipping dropdown by its value attribute
select(ui.zwatch.checkout-dropdown, shippingCountry, select.VALUE);
// Step 4: Confirm the shipping dropdown reflects the selection using the Assert Selected task
assertSelected(ui.zwatch.checkout-dropdown);Scenario 3: Selecting a leave type in an HR web app
Consider an organization that uses a Zoho Creator app called Meridian Payroll to handle its employee leave request process. Employees submit leave requests through a form that includes a Leave Type dropdown offering Sick, Casual, and Earned options, and the type selected determines how the request is categorized and deducted from the employee's leave balance.
A tester needs to confirm that selecting the Earned option in this dropdown works correctly before the form is submitted. If the dropdown selection fails silently, a request could be submitted under the wrong leave type, leading to incorrect balance deductions or approval routing.
Steps
Implementation
// Step 1: Open the leave request form page in the Meridian Payroll web app using the Open URL task
openURL("https://meridianpayroll.zohocreatorportal.com/leave-request", "same window");
// Step 2: Select "Earned" from the Leave Type dropdown by its visible text
select(ui.meridianpayroll.leave-type-dropdown, "Earned", select.TEXT);
// Step 3: Submit the form using the Click task
click(ui.meridianpayroll.submit-button);Previous
Select is the first task covered in the Form Actions group. You may want to start with the Form Actions overview to see the full set of tasks in this group.
Now that you've learned how to select an option from a dropdown using the Select task, learn how to remove a previously selected option from a dropdown using the Deselect task.