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