How to write the XPath for this



  • I am trying to write the XPath for the below element but unable to do. I want to write for the Individual. I wrote like this //h3[contains(text(),'Individual')]

    <h3 class="dashboradh">
              <strong>My Dashboard</strong>
              <span>Anjana</span> |  Individual        </h3>
    


  • There are some white spaces in your string. So use normalize-space() to trim the white spaces as below :

    //h3[normalize-space(text()='Individual')]
    

    OR

    You should try dot . instead of text() in contains method to match the required text in any node within the tag.

    //h3[contains(., 'Individual')]
    


Suggested Topics

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