I am trying send a shortcut with Actions.sendKeys, but it isn't working.
(New Actions(driver)).SendKeys(Keys.ALT, Keys.SHIFT, "z");
I am trying send a shortcut with Actions.sendKeys, but it isn't working.
(New Actions(driver)).SendKeys(Keys.ALT, Keys.SHIFT, "z");
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);
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();
Assuming you're using JavaScript,
Keys.chord(keys)
Also, the documentation is at https://www.selenium.dev/documentation/en/
Apart from the Keys.chord(Keys.ALT, Keys.SHIFT,"z");
method as suggested in the other/accepted answer, I would suggest you try the Robot framework for using keyboard shortcuts.
You can do something like;
Robot robot = new Robot();
Thread.sleep(1000);
robot.delay(3000);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_Y);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_Y);
I guess this would help sort your problem.