Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 2 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
add comment

Your Answer

 
discard

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.