I would like how to use the "not" in XPath properly. I just can't seem to get it to work with attributes.
Say I have this expression: //*[@name = 'Bob']
It is valid, and will return all nodes that have a name attribute equaling 'Bob'.
Now if I want all nodes that have a name attribute that do not equal 'Bob', I need to use an XPath such as: //*[@name not(='Bob')]
but this is invalid.
I have tried multiple combinations with not() being placed in a different order, but I can't seem to get this to work. Could someone please inform me how to use not() properly?
Also, does the order change when using elements instead of attributes? Such as: //name[text() = 'Bob']
Thanks! :)
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.
XPath is a case-sensitive language. Keywords in XPath use lowercase characters and are not reserved. Names in XPath expressions are allowed to be the same as language keywords.
XPath expressions can use comparison operators. Comparison operators compare one value to another. The resulting value is a "boolean" value. A boolean value is one that only returns either true of false.
According to : http://msdn.microsoft.com/en-us/library/ms256086.aspx, have you tried
//*[@name != 'Bob']
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