Set Value task | Zoho QEngine Help

Set Value

In a nutshell

The Set Value task enters a specified value directly into an input element on a webpage. This is used to populate fields such as a search box or a login form. The entered value is ready for the next step, whether that's submitting a search or confirming that the field contains the expected value. The task works with any text-based input, from a single search box to a full form with multiple fields.

1. Overview

The Set Value task populates a value into any text-based input element on a page. It's commonly used to automate scenarios such as entering a search query, filling out a login form, or typing a note into a checkout field. The task updates the fields directly, so it provides precise and predictable behavior in automated workflows.

NotesNote: Set Value populates the field directly, without simulating individual keystrokes. For scenarios that depend on real keyboard input, such as triggering a live autocomplete suggestion, use Send Keys instead.

2. Syntax

setValue(<locator>, <value>);


ParameterData TypeDescription
locatorSTRING

Identifies the text-based input element that receives the specified value.

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

valueSTRINGValue to be set in the input element.

3. Examples

Example 1: Entering a search query on the home page

Enters "Chrono 44" into the search box on the ZWatch Commerce home page using the Set Value task.

// Open the ZWatch Commerce home page using the Open URL task
openURL("https://zwatch.zohocommerce.com/", "same window");
// Enter a search query using the Set Value task
setValue("[data-search-input]", "Chrono 44");

where:

"https://zwatch.zohocommerce.com/"ZWatch Commerce home page URL.
"same window"Opens the page in the window already running the test.
[data-search-input]Locator for the search box.
"Chrono 44"Search term entered into the search box.

Example 2: Testing an invalid email format on a login form
Enters an incorrectly formatted email address into a login form's email field to check whether an inline validation error appears.
// Open the login page using the Open URL task
openURL("<webpage_url>/login", "same window");
// Enter an invalid email format using the Set Value task
setValue(ui.login.email-field, "example#mail.con");
// Confirm the inline validation error appears using the Assert Visible task
assertVisible(ui.login.email-format-error, errorhandling.STOP_ON_ERROR);

where:


"<webpage_url>/login"Login page URL.
"same window"Opens the page in the window already running the test.
ui.login.email-fieldLocator for the email field.
"example#mail.con"Invalid email format entered into the field.
ui.login.email-format-errorLocator for the inline validation error.
errorhandling.STOP_ON_ERRORStops the test if the validation error doesn't appear.

Example 3: Adding a gift note at checkout

A short message is entered into the gift note field on a checkout page, using the Set Value task.

// Open the checkout page using the Open URL task
openURL("<webpage_url>/checkout", "same window");
// Enter a gift note using the Set Value task
setValue(ui.checkout.gift-note-field, "Happy Birthday!");

where:


"<webpage_url>/checkout"Checkout page URL.
"same window"Opens the page in the window already running the test.
ui.checkout.gift-note-fieldLocator for the gift note field.
"Happy Birthday!"Message entered into the gift note field.

Example 4: Entering a candidate's name in a candidate application form

A candidate application form, built in Zoho Creator, has separate First Name and Last Name fields under the Candidate Name section. These fields are filled using the Set Value task.

// Open the candidate application form in the Recruitment Portal application using the Open URL task
openURL("https://creatorapp.zoho.com/<orgname>/recruitment-portal#Form:New_Application", "same window");
// Enter the candidate's first name using the Set Value task
setValue(ui.recruitmentportal.first-name-field, "Jordan");
// Enter the candidate's last name using the Set Value task
setValue(ui.recruitmentportal.last-name-field, "Lee");

where:


"https://creatorapp.zoho.com/<orgname>/recruitment-portal#Form:New_Application"Candidate application form URL.
"same window"Opens the form in the window already running the test.
ui.recruitmentportal.first-name-fieldLocator for the First Name field.
"Jordan"First name entered into the field.
ui.recruitmentportal.last-name-fieldLocator for the Last Name field.
"Lee"Last name entered into the field.

4. Use cases

Scenario 1: Searching for a product and confirming relevant results appear

Shoppers rely on search bar to quickly find a specific product rather than browsing the full catalog.

