Python中文
首页
教程
问答
标签
搜索
登录
注册
为什么Selenium可以使用Chrome和Firefox点击单选按钮,但在ie9上却失败了?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我使用的是python3.4和<a href="http://selenium-python.readthedocs.org/en/latest/index.html" rel="nofollow">Selenium Webdriver python bindings</a>。我在windows机器上运行。 当我使用Selenium Chrome和Firefox webdrivers时,下面的脚本可以测试我的网站。但是,当我切换到IE webdriver时,它失败了。这是我的剧本:</p> <pre><code>driver = webdriver.Ie() # Line #1 appURL = ("http://localhost:3000") driver.maximize_window() driver.get(appURL) print("Waiting for 'MyRadio' to be present") WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID,'MyRadioButtonID'))) print("'MyRadio' is present") myRadioBtn = driver.find_element_by_id("MyRadioButtonID") print("myRadioBtn = %s" % myRadioBtn) print('myRadioBtn.get_attribute("disabled") = %s' % myRadioBtn.get_attribute("disabled")) print('myRadioBtn.get_attribute("class") = %s' % myRadioBtn.get_attribute("class")) print('myRadioBtn.get_attribute("data-name") = %s' % myRadioBtn.get_attribute("data-name")) print('myRadioBtn.get_attribute("data-key") = %s' % myRadioBtn.get_attribute("data-key")) print('myRadioBtn.get_attribute("name") = %s' % myRadioBtn.get_attribute("name")) print('myRadioBtn.get_attribute("type") = %s' % myRadioBtn.get_attribute("type")) print('myRadioBtn.is_enabled() = %s' % myRadioBtn.is_enabled()) print('myRadioBtn.is_displayed() = %s' % myRadioBtn.is_displayed()) print('dir(myRadioBtn) = %s' % dir(myRadioBtn)) print("\n") print("About to click 'MyRadio'") time.sleep(3) myRadioBtn.click() # Line #28 print('myRadioBtn.get_attribute("value") = %s' % myRadioBtn.get_attribute("value")) print("Clicked 'MyRadio' 1") </code></pre> <p>正如我前面所说的,这对于Chrome和Firefox都很好。但是,当我把第1行改为“Ie”时,第28行就失败了。我安装了IE9。错误消息是<code>"ElementNotVisibleException: Message: 'Cannot click on element'"</code>这种情况100%都会发生。下面是该故障产生的输出。在</p> ^{pr2}$ <p>为什么使用Firefox和Chrome驱动程序可以点击这个单选按钮,但不能用IE?我可以清楚地看到单选按钮是可见的。手动,我可以点击它。那么硒为什么不能呢?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>Selenium Internet Explorer web驱动程序不是浏览器的本机驱动程序,在查找屏幕上的元素时经常出现问题。我怀疑这就是你的问题所在。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在乒乓球比赛中预测球的轨迹,对于AI球拍预测?
10 回答
如何在乒乓球游戏中阻止球
3 回答
如何在乘法和模中不乘空间?
1 回答
如何在乘法和除以2个不同的数字之间进行交换?
10 回答
如何在也是数据一部分的单个字符上拆分大字符串
1 回答
如何在乾草堆中找到針,有更好的解決方案嗎?
5 回答
如何在事件wxWidgets中传递自定义数据
7 回答
如何在事件中使用lambda i=i?
1 回答
如何在事件中心只接收最近的数据
6 回答
如何在事件发生之前保持云函数运行?
5 回答
如何在事件发生后使页面重定向到同一页面
9 回答
如何在事件回调之间保持python生成器的状态
10 回答
如何在事件处理程序(pythonsocket、sphinx)中保留docstring
3 回答
如何在事件处理程序中更改wxRichTextCtrl的光标位置?
7 回答
如何在事件处理程序中访问外部对象?
2 回答
如何在事件循环中将协程打包为正常函数?
5 回答
如何在事件循环之外运行协同程序?
4 回答
如何在事件循环结束时为并发未来的所有线程调用类方法?
10 回答
如何在事件文件中只保留一份摘要?
2 回答
如何在事件模板中添加事件
10 回答