Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I currently have a large number of circumstances where I need to verify that a page (along with all of its elements) is displaying correctly. The isDisplayed() method of WebElement appears to be a logical way to do this, however, I would like to understand precisely what this method is doing to determine whether or not an element "is displayed". The Javadoc does not shed any light on the inner workings of the method and other information on the web appears to be sparse at best.

If anyone could provide a detailed description of how this method works, I would be very grateful.

1 Answer

0 votes
by (62.9k points)

The implementation details are specific to the driver.

But you can notice the isDisplayed method up here in RemoteWebElement.

The method looks like this:

public boolean isDisplayed() {

    Object value = execute(DriverCommand.IS_ELEMENT_DISPLAYED, ImmutableMap.of("id", id))        .getValue();

    try {

          return (Boolean) value;

    } catch (ClassCastException ex) {

      throw new WebDriverException("Returned value cannot be converted to Boolean: " + value, ex);    

   }  

}

And the line:

execute(DriverCommand.IS_ELEMENT_DISPLAYED, ImmutableMap.of("id", id))

is purely driver-specific, as each driver has its own implementation of handling this operation 

For example the SafariDriver, which works with extensions, therefore you'll find the implementation on the extension side.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...