A tester uses Zoho QEngine to automate this validation. When the test case runs, it enters a search term into the search box and checks whether the results reflect that term. The validation will allow shoppers to search for a product and avoid seeing irrelevant or no results.

Steps

  1. Open the home page in the same window.
  2. Enter a search term into the search box.
  3. Submit the search.
  4. Confirm the results reflect the search 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: Enter a search term using the Set Value task
setValue("[data-search-input]", "Chrono 44");
// Step 3: Submit the search using the Send Keys task
sendKeys("[data-search-input]", [keys.ENTER]);
// Step 4: Confirm the results reflect the search term using the Assert Text task
assertText(".search-results-heading", "Results for Chrono 44", errorhandling.STOP_ON_ERROR);
Scenario 2: Filling out a signup form and confirming account creation

New customers create an account by filling out a signup form before they can check out with saved details.

A tester uses Zoho QEngine to automate this validation. When the test case runs, it fills out the signup fields and checks whether the account is created successfully. If the validation failed, new customers could be unable to sign up at all, blocking them from completing a purchase.

Steps

  1. Open the signup page in the same window.
  2. Enter a name, email, and password.
  3. Submit the form.
  4. Confirm the account is created.

Implementation

// Step 1: Open the signup page in the same window using the Open URL task
openURL("<webpage_url>/signup", "same window");
// Step 2: Enter the customer's name using the Set Value task
setValue(ui.signup.name-field, "Jamie Rivera");
// Step 3: Enter the customer's email using the Set Value task
setValue(ui.signup.email-field, "jamie.rivera@example.com");
// Step 4: Enter a password using the Set Value task
setValue(ui.signup.password-field, "SecurePass123");
// Step 5: Submit the form using the Click task
click(ui.signup.submit-button);
// Step 6: Confirm the account is created using the Assert Visible task
assertVisible(ui.signup.account-created-message, errorhandling.STOP_ON_ERROR);
Scenario 3: Updating a candidate's phone number in a recruitment application

Consider an organization that uses a Recruitment Portal application built on Zoho Creator to manage job applications. A recruiter reviewing a candidate's record sometimes needs to correct a detail, such as an outdated phone number, after the application was originally submitted.

A tester uses Zoho QEngine to automate this validation. When the test case runs, it opens the candidate's record from the Candidates report, edits the phone number field, and checks whether the update is saved. If the validation failed, a corrected phone number could appear to save successfully but silently revert, leaving the recruiter unable to reach the candidate.

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 Edit.
  4. Enter the updated phone number.
  5. Click Update.
  6. Confirm the record reflects the updated phone number.

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 Edit using the Click task
click(ui.recruitmentportal.edit-button);
// Step 4: Enter the updated phone number using the Set Value task
setValue(ui.recruitmentportal.phone-field, "9876543210");
// Step 5: Click Update using the Click task
click(ui.recruitmentportal.update-button);
// Step 6: Confirm the record reflects the updated phone number using the Assert Text task
assertText(ui.recruitmentportal.phone-field, "9876543210", errorhandling.STOP_ON_ERROR);

5. Points to note

  1. Set Value populates a field directly rather than simulating keystrokes. For scenarios that depend on real keyboard input, such as a live autocomplete suggestion, use Send Keys instead.
  2. Prefer Set Value over Click when focusing an input field, since it populates the value directly without relying on UI-driven clicks or typing.
  3. Set Value replaces the existing value in the field. Use Clear only when the field needs to be emptied without entering a replacement value.
  4. Follow the Set Value task with an assertion, such as Assert Value, to confirm the field actually holds the entered value. Learn more
  5. When locating the input element, use logical or recorded locators, such as a field's name or label, over raw full XPath strings.

6. Related topics

  1. Click
  2. Assert Value
  3. Send Keys

7. What's next

Next step
Previous step
Next step
Now that you've used the Set Value task to enter a value into a field, learn how to confirm text appears on a page using the Assert Text task.
Previous step

Before using the Set Value task, ensure that you've learned how to interact with an element using the Click task.