如何使用 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/