简体   繁体   English

从浏览器上下文菜单中选择一个选项

[英]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.

相关问题 在ListView的上下文菜单中,选择一个项目 - Context Menu in ListView, choosing an Item 从浏览器上下文菜单中选择项目 - Select item from the browser context menu 发布选项已从VS2017的上下文菜单中删除 - Publish option is gone from context menu in VS2017 如何从上下文菜单中的选项调用longlistselector事件 - How to call a longlistselector event from an option in context menu 从DialogResult中选择选项时出错 - An error while choosing option from DialogResult VS2010中文件夹上下文菜单中缺少“包含在项目中”选项 - “Include in Project” option missing from folder context menu in VS2010 选择两个文件时,从右键单击 Windows 上下文菜单中隐藏选项 - Hide an option from right click Windows context menu when two files are selected Visual Studio 2017 中的文件夹上下文菜单中缺少“包含在项目中”选项 - “Include in Project” option missing from folder context menu in Visual Studio 2017 WPF浏览器控件上下文菜单命令禁用 - WPF Browser Control Context menu commands disable 如何在CefSharp chrome浏览器中禁用上下文菜单 - How to disable context menu in CefSharp chromium browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM