版权声明: https://blog.csdn.net/weixin_41357300/article/details/85693607
如何设置页面加载超时时间,robotframework+selenium实现,设置浏览器的超时时间,自身加载页面的超时时间
有些测试,使用的方法是如下场景,例如:
访问google超时,由于无法访问,想在10秒内退出,要不然可能登登上1分钟以上
我们想加快这个进度,使用selenium的 set_page_load_timeout()就可以了
但是robotframe的selenium库没有这个方法
所以需要自己添加一下
\Lib\site-packages\SeleniumLibrary\keywords\browsermanagement.py
模仿set_selenium_timeout 做一个set_page_timeout,调用的是set_page_load_timeout
def set_page_timeout(self, value):
old_timeout = self.get_selenium_timeout()
self.ctx.timeout = timestr_to_secs(value)
for driver in self.drivers.active_drivers:
driver.set_page_load_timeout(self.ctx.timeout)
return old_timeout
第二个方法,直接改open brower
drvier.set_page_load_timeout()
driver.get(url)