ThesendKeys action is applicable for textbox or textarea HTML elements. This is used to type text into the textbox. This will simulate the user keyboard and types text into WebElements exactly as a user would. The API syntax for the sendKeys() method is as follows:
void sendKeys(java.lang.CharSequence...keysToSend)
The input parameter for the preceding method is CharSequence of text that has to be entered into the element. This method doesn't return anything. Now, let's see a code example of how to type a search text into the Search box using the sendKeys() method:
@Testpublic void elementSendKeysExample() { WebElement searchBox = driver.findElement(By.name("q")); searchBox.sendKeys("Phones"); searchBox.submit();