【问题标题】:In Python - Selenium2 how to set the time for which a webdriver instance should wait,when loading a page,before giving a timeout exception?在 Python - Selenium2 中,如何设置 webdriver 实例在加载页面时应该等待的时间,然后再给出超时异常?
【发布时间】:2012-01-10 11:36:08
【问题描述】:

我通过使用超时作为第三个参数来实例化一个 webdriver 来尝试它,如下所示:

self.driver = webdriver.Firefox(None, None, 5)

然后使用驱动程序来获取这样的网页

self.driver.get("http://www.google.com")

但是它会无限期地等待页面加载。 还尝试了 WebDriverWait(self.driver, 3) 其中 self.driver 是一个 webdriver 实例,但无济于事。

操作系统-Windows Vista;蟒蛇2.7;硒2; Python-Selenium 绑定 2.8

有什么想法吗?

编辑:似乎它不存在于 python 并且已经有相同的请求put in

【问题讨论】:

    标签: python selenium selenium-webdriver python-bindings


    【解决方案1】:

    WebDriverWait 应该像这样使用:

    WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!"))
    

    请参考:http://seleniumhq.org/docs/03_webdriver.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-11
      相关资源
      最近更新 更多