For example: To find a link with text "click me" the Xpath is //a[text()='click me'.

What should be the equivalent in cssSelector which will be used to identify the same element in firebug and firepath? a[text='click me'] is unable to find the same element.

Please help

  • show us the whole HTML, and your xpath expression is incomplete.
    – Yu Zhang
    Nov 21 '16 at 9:31
  • I have never seen an element with text as its property, did you mean innerText?
    – Yu Zhang
    Nov 21 '16 at 9:32
  • Your xpath should be //a[text()='click me'] and please share HTML also.
    – Sagar007
    Dec 21 '16 at 13:22

In CSS and Xpath elements can be find using their attributes like the following:

 CSS : tagname[attribute='text']
 CSS : tagname[innerText=’text’] or tagname[textContent=’text’]
 Xpath: tagname[@attribute='value']

For any other browser(except FireFox) you can use tagname[innerText=’text’] i.e a[innerText='linkname']

For Firefox you can use tagname[textContent=’text’] i.e, a[textContent='linkname']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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