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

Viewed 59952

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

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

Try it:

SendKeys.SendWait("%+z")

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.

Related