[英]Choosing an Option from a Browser Context Menu
I'm attempting to write a method that will choose a specific option from the context menu of a browser. 我正在尝试编写一种将从浏览器的上下文菜单中选择特定选项的方法。 All of my research has led me to the solution of doing something like this:
我所有的研究使我找到了执行以下操作的解决方案:
var action = new Actions(driver);
action.ContextClick(element);
action.SendKeys(Keys.ArrowDown).SendKeys(Keys.ArrowDown);
action.SendKeys(Keys.Enter);
action.Build().Perform();
However this does not seem to be working for me. 但是,这似乎不适用于我。 Ideally I'd be able to choose which option to select based on the name or something similar, but the ability to just choose "option 2" or something like that would work as well.
理想情况下,我可以根据名称或类似名称选择要选择的选项,但是只选择“选项2”或类似选项的功能也可以使用。
You will not be able to fo it untill you will not perform complex ( or chained) actions ( http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html ) and will look like that: 您将无法执行此操作,直到您不执行复杂的(或连锁的)操作( http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html )看起来像这样:
Actions actions = new Actions(driver);
actions.moveToElement(linkFilms).click(cssElement).perform();
The thing is you shoud not ending interacting with a page, otherwise menu focus will disappear. 问题是您不应该结束与页面的交互,否则菜单焦点将消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.