I think I've read all the Selenium timeout questions on Stack Overflow, yet neither implicit nor explicit timeout works in my Selenium webdriver 2.25 (Python 2.7 binding) and both "no_timeout_here =" lines would hang forever --
browser = webdriver.Firefox()
browser.implicitly_wait(6)
browser.set_page_load_timeout(30)
browser.get("http://www.google.com")
try:
#no_timeout_here = browser.find_element_by_id("id_not_found")
no_timeout_here = WebDriverWait(browser, 5).until(lambda browser:
browser.find_element_by_id("id_not_found"))
except:
raise
All pointers will be greatly appreciated!
Update Oct. 16th
Thanks to seleniumnewbie for your comprehensive answer, however, your unittest code still hangs on my Ubuntu 11.04 (64-bit) under Python 2.7 --
(2012/10/17 11:51:58)$ time ./timeout.py
^CTraceback (most recent call last):
...
KeyboardInterrupt
real 2m26.572s
user 0m0.368s
sys 0m0.232s
(2012/10/17 11:54:26)$ python -V
Python 2.7.2+
(2012/10/17 11:57:04)$ uname -a
Linux 3.0.0-26-generic #43-Ubuntu SMP Tue Sep 25 17:19:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
(2012/10/17 11:57:10)$ ls selenium-server-standalone-2.25.0.jar
May I know your OS/Python version?
Based on answers found here
1
I would recommend using WebDriverWait with ExpectedConditons.
Take a look at the guidance provided by Selenium Official page: http://seleniumhq.org/docs/04_webdriver_advanced.html
2
try using fluent wait in particular. The main feature is:
An implementation of the Wait interface that may have its timeout and polling interval configured on the fly. Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.
The method described returns you web element you can operate with. So the approach be the following: 1) you need to find the selectors of elements you expect to be rendered after scrolling e.g.
2) scroll down with js 3)
you can get more info about fluent wait here
UPDATE
and I get this exception, which is desired
Also note that it failed after 33 seconds, which means it waited for 30 seconds before erroring out.
When i change the implicit wait to
self.driver.implicitly_wait(15)
I get this error
If you are using Firefox 17 and Selenium 2.26.0 then you are hitting defect #4814: http://code.google.com/p/selenium/issues/detail?id=4814