I want to get the closest ancestor WebElementwith some attribute.
For instance:
<div>
<i value1= "hello">
<a value1 = "bye">
<div id="2"> Hello </div></a></i></div>
I have WebElmentin Jave, which representsdiv (id="2")
How can I get the closest parent that has an attribute value1?
In this case, I would get item ac value1="bye".
I try the following: divElement.findElement(By.xpath("/ancestor-or-self::*[@value1]"));but this will not work.
source
share