0
votes

I am not able to perform the control key press using selenium webdriver. My scenario is like press on control key, and click on one object and release the control key.

2
Show us your code - Andersson

2 Answers

0
votes

Code snippet:

Actions actions = new Actions(driver);
actions.keyDown(Keys.LEFT_CONTROL)
    .click(your_WebElement)
    .keyUp(Keys.LEFT_CONTROL)
    .build()
    .perform();
0
votes

You can also use Robot Class to key down,

new Robot().keyPress(KeyEvent.VK_CONTROL);
driver.findElement(...).click();
new Robot().keyRelease(KeyEvent.VK_CONTROL);