|
22 | 22 |
|
23 | 23 | import java.io.File; |
24 | 24 | import java.io.IOException; |
| 25 | +import java.util.ArrayList; |
25 | 26 | import java.util.Arrays; |
26 | 27 | import java.util.List; |
27 | 28 | import java.util.Map; |
28 | 29 | import java.util.stream.Collectors; |
| 30 | +import java.util.stream.Stream; |
| 31 | + |
29 | 32 | import org.openqa.selenium.Beta; |
30 | 33 | import org.openqa.selenium.By; |
31 | 34 | import org.openqa.selenium.Dimension; |
@@ -279,7 +282,34 @@ public WebDriver getWrappedDriver() { |
279 | 282 |
|
280 | 283 | @Override |
281 | 284 | public boolean isDisplayed() { |
282 | | - Object value = execute(DriverCommand.IS_ELEMENT_DISPLAYED(id)).getValue(); |
| 285 | + // String script = "return arguments[0].checkVisibility({ visibilityProperty: true, opacityProperty: true });" |
| 286 | + String script = "const visibility = arguments[0].checkVisibility({ visibilityProperty: true, opacityProperty: true, contentVisibilityAuto: true });\n" |
| 287 | + + "if (visibility) {\n" |
| 288 | + + " const style = getComputedStyle(arguments[0]);\n" |
| 289 | + + " if (style.getPropertyValue('position') !== 'absolute') {\n" |
| 290 | + + " let parentElement = arguments[0].parentElement;\n" |
| 291 | + + " while (parentElement) {\n" |
| 292 | + + " const parentStyle = getComputedStyle(parentElement);\n" |
| 293 | + + " const parentOverflowX = parentStyle.getPropertyValue('overflow-x');\n" |
| 294 | + + " const parentOverflowY = parentStyle.getPropertyValue('overflow-y');\n" |
| 295 | + + " if (parentOverflowX === 'hidden' && parentOverflowY === 'hidden') {\n" |
| 296 | + + " return !(arguments[0].offsetLeft - parentElement.offsetLeft > parentElement.offsetWidth ||\n" |
| 297 | + + " arguments[0].offsetTop - parentElement.offsetTop > parentElement.offsetHeight);\n" |
| 298 | + + " }\n" |
| 299 | + + " if (parentOverflowX === 'hidden') {\n" |
| 300 | + + " return !(arguments[0].offsetLeft - parentElement.offsetLeft > parentElement.offsetWidth);\n" |
| 301 | + + " }\n" |
| 302 | + + " if (parentOverflowY === 'hidden') {\n" |
| 303 | + + " return !(arguments[0].offsetTop - parentElement.offsetTop > parentElement.offsetHeight);\n" |
| 304 | + + " }\n" |
| 305 | + + " parentElement = parentElement.parentElement;\n" |
| 306 | + + " }\n" |
| 307 | + + " }\n" |
| 308 | + + "}\n" |
| 309 | + + "return visibility;"; |
| 310 | + Object value = parent.executeScript(script, this); |
| 311 | + |
| 312 | + // Object value = execute(DriverCommand.IS_ELEMENT_DISPLAYED(id)).getValue(); |
283 | 313 | try { |
284 | 314 | // See https://github.com/SeleniumHQ/selenium/issues/9266 |
285 | 315 | if (value == null) { |
|
0 commit comments