Python中文
首页
教程
问答
标签
搜索
登录
注册
使用Python控制Selenium无法使用“waits”
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我们维护一个由测试脚本使用的库来进行系统级测试。测试系统的一部分是一个网站,为了导航和与网站交互,我们使用JPype控制selenium2.0的webdriver。Selenium 2.0有一个Java和C接口,目前我们不能使用Java或C重写测试库,这就是为什么我们使用JPype来控制它。这个系统是由一个最近离开公司的人建立的,我现在正在加速。在</p> <p>每当我们与网站交互时,我们都在使用时间。睡觉公司名称:</p> <pre><code>self.browserDict['Driver'].findElement(self.browserDict['By'].id(byId)).click() time.sleep(_AJAX_TIMEOUT) >>> self.browserDict['Driver'] <jpype._jclass.org.openqa.selenium.firefox.FirefoxDriver object at 0x0626DD30> >>> byId 'login_submit' </code></pre> <p>任何时候我们点击“无”的时候时间。睡觉()等待加载下一页。我们有很多AJAX,但似乎应该有一种方法来等待AJAX完成加载。在离开之前,这个工具的作者解释说JPype或Selenium有一个问题阻止了这一点。到目前为止,我找不到这个问题,但我也不知道这里将使用的等待命令。在</p> <p><strong>编辑:</strong><br/> 一种选择是使用<a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html" rel="nofollow">implicitlyWait</a>,假设如果超时为6秒,它将在找到元素后立即返回,但是在加载页面时似乎总是等待整整6秒。在</p> <p><strong>编辑2:</strong> <a href="http://pypi.python.org/pypi/selenium" rel="nofollow">Python bindings</a>直接到selenium 2.0的版本现在已经过时了,但是似乎也没有办法等待Ajax加载完成这个库:<code>time.sleep(0.2) # Let the page load, will be added to the AP</code>(从他们的例子中)。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>隐式等待通过JPype和Java绑定工作,可以满足这里所需的需求。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
"无法将Python字节数组转换成NetworkManager / GLib的GArray_guchar"
1 回答
"无法打开包含图表的Excel文件"
1 回答
"无法找到文件/目录:尝试使用LaTeX渲染matplotlib文本"
2 回答
"无法提供0个位置参数,但给出了1个"
6 回答
"无法理解字幕"
8 回答
"无法通过webdriver+python设置浏览器偏好后抑制操作系统下载文件窗口"
2 回答
"无返回语句却仍然返回非"
3 回答
"无需使用.py扩展名分发Python脚本"
8 回答
"无需分配不必要数组的Numpy运算符结果总和"
9 回答
"日期持续时间:持续时间比较不一致?"
9 回答
"日蚀,PyDev语法着色"
1 回答
"日蚀:折叠的开放资源"
10 回答
"时间复杂度 - in运算符(包含运算符)"
10 回答
"星号 * 与 python 中的地球仪有什么关系?"
3 回答
"是否AWS Cloudwatch将两个独立维度的平均值合并在一起"
5 回答
"是否使用快捷表达式而不是三元运算符符合Python风格?"
10 回答
"是否可以在Google App Engine中增加响应超时时间?"
2 回答
"是否可以在Sublime文本中使用Bpython?"
9 回答
"是否可以将Python安装从一个Windows账户移到另一个?"
5 回答
"是否可能将NaN值单元格设置为使用SVR预测缺失值的输出?"
4 回答