Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98787

Is it possible to have visible element without height and width?

$
0
0

I've been going through existing Selenium automation framework where it has a code which checks for width and height of an element. If they have positive values only then it will be interactable like click, double click etc.

public boolean isElementInteractable(WebElement element) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    String offsetWidth = js.executeScript("return arguments[0].offsetWidth;", element).toString();
    String offsetHeight = js.executeScript("return arguments[0].offsetHeight;", element).toString();

    if ((Integer.parseInt(offsetWidth) != 0 && Integer.parseInt(offsetHeight) != 0) && element.isDisplayed()) {
        return true;
    }
    return false;
}

In my understand, every element which is visible/interactable has positive height and width. I'm confused why this code has been written.

Could you please confirm if my understanding is correct? If not, please help me to understand the cases where this is possible.


Viewing all articles
Browse latest Browse all 98787

Trending Articles