我想刷新一个页面,如果加载时间超过我的预期。所以我计划使用现有的函数set_page_load_timeout(time_to_wait),但结果是调用驱动程序。获取()似乎不起作用了。在
我在下面写了一个简单的程序并解决了这个问题。在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"
环境信息:
铬=67.0.3396.99
chromedriver=2.40.565386(45a059dc425e08165f9a10324bd1380cc13ca363),平台=Mac OS X 10.13.4 x86_64
Selenium版本:3.12.0