How to locate XPath for given tag?



  • 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?



  • 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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2