Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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