Reputation: 31
I'm trying to select an option from context menu, and sendKeys(Keys.ARROW_DOWN) is not working. All it does is that it moves the scroll of the page up and down(even though context menu is still open)
Actions action = new Actions(driver);
action.contextClick(element).build().perform();
action.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.Enter).build().perform();
the sendKeys method here just moves the page up and down without taking the opened context menu into consideration.(I also tried switching to an alert) Is there another way to select an option from the context menu?
Upvotes: 2
Views: 4028
Reputation:
To navigate the context menu, you have to press the shift key AND arrow keys. Like this:
actionChains.context_click(element).send_keys(Keys.SHIFT, Keys.ARROW_DOWN, 'H')
The thing I have trouble with though is how to navigate down more than one menu item. Mine just always stops at the second item
Upvotes: 0
Reputation: 29362
try this code :
action.contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.Enter).build().perform();
Upvotes: 1