Selenium:如何使WebDriver忽略“元素不可见"?错误? [英] Selenium: How can I make WebDriver ignore "Element is not visible" error?

查看:233
本文介绍了Selenium:如何使WebDriver忽略“元素不可见"?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium WebDriver(v2.5.0).使用driver.click(...)命令

I'm using Selenium WebDriver (v2.5.0). I get this error when I use a driver.click(...)" command

Element is not currently visible and so may not be interacted with Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:30:44' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.38-10-generic', java.version: '1.6.0_26' Driver info: driver.version: RemoteWebDriver

在浏览器中,当我将鼠标悬停在某个元素上时,被单击的元素变为可见.有什么方法可以检查是否可见?

In the browser when I mouse hover on an element, the element being clicked becomes visible. Is there any way to check whether something is visible or not?

推荐答案

您可以通过操作来实现.使用Python Webdriver客户端可以实现所需的功能,但是原理是相同的.

You can do it via actions. To achieve what you want, using the Python Webdriver client, but the principle is the same.

ActionChains(driver).move_to_element(driver.find_element(By.ID, 'Foo'))\
  .click(driver.find_element(By.Name, "Bar"))\
  .perform()

这篇关于Selenium:如何使WebDriver忽略“元素不可见"?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