I need to exclude elements from XPath
where display: none;
is set in the CSS class. The solution suggested here will not work when the given element has a CSS class in which the display: none;
is set as pointed out in this comment.
In my specific example, the element has a class named error-result with CSS set to:
.error-result {
display: none;
}
Here's the XPath I tried:
.//*[contains(text(),'XXXXXX')][not(ancestor::div[contains(@style,'display: none')])][not(descendant::div[contains(@style,'display: none')])]
The problem is, Selenium
still identifies the undesired element since display: none; is set only in CSS class.
How can I exclude such elements?
I'm using Selenium WebDriver
with Java.
Thanks