【发布时间】:2017-06-21 17:38:30
【问题描述】:
我正在尝试使用 Selenium Webdriver 右键单击页面,然后导航上下文菜单。该脚本应打开一个右键菜单,并导航向上 2 个选项,然后使用 Return 键选择...
driver.Navigate().GoToUrl("http://www.google.com");
//Google search bar
IWebElement tb = driver.FindElement(By.Id("lst-ib"));
Actions action = new Actions(driver);
//Right Clicks outside of the search bar.
action.MoveToElement(tb, -5, -5).ContextClick().Perform();
action.SendKeys(Keys.Up).SendKeys(Keys.Up).SendKeys(Keys.Return).Perform();
按原样执行右键单击(在搜索栏之外),但此后,没有任何证据表明按下了向上箭头,并且没有使用 Return 键选择任何内容。菜单选项应在滚动时突出显示。
我正在使用最新版本的 ChromeDriver 2.30 和 Chrome 59.0.3071.109
【问题讨论】:
-
这是 ChromeDriver 中的一个已知问题,我建议改用 FirefoxDriver:bugs.chromium.org/p/chromedriver/issues/detail?id=1003
-
谢谢,我相信是这种情况,因为我无法完成其他操作。使用修饰键 (ctrl+m) 作为打开扩展程序的快捷方式比使用上下文菜单更容易,但这也不起作用……我想我会尝试使用 firefox 并等待修复。跨度>
标签: selenium selenium-webdriver