Search code examples
seleniumshortcuthotkeys

How can I send keyboard shortcut Alt + Shift + Z (hotkey) with Selenium 2?


I am trying send a shortcut with Actions.sendKeys, but it isn't working.

(New Actions(driver)).SendKeys(Keys.ALT, Keys.SHIFT, "z");

Solution

  • You can check this question to refer about this - Pressing Ctrl+A in Selenium WebDriver

    Check the answer which uses the chord method. In your case, you can do this -

    String selectAll = Keys.chord(Keys.ALT, Keys.SHIFT,"z");
    driver.findElement(By.tagName("html")).sendKeys(selectAll);