not() XPath Function
not() is used to select elements that do NOT match a condition.
Practical Demonstration:
Locate the paragraph which doesn't have a specific id
//p[not(@id='para1')]
Locate the paragraph which doesn't have specific text
//p[not(text()='Another paragraph of text')]
Locate the paragraph which doesn't contain certain text
//p[not(contains(text(),'Another'))]
Locate the checkbox fields which are not selected
//input[@type='checkbox'][not(@checked)]
Locate the text fields which are not disabled
//input[@type='text'][not(@disabled)]
Download
0 formats
No download links available.
92. not() function in XPath Expressions (Selenium Java 2026) | NatokHD