Reputation: 7563
First, I'm familiar with or
logic like this:
//*[@id='a' or @id='b']
But how to write the xpath if one of them having node (child, preceding, etc) like this:
//*[@id='a']//*[@id='aa'] or //*[@id='b']
The above return as invalid xpath.
I struggled to search on this forum but it was a bit difficult to find the right keywords.
How to write the correct xpath for the above issue?
Just simple snippet to get 2 result like the above explanation:
<div id="a">
<div id="aa"></div> --target
<div id="aaa"></div>
<div id="aaaa"></div>
</div>
<div id="b"></div> --target
<div id="c"></div>
Upvotes: 1
Views: 59
Reputation: 4869
//*[@id='a']//*[@id='aa'] or //*[@id='b']
This XPath is not invalid - it returns boolean (true or false). But tools like Selenium might not support this syntax. I guess you need
//*[@id='a']//*[@id='aa'] | //*[@id='b']
Upvotes: 2