-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Open
Labels
B-atomsJavaScript chunks generated by Google closureJavaScript chunks generated by Google closureI-defectSomething is not working as intendedSomething is not working as intended
Description
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
Labels
B-atomsJavaScript chunks generated by Google closureJavaScript chunks generated by Google closureI-defectSomething is not working as intendedSomething is not working as intended