Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[πŸ› Bug]: isDisplayed atom does consider element with width 0px displayed as soon as a text node is belowΒ #16284

@joerg1985

Description

@joerg1985

Description

The isDisplayed atom does ignore the state of the intermediate nodes when handling the 0px width / height elements. Therefore a element is considere as displayed, even though all children of the element are not considered as displayed. This does lead to false positive isDisplayed results as soon the text node is nested inside a not visible child.

In the code below the state i correct as long as there is no text node.
Text nodes could also be added due to formatting of the source, see link so this might be a common issue.

Reproducible Code

public static void main(String[] args) throws Exception {
        ChromeDriver cd = new ChromeDriver();

        var page = "<div id='withoutTextNodeV' style='width: 0px;'><div style='visibility: hidden'></div></div>"
                + "<div id='withoutTextNodeCV' style='width: 0px;'><div style='content-visibility: hidden'></div></div>"
                + "<div id='withoutTextNodeD' style='width: 0px;'><div style='display: none'></div></div>"
                + "<div id='withTextNodeV' style='width: 0px;'><div style='visibility: hidden'>B</div></div>"
                + "<div id='withTextNodeCV' style='width: 0px;'><div style='content-visibility: hidden'>B</div></div>"
                + "<div id='withTextNodeD' style='width: 0px;'><div style='display: none'>B</div></div>";

        cd.get("data:text/html;charset=utf-8;base64,"
                + Base64.getEncoder().encodeToString(page.getBytes(StandardCharsets.UTF_8)));

        // working
        if (cd.findElement(By.id("withoutTextNodeV")).isDisplayed()) {
            throw new IllegalStateException("withoutTextNodeV");
        }
        if (cd.findElement(By.id("withoutTextNodeCV")).isDisplayed()) {
            throw new IllegalStateException("withoutTextNodeCV");
        }
        if (cd.findElement(By.id("withoutTextNodeD")).isDisplayed()) {
            throw new IllegalStateException("withoutTextNodeD");
        }
        
        // not working
        if (cd.findElement(By.id("withTextNodeV")).isDisplayed()) {
            throw new IllegalStateException("withTextNodeV");
        }
        if (cd.findElement(By.id("withTextNodeCV")).isDisplayed()) {
            throw new IllegalStateException("withTextNodeCV");
        }
        if (cd.findElement(By.id("withTextNodeD")).isDisplayed()) {
            throw new IllegalStateException("withTextNodeD");
        }

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-atomsJavaScript chunks generated by Google closureI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions