...

/

Keyboard Interactions

Keyboard Interactions

Learn how to perform keyboard actions using Selenium.

Send key sequences: select all and delete

We can send the key sequences as:

Press + to interact
driver.get("file://" + __dirname + "/../../site/text_field.html");
driver.findElement(By.id("comments")).sendKeys("Multiple Line\r\n Text");
var elem = driver.findElement(By.id("comments"));
driver.actions()
.click(elem)
.keyDown(webdriver.Key.CONTROL)
.sendKeys("a")
.keyUp(webdriver.Key.CONTROL)
.perform();
// this different from click element, the key is send to browser directly
driver.actions()
.sendKeys(webdriver.Key.BACK_SPACE)
.perform();

Please note that the last test statement ...