not() is a function in XPath (as opposed to an operator), so
//a[not(contains(@id, 'xx'))]
41
votes
you can use not(expression) function
or
expression != true()
17
votes
None of these answers worked for me for python. I solved by this
a[not(@id='XX')]
Also you can use or condition in your xpath by | operator. Such as
a[not(@id='XX')]|a[not(@class='YY')]
Sometimes we want element which has no class. So you can do like
a[not(@class)]
1
votes
Use boolean function like below:
//a[(contains(@id, 'xx'))=false]
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more