java - Selenium 悬停代码适用于 Chrome 而不是 Edge
问题描述
public void Hover()
{
Actions action = new Actions(BrowserWindow.Instance.Driver);
action.MoveToElement(WebElement).Perform();
}
这在 Chrome 中有效。不是边缘。我已与开发人员确认我“悬停”在正确的元素上。
WebElement elem = yourWebDriverInstance.findElement(By.xpath("//*[@class='goog-menu goog-menu-vertical uploadmenu density-tiny']/input"));
String js = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";
((JavascriptExecutor) yourWebDriverInstance).executeScript(js, elem);
这也失败了。有人知道我做错了什么吗?
更多信息。
这在 Firefox 上也失败了。我看到一篇关于过时的硒驱动程序的文章。我刚刚安装了 geckodriver 并将 Edge 驱动程序设置为根据文档自动更新。我不相信我有过时的驱动程序。
更多信息采取 2
调用代码是
public static void DoCloseActiveTabEntire()
{
Element tab = new Element(byTab);
tab.Hover();
// CLose button is not clickable. Cannot use standard BUTTON for find
Button close = new Button(byClosePanelButton);
close.Click();
}
如果我在按钮关闭处设置断点......在悬停尝试之后,我注意到将鼠标移到“选项卡”上也不会导致按钮可见。
解决方案
这很奇怪。但是更换
action.MoveToElement(WebElement).Perform();
和
action.MoveToElement(WebElement).Build().Perform();
它有效。我读到Build内置于Perform中。但我有点只是在拍它,希望有什么东西掉出来。它奏效了。
推荐阅读
- javascript - 快速子域的路由
- html - 如何更改选择中悬停选项的背景颜色和文本?
- airflow - Apache Airflow 任务超时
- python - 从 PubMed find_element_by_css_selector VS visibility_of_all_elements_located 中抓取文本
- javascript - 我可以将对象数组存储在具有相同属性的本地存储中吗?即使我在 JavaScript 中刷新页面,它也会保留下来?
- android - 错误:无法在项目中找到模块“XXXXX”
- mongodb - 将所有对象合并到一个组中并保留所有先前的字段
- selenium-chromedriver - 如何在 chromedriver 中手动验证假视频流
- java - 无法从 Java Spring Boot 项目中的 application.yml 文件中读取用户定义类的列表
- r - 如何计算每列(按组)中满足 R 中特定条件的行数