加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何使用selenium webdriver上的鼠标来查看隐藏的菜单而不

发布时间:2020-12-15 03:56:43 所属栏目:百科 来源:网络整理
导读:如何使用selenium webdriver鼠标悬停/覆盖查看隐藏菜单而不执行任何鼠标点击? 网站上有一个隐藏的菜单,我正在测试,只出现在鼠标悬停/结束. 注意:如果执行任何点击,页面被重定向,所以请建议一个解决方案,而不需要点击 我试过了: IWebDriver driver = new F
如何使用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();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读