I have this line of code:
final WebElement button = driver.findElement(By.tagName("button"));
Now, how do I click on this button with the meta key pressed?
According to Madd0g, Java code would look like this:
Actions shiftClick = new Actions(driver); shiftClick.keyDown(Keys.SHIFT).click(element).keyUp(Keys.SHIFT).perform();
hmm .. I'm not quite sure about java, but in C # this is done using ActionBuilder -
new Actions(Browser).KeyDown(Keys.Shift).Click(element).KeyUp(Keys.Shift).Perform();
Found. http://code.google.com/p/selenium/wiki/AdvancedUserInteractions .
final WebElement button = driver.findElement(By.id("button")); Actions actions = new Actions(driver); if (ctrlKey) { actions = actions.keyDown(Keys.CONTROL); } if (altKey) { actions = actions.keyDown(Keys.ALT); } if (shiftKey) { actions = actions.keyDown(Keys.SHIFT); } actions = actions.click(button);
Now, if only it really worked.