【问题标题】:Default Selenium Chrome WebDriver Page load timeout默认 Selenium Chrome WebDriver 页面加载超时
【发布时间】:2015-02-10 21:25:42
【问题描述】:

我正在尝试使用 Selenium chrome webdriver 加载页面, 但是获得硒的超时错误

渲染器超时:3000

这是在页面加载之前等待的默认超时时间。

我正在使用 groovy selenium 来处理 chrome。 一切顺利。只有超时错误有时会导致问题。

有人知道什么是 Chrome SELENIUM WEBDRIVER 中页面加载的默认超时时间??

我可以更改那个超时时间吗?

如果是怎么办?

我目前在 GROOVY 中使用 selenium chrome driver v2.9 chrome v.27。

【问题讨论】:

    标签: selenium selenium-webdriver timeout pageload


    【解决方案1】:

    你见过documentation吗?

    隐式等待是告诉 WebDriver 在尝试查找一个或多个元素(如果它们不是立即可用的)时轮询 DOM 一段时间。默认设置为 0。

    【讨论】:

      【解决方案2】:

      我一直在使用 Python 尝试 Chrome、Firefox 和 PhantomJS。 我一直在搜寻大量网页,试图找到使用带有工作负载页面超时的无头 Web 驱动程序的答案。 各种答案之间存在很多混淆。 我将在此页面上发布我的发现,因为它在诸如“selenium chrome timeout”之类的搜索中排名靠前。

      我现在可以让 chromedriver.exe 超时工作。 硒包装器似乎坏了,但以下工作符合我的要求。而不是调用:

      chrome_driver.set_page_load_timeout(my_timeout_secs)
      chrome_driver.get( ...... )
      

      使用:

      chrome_driver.execute(Command.SET_TIMEOUTS, {
                  'ms': float(my_timeout_secs * 1000),
                  'type': 'page load'})
      chrome_driver.get( ...... )
      

      这会绕过 selenium 包装器并使用 Chrome 设置超时。 然后只需使用标准的 Selenium 捕获。该页面将超时,然后在 Chrome 从 selenium.common.exceptions

      引发 TimeoutException 后点击您的代码
      try:
          ... set_timeout ...
          ... get url ...
      
      except TimeoutException as e:
      
          # do whatever you need to here
      

      希望对需要无头驱动程序超时的任何人有所帮助。

      谢谢, 刘杰华

      【讨论】:

      • 感谢您的提示!我终于在 python 中为 Chrome webdriver 工作了!它对我有用的是在调用chrome_driver.get()之前调用函数chrome_driver.set_page_load_timout()
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-02
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      相关资源
      最近更新 更多