I am writing Webdriver automation for an app that uses the following construction:
<html>
<body>
<div style="display:block">
<div class="textDiv">One</div>
</div>
<div style="display:none">
<div class="textDiv">Two</div>
</div>
<div style="display:none">
<div class="textDiv">Three</div>
</div>
</body>
</html>
I need a way to find the textDiv which is visible. I have tried the following:
- isDisplayed(). This is not sufficient, because the textDiv element which has a parent with display:block may be off the screen.
- getCssValue('visibility'). This is not working, as all textDivs return a visibility of 'visible'.
- getCssValue('display'). This is not working, as all textDivs return a display of 'block'.
- getAttribute('style'). This is not working, as all textDivs return a style of 'null'.
Basically, is there another way within Webdriver to determine whether an element is or is not displayed because of a style applied to a parent element?
Please note that this is a simplified example, and that the div whose display is set to none may not be the immediate parent of the element.