Monday 3 March 2014

Hitting Multiple Keys from Keyboard using Selenium Webdriver

Hitting Multiple Keys from Keyboard using Selenium Webdriver

• Suppose you want to hit <ENTER> key from keyboard. You do it as below:

driver.findElements(By.id("your id here")).sendKeys(Keys.ENTER);


• Suppose you want to hit more tha 1 keys from keyboard for example Selecting some text --> Ctrl+Shift+ArrowRight. You do it as below:


driver.findElement(By.id("id")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT,Keys.ARROW_RIGHT));