September 28, 2015

isDisplayed vs isEnabled

In this post i will  show you the difference between isDisplayed() and isEnabled()


isDisplayed

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

Method used to verify presence of a web element within the webpage. The method is designed to result a Boolean value with each success and failure. The method returns a “true” value if the specified web element is present on the web page and a “false” value if the web element is not present on the web page.


isEnabled

boolean isEnabled()
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
Returns:
True if the element is enabled, false otherwise.

Reference :  https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#isEnabled()
Method used to verify if the web element is enabled or disabled within the webpage. Like isDisplayed() method, it is designed to result a Boolean value with each success and failure. The method returns a “true” value if the specified web element is enabled on the web page and a “false” value if the web element is not enabled (state of being disabled) on the web page






After Executing code :







Below is the Code:





2 comments: