Even though I'm somewhat late answering the question:
You can now use WebElement.isDisplayed()
to check if an element is visible.
Note:
There are many reasons why an element could be invisible. Selenium tries cover most of them, but there are edge cases where it does not work as expected.
For example, isDisplayed()
does return false
if an element has display: none
or opacity: 0
, but at least in my test, it does not reliably detect if an element is covered by another due to CSS positioning.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…