java - isDisplayed() 与 Selenium 中的 isVisible()

标签 java selenium selenium-webdriver webdriver

Selenium 中的isDisplayed()isVisible() 方法有什么区别?两者都用于识别网页元素是否隐藏在网页中。

最佳答案

简而言之,isVisible 是旧版 Selenium RC 的方法,isDisplayed 是 Selenium 2 的方法。

如果你在谈论WebDrivers WebElement ,它仅包含 isDisplayed() 方法,该方法由文档提供:

Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.

在 webdriver 之前我们有 Selenium RC,现在已经弃用了很长时间,DefaultSelenium 类有 isVisible() 方法:

Determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present.

reference

关于java - isDisplayed() 与 Selenium 中的 isVisible(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34380119/

相关文章:

java - JSoup 不加载整个 HTML

eclipse - Selenium Webdriver 关于 destroyHarder 的错误

Python selenium lib 未在 Windows 上安装

java - Selenium WebDriver 上传文件/关闭资源管理器窗口

java - 具有 nativeEvents 的 InternetExplorer Webdriver

java - 有没有一种方法可以测量执行 SQL 查询所花费的时间而不用 Java 获取结果?

java - Eclipse 插件开发。我可以在我的插件中使用现有的 jar 文件吗?

java - 如何防止 JTable 单元格开始编辑某些击键?

python : selenium click on submit no redirect

python-3.x - 如何查看加载失败的页面? ( Selenium 。Python)