c# - 如何使用 selenium webdriver 将鼠标悬停在不执行任何鼠标单击的情况下查看隐藏菜单?

标签 c# selenium-webdriver automated-tests

如何使用 selenium webdriver 将鼠标悬停/悬停在上面以查看隐藏菜单而不执行任何鼠标单击?

我正在测试的网站上有一个隐藏菜单,仅在鼠标悬停/悬停时出现。 注意:如果执行任何点击,页面将被重定向,因此请建议一个不点击的解决方案

我尝试过:

IWebDriver driver = new FirefoxDriver()
Actions builder = new Actions(driver)
builder.MoveToElement(driver.FindElement(By.Id("Content_AdvertiserMenu1_LeadsBtn")))
       .Click().Build().Perform();

最佳答案

试试这个?

// this makes sure the element is visible before you try to do anything
// for slow loading pages
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
var element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(elementId)));

Actions action  = new Actions(driver);
action.MoveToElement(element).Perform();

关于c# - 如何使用 selenium webdriver 将鼠标悬停在不执行任何鼠标单击的情况下查看隐藏菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20355515/

相关文章:

python - 如何在 ubuntu 16.04 上为 python3 selenium 安装 firefoxdriver webdriver?

python - 接收属性错误 'FirefoxBinary'对象没有属性 '_get_firefox_output'

python - 如何使用 Selenium Python 从 XML URL 中按 tagName 提取元素

java - Selenium 动态生长表

c# - .NET:如何对通用词典进行排序?

c# - 如何让 ConfigurationManager 从多个文件加载应用程序设置?

c# - 函数的协变分配需要显式参数

c# - 根据字符串值搜索 int 列

Selenium 教程

typescript - 函数参数中的模板插值导致 TS2554 :Expected 1 arguments, 但得到 2