[Tutor] How to get Selenium to wait for page load

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Fri Feb 1 16:27:55 EST 2019


Everyone,

 

Thanks for the pointers. 

 

From: George Fischhof <george at fischhof.hu> 
Sent: Saturday, 2 February 2019 2:42 AM
To: mhysnm1964 at gmail.com
Cc: tutor at python.org
Subject: Re: [Tutor] How to get Selenium to wait for page load

 

 

<mhysnm1964 at gmail.com <mailto:mhysnm1964 at gmail.com> > ezt írta (időpont: 2019. jan. 31., Cs 12:07):

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- <http://www.obeythetestinggoat.com/how-to-get-selenium-to-wait-for-page-load-after-a-click.html> 
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





_______________________________________________
Tutor maillist  -  Tutor at python.org <mailto:Tutor at python.org> 
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

 

 

Hi, 

 

Try splinter package.

That is an abstraction layer over selenium, and exactly does similar things.

 

__george__

 



More information about the Tutor mailing list