What is the difference between isDisplayed()
and isVisible()
methods in Selenium? Both are used to identify whether web element is or is not hidden in web page.
3 Answers
Short answer is that isVisible
is method of old Selenium RC
and isDisplayed
is method of Selenium 2.
If you are talking about WebDrivers
WebElement
, it contains only isDisplayed()
method, which by the doc:
Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
Before webdriver we had Selenium RC, which is now long deprecated, the DefaultSelenium
class had isVisible()
method that:
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.
As explained in this post How does Selenium WebDriver's isDisplayed() method work
WebDriver has its own W3C specification. and the section about determining visibility can give you more information from the spec.
Selenium RC - isVisible() - looks for display: none style tag - this might throw a null pointer if we aren't careful...thus to see if an element is visible first check if the element is present using isElementPresent() method. Then try checking if the element is visible! Refer Difference between isElementPresent and isVisible in Selenium RC

- 1
- 1

- 4,506
- 4
- 34
- 48
-
1You are mixing up `webdriver` and `selenium rc` – Erki M. Dec 20 '15 at 21:00
-
Thank you @ErkiM. for correcting my understanding too. – parishodak Dec 21 '15 at 01:33
As per the current release of Selenium v3.141.59 and it's documentation of WebElement Interface the method isVisible()
seems no more supported and must have been deprecated.
Where as isDisplayed()
is pretty much well suported and very much in practice.
boolean isDisplayed()
Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
Returns:
Whether or not the element is displayed
This function is typically exposed to GET
requests with a URI Template of:
/session/{session id}/element/{element id}/displayed

- 183,867
- 41
- 278
- 352