Handling Keyboard actions in Selenium
sendKeys() of WebElement interface can be used to press the specified keys of Keyboard.
- Keys is the predefined class of WebDriver API
We can use below different ways:
1. Using Actions Class
Actions action =new Actions(driver);
action.sendKeys(Keys.ENTER).build( ).perform( );
2. Using chrod() predefined method of Keys() class
We can simultaneously press multiple keys using chrod()
WebElement textPassword= driver.findElement(By.id("txtPassword"));
textPassword.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE);
Comments
Post a Comment