12
votes

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

(New Actions(driver)).SendKeys(Keys.ALT, Keys.SHIFT, "z");
4
What host language for Selenium? Java? - Peter Mortensen

4 Answers

17
votes

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);
6
votes

This can also be done using Actions keyUp and keyDown functions.

WebDriver driver = new FirefoxDriver();
Actions keyAction = new Actions(driver);
keyAction.keyDown(Keys.ALT).keyDown(Keys.SHIFT).sendKeys("z").keyUp(Keys.ALT).keyUp(Keys.SHIFT).perform();
0
votes

Try it:

SendKeys.SendWait("%+z")
0
votes

Assuming you're using JavaScript,

Keys.chord(keys)

Also, the documentation is at https://www.selenium.dev/documentation/en/