2

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:

.//a[starts-with(@href,'http://register.rediff.com/register/register.php?FormName=user_details')]

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

4

You may use this-

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

OR

Xpath2=//a[contains(@href,'details')]  

OR

Xpath3=.//*[@id='toprightinfo']/a[2]

Or you try with other Locator types as- LinkText

Check I have tried & found 1 match xpath-

enter image description here

|improve this answer|||||
  • @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
  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!!!

|improve this answer|||||

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