I am using selenium with Firefox driver (geckodriver) to get some page source from a list of urls.
I notice that if the Internet is slow, FireFox does not wait until the page is fully loaded (the execution does not wait at line 5). As a result, the page_source in line 9 is actually from the previous url.
How can I make Firefox to wait for the page to fully load?
Selenium: 3.14.1
Geckodriver: 0.23.0 linux64
1 browser = webdriver.Firefox()
2
3 for url in url_list:
4
5 browser.get(url)
6
7 sleep(1)
8
9 page_source = browser.page_source
10
11 if html == page_source:
12
13 print "error: page not fully loaded"
14
15 exit(1)
16 html = page_source
Update: I have tested with Chrome driver. Chrome driver does wait until the page is fully loaded. So maybe the issue is with FireFox driver.