In a nutshell
The Send Keys task sends a sequence of keystrokes to a web element during test execution. It can combine typed text with special keys such as Tab, Enter, or Delete in a single action. This triggers keyboard-driven behavior, which differs by simulating actual keystrokes rather than setting a field's value directly, such as submitting a form with Enter or moving focus to the next field with Tab.
The Send Keys task sends a sequence of keystrokes to a web element, registered by the browser as genuine keyboard input rather than a value set directly using the Set Value task. It's commonly used to automate scenarios such as submitting a form by pressing Enter, moving between fields with Tab, or triggering a live suggestion that only appears while typing.
Each call takes an array combining plain text, such as a username or password, with special key constants, such as keys.ENTER or keys.TAB. The values are sent to the element in the order they are listed.
sendKeys(<locator>, <keys>);
| Parameter | Data Type | Description |
| locator | STRING | Identifies the element that should receive the keystrokes. Note: Locators can be found by <manually inspecting> the webpage for the element, or by using an element already saved through a <recording> session. <Learn more about Elements> |
| keys | ARRAYLIST | Sequence of keystrokes to send to the element, sent in the order listed. Each item is either a plain text string, sent as literal characters, or a special key constant, such as keys.ENTER, keys.TAB, or keys.DELETE. See Supported key constants for the complete list. Supported key constants: ADD, ALT, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, BACK_SPACE, CANCEL, CLEAR, COMMAND, CONTROL, DECIMAL, DELETE, DIVIDE, DOWN, END, ENTER, EQUALS, ESCAPE, HELP, HOME, INSERT, LEFT, LEFT_ALT, LEFT_SHIFT, META, MULTIPLY, NULL, PAGE_DOWN, PAGE_UP, PAUSE, RETURN, RIGHT, SEMICOLON, SEPARATOR, SHIFT, SPACE, SUBTRACT, TAB, UP. |
Submit a search by sending the Enter key after entering a search term.
// 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");
// Submit the search by sending the Enter key using the Send Keys task
sendKeys("[data-search-input]", [keys.ENTER]);
// Confirm the results heading reflects the search term using the Assert Text task
assertText(".search-results-heading", "Results for 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-search | Locator for the search icon. |
| [data-search-input] | Locator for the search box. |
| "Chrono 44" | Search term entered into the search box. |
| keys.ENTER | Submits the search, the same as pressing Enter. |
| .search-results-heading | Locator for the results heading. |
| errorhandling.STOP_ON_ERROR | Stops the test if the results heading doesn't match. |
Fill the username and password fields and submit the form in a single Send Keys call, moving between fields with Tab and submitting by sending Enter.
// Open the login page using the <Open URL> task
openURL("https://www.<website_name>.com/<login_page>", "same window");
// Fill in the username and password fields and submit the form using the Send Keys task
sendKeys(ui.<login_page>.<username_field>, ["chris.morgan", keys.TAB, "SecurePass123", keys.ENTER]);
// Confirm the account page loads using the <Assert Visible> task
assertVisible(ui.<login_page>.<account_dashboard>, 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, where the key sequence begins. |
| ["chris.morgan", keys.TAB, "SecurePass123", keys.ENTER] | Enters the username, uses Tab to move focus to the password field, then enters the password and uses Enter to submit the form. |
| ui.<login_page>.<account_dashboard> | Locator for the account dashboard, shown after a successful login. |
| errorhandling.STOP_ON_ERROR | Stops the test if the account dashboard doesn't load. |
Close the search suggestions panel by sending Escape after entering a partial search term, without selecting an option.
// Open the search page using the <Open URL> task
openURL("https://www.<website_name>.com/<search_page>", "same window");
// Enter a partial search term using the <Set Value> task
setValue(ui.<search_page>.<search_field>, "Chro");
// Press Escape to close the suggestions panel using the Send Keys task
sendKeys(ui.<search_page>.<search_field>, [keys.ESCAPE]);
// Confirm the suggestions panel is closed using the <Get Count> task
suggestionsCount = getCount(ui.<search_page>.<suggestions_panel>);
if (suggestionsCount != 0)
{
throwError("Suggestions panel did not close after pressing Escape");
}where:
| "https://www.<website_name>.com/<search_page>" | Search page URL. |
| "same window" | Opens the page in the window already running the test. |
| ui.<search_page>.<search_field> | Locator for the search field. |
| "Chro" | Partial search term entered into the search field. |
| keys.ESCAPE | Closes the suggestions panel without selecting an option. |
| ui.<search_page>.<suggestions_panel> | Locator for the suggestions panel. |
| suggestionsCount | Variable storing the number of suggestions panels found after pressing Escape. |
Populate the First Name and Last Name fields on the Zoho Creator Recruitment Portal application form by navigating between fields with Tab, using a single Send Keys call.
// 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 first and last names, moving between fields with Tab, using the Send Keys task
sendKeys(ui.recruitmentportal.first-name-field, ["Jordan", keys.TAB, "Lee"]);
// Confirm both fields hold the entered values using the <Assert Value> task
assertValue(ui.recruitmentportal.first-name-field, "Jordan", errorhandling.STOP_ON_ERROR);
assertValue(ui.recruitmentportal.last-name-field, "Lee", errorhandling.STOP_ON_ERROR);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-field | Locator for the First Name field, where the key sequence begins. |
| ["Jordan", keys.TAB, "Lee"] | Fills the first name, moves to the Last Name field, then fills it. |
| ui.recruitmentportal.last-name-field | Locator for the Last Name field. |
| errorhandling.STOP_ON_ERROR | Stops the test if either field doesn't hold the entered value. |
Shoppers often press Enter to submit a search rather than clicking a separate search button, and the search needs to respond the same way either action is taken.
A tester uses Zoho QEngine to verify that submitting a search for Chrono 44 on the ZWatch Commerce home page with the Enter key returns matching results. This confirms the search behaves consistently regardless of how it is submitted.
Steps
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: Submit the search by sending the Enter key using the Send Keys task
sendKeys("[data-search-input]", [keys.ENTER]);
// Step 5: Confirm the results heading reflects the search term using the Assert Text task
assertText(".search-results-heading", "Results for Chrono 44", errorhandling.STOP_ON_ERROR);New customers filling out a registration form often move between fields by pressing Tab rather than clicking each field. The form should respond correctly to this keyboard navigation and submit successfully when Enter is pressed.
A tester uses Zoho QEngine to verify that users can enter their name, email address, and password, navigate between fields using Tab, and submit the registration form with Enter to create an account.
Steps
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 the name, email, and password fields, moving between them with Tab, using the <Send Keys> task
sendKeys(ui.<registration_page>.<name_field>, ["Jamie Rivera", keys.TAB, "jamie.rivera@example.com", keys.TAB, "SecurePass123"]);
// Step 3: Submit the form using the <Click> task
click(ui.<registration_page>.<submit_button>);
// Step 4: Confirm the account is created using the <Assert Visible> task
assertVisible(ui.<registration_page>.<account_created_message>, errorhandling.STOP_ON_ERROR);Consider a Recruitment Portal application built on Zoho Creator that job candidates use to submit applications. Candidates sometimes navigate the Job Category dropdown using arrow keys and Enter rather than clicking an option directly.
A tester uses Zoho QEngine to verify that pressing the Down Arrow key to move through the options, followed by Enter to select one, chooses the correct Job Category. This confirms that candidates can complete the selection using only the keyboard and submit their application under the intended category.
Steps
Implementation
// Step 1: 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");
// Step 2: Click the Job Category dropdown to give it focus using the Click task
click(ui.recruitmentportal.job-category-dropdown);
// Step 3: Press the down arrow key to move to the next option, then Enter to confirm it, using the Send Keys task
sendKeys(ui.recruitmentportal.job-category-dropdown, [keys.ARROW_DOWN, keys.ENTER]);
// Step 4: Confirm the dropdown reflects the selected category using the Assert Value task
assertValue(ui.recruitmentportal.job-category-dropdown, "Engineering", errorhandling.STOP_ON_ERROR);Previous
Before learning about the Send Keys task, ensure you have learned how to right-click an element using the <Right Click> task.
Now that you've learned how to send keystrokes to an element using the Send Keys task, learn how to hover over an element using the <Hover> task.