Please help to use the logical OR operator in XPATH and select one request from these two:
1) .//span[@class=\'fob12\']
2) .//p[@class=\'fob12\']
They differ in tag only.
Using OR & AND It is also applicable if any one condition is true, or maybe both. This means that any one condition should be true to find the element. In the below XPath expression, it identifies the elements whose single or both conditions are true.
XPath text() function is a built-in function of the Selenium web driver that locates items based on their text. It aids in the identification of certain text elements as well as the location of those components within a set of text nodes. The elements that need to be found should be in string format.
The | character denotes the XPath union operator. You can use the union operator in any case when you want the union of the nodes selected by several XPath expressions to be returned.
One more (with the OR as requested):
".//*[(self::p or self::span) and @class = 'fob12']"
You want the union expression which is |
, so the XPath would be:
.//span[@class="fob12"] | .//p[@class="fob12"]
I might be missing something, but the following should just work!?
.//span[@class=\'fob12\'] | .//p[@class=\'fob12\']
I would write it as .//(p|span)[@class='fob12']
. But I think that needs XPath 2.0 IIRC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With