0

Where is the implementation of the WebElement.isDisplayed() method? The WebElement.java class is an interface that creates the contract for a isDisplayed() method but I cannot find source code that shows how it works. Does anyone know how I can find it? I know about dom.js and I can see how all the methods in ExpectedConditions.java all work, but I can't find the source code implementation (in Java) of what we call element.isDisplayed() .

I think that to truly understand how ExpectedConditions works, I need to know the workings of the underlying isDisplayed() method. I can't figure out how it eventually calls the bot.dom.isInteractable method in dom.js .

djangofan
  • 28,471
  • 61
  • 196
  • 289

1 Answers1

4

The implementation details are specific to the driver.

But you can find the isDisplayed method over here in RemoteWebElement. All WebElement methods are been implemented over here.

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 IS_ELEMENT_DISPLAYED.

For example the SafariDriver, which works with extensions, hence you can find the implementation on the extension side, which can be found here

Ant's
  • 13,545
  • 27
  • 98
  • 148