[Tutor] How to get Selenium to wait for page load
mhysnm1964 at gmail.com
mhysnm1964 at gmail.com
Thu Jan 31 05:22:39 EST 2019
Hi all,
I have found an excellent article on identifying stale elements. The issue
is when I try and use their example code. I get a failure where for_wait is
not defined.
http://www.obeythetestinggoat.com/how-to-get-selenium-to-wait-for-page-load-
after-a-click.html
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
NameError: name 'wait_for' is not defined
>>>
When I look through the examples. I only find one reference for the above
function. But it doesn't look correct and I am confused. The author
indicates the definition of the function is half way up the page. As I
cannot see, this reference doesn't help. So can someone help and provide the
definition for this method/function?
The code which generated the error:
rows = []
pageNav = browser.find_element_by_id("center-5")
curr_page = pageNav.find_element_by_css_selector('span
.pageNumberElement').text
prev_page = ""
while prev_page in curr_page:
# wait_for(link_has_gone_stale):
prev_page = curr_page
rows.extend(tableNavigation (pageNav))
if wait_for(link_has_gone_stale):
pageNav = browser.find_element_by_id("center-5")
curr_page = pageNav.find_element_by_css_selector('span
.pageNumberElement').text
if prev_page == curr_page:
print ("Page no has not changed:",curr_page)
else:
prev_page = curr_page
More information about the Tutor
mailing list