博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
selenium中implicitly_wait对is_element_present()的影响.md
阅读量:6880 次
发布时间:2019-06-27

本文共 661 字,大约阅读时间需要 2 分钟。

  hot3.png

设置了默认等待时间是30s

self.driver = webdriver.PhantomJS()self.driver.implicitly_wait(30)

然后在测试时每次点击链接前会先去查找链接元素是不是存在:

def wait_for(self, content, timeout=10):        print("in wait_for: %s" % content)        for i in range(timeout):            try:                #print(datetime.datetime.now())                if self.is_element_present(By.LINK_TEXT, content): break                #print(datetime.datetime.now())            except: pass            time.sleep(1)        else:            print("time out")            self.fail("time out")

发现链接找不到时程序会等很久才退出, 经调试发现is_element_present是会等待的,等待的时间是implicitly_wait的设置值, 加起来就是40s了

转载于:https://my.oschina.net/laofa1/blog/784656

你可能感兴趣的文章
C++文件操作(fstream)
查看>>
用main函数传参做简单的计算器的代码
查看>>
python中struct.unpack的用法
查看>>
体绘制(Volume Rendering)概述之4:光线投射算法(Ray Casting)实现流程和代码(基于CPU的实现)...
查看>>
Python实践之(七)逻辑回归(Logistic Regression)
查看>>
PAT (Advanced Level) 1107. Social Clusters (30)
查看>>
【开源社群系统研发日记五】ThinkSNS+ 是如何计算字符显示长度的
查看>>
Nodejs日志管理log4js
查看>>
Bat 脚本实现监控进程功能
查看>>
Js判断是否联网引入不同js
查看>>
pwnable.kr bof之write up
查看>>
Sql语句查询某列A相同值的另一列B最大值的数据
查看>>
技术串讲 CAS 有用
查看>>
怒学三算法 POJ 2387 Til the Cows Come Home (Bellman_Ford || Dijkstra || SPFA)
查看>>
Tensorflow学习笔记(1):tf.slice()函数使用
查看>>
ORA-01102的解决办法
查看>>
奇怪的iphone6 plus,H5调用拍照浏览器崩溃
查看>>
MVC接受JSON的一些注意事项
查看>>
response对象设置输出缓冲大小
查看>>
MVC+Ninject+三层架构+代码生成 -- 总结(七、顯示層 一)
查看>>