【问题标题】:WebDriverWait in Chrome, Selenium C#Chrome、Selenium C# 中的 WebDriverWait
【发布时间】:2015-10-06 01:30:42
【问题描述】:

我最近将我的 WebDriver 从 Firefox 更改为 ChromeDriver,而我之前用来等待元素可以交互的等待步骤不再有效”

WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); w.IgnoreExceptionTypes(typeof(StaleElementReferenceException), typeof(InvalidElementStateException)); w.Until(ExpectedConditions.ElementExists(By.Id("formSubmit")));

我现在经常收到诸如“元素在点 (964, 776) 处不可点击。其他元素会收到点击:”之类的错误,即使该元素在页面上可见。

有没有办法告诉 webdriver 等到元素可以交互,或者更好的是,我可以更改任何设置,让 Selenium 知道我正在使用 Chrome,以便我现有的代码可以工作?

【问题讨论】:

    标签: c# selenium automation webdriver selenium-chromedriver


    【解决方案1】:

    最新版本的Selenium C# Binding(2.46) 提供了一个名为ElementToBeClickable 的预期条件方法。试试那个。这是 Chrome 的一个非常常见的问题。

    【讨论】:

    • 谢谢,我已经迁移到 2.46 并且看起来已经成功了。非常感谢。
    【解决方案2】:

    方法不止于此 这是我的最爱

    try{
       //for example
               site.FindElement(By.Id("ctl00_ContentPlaceHolderBody_drp_City")).Click();
    
       }catch{
    
      Thread.Sleep(Time in sec);
               site.FindElement(By.Id("ctl00_ContentPlaceHolderBody_drp_City")).Click();
    
       }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-21
      • 1970-01-01
      • 1970-01-01
      • 2020-03-18
      • 2020-10-06
      • 2022-01-16
      • 2021-05-03
      相关资源
      最近更新 更多