如何使用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();