I would like to refresh a page if the loading time exceeds my expectation. So I plan to use existing function set_page_load_timeout(time_to_wait), but it turns out that call driver.get() seems not to work anymore.
I've written a simple program below and hit the problem.
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
import time
driver = webdriver.Chrome()
time.sleep(5)
driver.set_page_load_timeout(2)
try:
driver.get("https://aws.amazon.com/")
except TimeoutException as e:
print str(e)
driver.set_page_load_timeout(86400)
time.sleep(5)
print "open page"
driver.get("https://aws.amazon.com/")
print "page loaded"
The environment info:
chrome=67.0.3396.99
chromedriver=2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363),platform=Mac OS X 10.13.4 x86_64
Selenium Version: 3.12.0
or see: environment
What you are seeing is an unfortunate situation when get
/ navigation
timeouts the connection is not stable, so you can't operate well on the browser again.
The only workaround that exists as of now is to disable the pageLoadStrategy
, but then you loose lot of good perks which automatically wait for pageLoad on get
and click
operations
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
import time
from selenium.webdriver import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap["pageLoadStrategy"] = "none"
driver = webdriver.Chrome(desired_capabilities=cap)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.