How to press (down arrow +shift key) button using selenium WebDriver? I need to select options from multi Select box. For that i need to know how to press both keys together. Please help. Thanks.
Asked
Active
Viewed 4,751 times
-3
-
You should make some investigation and try to do it yourself. If you fail, provide your code and we'll try to help you. At least show `HTML` for target select box and programming language you use – Andersson Oct 18 '16 at 07:44
-
Possible duplicate of [How to press Ctrl+A to select all content in a page by Selenium WebDriver using Java](http://stackoverflow.com/questions/11578768/how-to-press-ctrla-to-select-all-content-in-a-page-by-selenium-webdriver-using) – Grasshopper Oct 18 '16 at 07:45
2 Answers
0
Here is a really simple example:
import org.openqa.selenium.Keys;
String multiSelect = Keys.chord(Keys.SHIFT, Keys.DOWN);
driver.findElement(By.xpath("//xpath")).sendKeys(multiSelect);
You can do it of course in other combinations, too.

Philipp Palmtag
- 1,310
- 2
- 16
- 18

Arno Don Calzone
- 53
- 7
-1
Using the Robot class in Java you can perform like shown below
Robot robot=new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
//This will press shift key on keyboard.
robot.keyPress(KeyEvent.VK_DOWN);
//This will press the down key on your numpad.
robot.keyRelease(KeyEvent.VK_DOWN);
//This will release the down key on your numpad.
robot.keyRelease(KeyEvent.VK_SHIFT);
//This will release the shift key.
-
Actually, `selenium` has `Action Chains` module (http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.action_chains for `Python`) that allow to perform clicking multiple buttons simultaneously – Andersson Oct 18 '16 at 08:40