I am trying to automate one of site and the below are the HTML code for same:

<a href="http://register.rediff.com/register/register.php?FormName=user_details">Create a Rediffmail account</a>

I want to construct XPath for "Create a Rediffmail account" hyperkink

When I construct XPath so it will display 2 match element:


There are two match element for above link how can I click only "Create a Rediffmail account" hyperlink?

closed as off-topic by Michael Durrant, NarendraC, Kate Paulk, IAmMilinPatel, Bharat Mane Dec 16 '16 at 13:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development unrelated to testing are off-topic here, but can be asked on Stack Overflow." – Michael Durrant, NarendraC, IAmMilinPatel, Bharat Mane
If this question can be reworded to fit the rules in the help center, please edit the question.


You may use this-

Xpath1= //a[contains(.,'Create a Rediffmail account')] 





Or you try with other Locator types as- LinkText

Check I have tried & found 1 match xpath-

enter image description here

  • @Mahesh, Is it works? – Bharat Mane May 9 '16 at 13:15
  • I think If you are satisfied with this answer, You have to accept this answer by clicking right click. – Bharat Mane May 9 '16 at 13:36
  • Yes Xpath1= //a[contains(.,'Create a Rediffmail account')] and accept You may use this- Xpath1= //a[contains(.,'Create a Rediffmail account')] OR Xpath2=//a[contains(@href,'details')] both are work fine – Mahesh May 9 '16 at 14:47
  • @Mahesh accepting answer is nothing but marking right click which is present infront of answer. – Bharat Mane May 10 '16 at 5:57
  1. Open Mozilla FireFox.
  2. Install Firebug add-on.
  3. Install FirePath add-on.
  4. Browse your webpage in FireFox.
  5. Hit F12.
  6. Click FirePath tab.
  7. Inspect the element for which you want to get the Xpath.
  8. Copy the xpath from the FirePath console.

It's really this simple!!!

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