Where is the implementation for the WebElement.isDisplayed() method in Selenium?

前端 未结 1 1765
星月不相逢
星月不相逢 2020-12-22 11:01

Where is the implementation of the WebElement.isDisplayed() method? The WebElement.java class is an interface that creates the contract for a

相关标签:
1条回答
  • 2020-12-22 11:21

    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

    0 讨论(0)
提交回复
热议问题