Selecting an anchor link with content, such as <a>test link</a>, I can see three different ways to do it using XPath:

a[text()="test link"]
a[.="test link"]
a[contains(text(), "test link")]

What are the differences between the three? The last option appears that it would take longer by virtue of it being an extension of the first.

1 Answer 1


You can find an Xpath specification here. Your first xpath matches an anchor that contains exactly the string "test link". The last xpath matches an anchor whose contents includes the substring "test link". No doubt it is slower, but the depending on the circumstances, the performance difference may be insignificant.

As far as I can tell, the first and second xpaths are equivalent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.