栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何设置pythonselenium3.8.0的'driver.get'超时?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何设置pythonselenium3.8.0的'driver.get'超时?

为设置

time out
Page Loading
可以诱导
set_page_load_timeout(seconds)


set_page_load_timeout


方法细节

def set_page_load_timeout(self, time_to_wait):    """    Set the amount of time to wait for a page load to complete    before throwing an error.

精氨酸

time_to_wait: The amount of time to wait

用法

driver.set_page_load_timeout(3)

from selenium import webdriverfrom selenium.common.exceptions import TimeoutExceptiondriver = webdriver.Chrome(executable_path=r'C:UtilityBrowserDriverschromedriver.exe')driver.set_page_load_timeout(2)try :    driver.get("https://www.booking.com/hotel/in/the-taj-mahal-palace-tower.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaGyIAQGYATG4AQbIAQzYAQHoAQH4AQKSAgF5qAID;sid=338ad58d8e83c71e6aa78c67a2996616;dest_id=-2092174;dest_type=city;dist=0;group_adults=2;hip_dst=1;hpos=1;room1=A%2CA;sb_price_type=total;srfid=ccd41231d2f37b82d695970f081412152a59586aX1;srpvid=c71751e539ea01ce;type=total;ucfs=1&#hotelTmpl")    print("URL successfully Accessed")    driver.quit()except TimeoutException as e:    print("Page load Timeout Occured. Quiting !!!")    driver.quit()

控制台输出

Page load Timeout Occured. Quiting !!!

文献资料

您可以在

pageLoadTimeout
此处找到详细的讨论
pageLoadTimeout in Selenium notworking


深潜

按照Python,

3.x
如果我们不处理异常,则会观察到以下日志消息:

    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message: timeout  (Session info: chrome=62.0.3202.94)  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.2.9200 x86_64)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/568913.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号