Search code examples
pythonseleniumselenium-webdriverpython-bindings

In Python - Selenium2 how to set the time for which a webdriver instance should wait,when loading a page,before giving a timeout exception?


I tried it by instantiating a webdriver using the time out as the third parameter as shown below:

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

and then used the driver to fetch a web page like so

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

However it waits indefinitely for the page to load. Also tried out WebDriverWait(self.driver, 3) where self.driver is a webdriver instance, but to no avail.

OS-Windows Vista ; Python 2.7 ; Selenium2 ; Python-Selenium bindings 2.8

Any ideas?

EDIT: Seems that it doesn't exist for python and a request for the same has already been put in


Solution

  • The WebDriverWait should be used like:

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

    Please refer to: http://seleniumhq.org/docs/03_webdriver.html