-3

I cannot find the xpath for the Login button and the Login text in the below code. Please help me.

<header id="primary-header" role="banner">
  <div id="header-left-links" role="navigation">
    <div id="header-middle-links">
      <div id="header-right-links">
        <ul>
          <li>
            <li>
              <a class="login header-right-label open" data-side-panel-trigger="login" href="#" aria-expanded="true">
                Log In
                <span class="icon-account-info"/>
              </a>
            </li>
JeffC
  • 22,180
  • 5
  • 32
  • 55
  • for text use `//a[.='Log In']` and for button anchor tag use `//a[@data-side-panel-trigger="login"]` – Yash Nov 18 '17 at 07:36
  • The concept of "the XPath" for a node is completely mistaken. There's an infinite number of possible XPaths. The particular one you want is the one that will find the right node even if the document is slightly different from the one shown (because if it only works on this document, then you know what's in the document and don't need XPath to find it). So we need to know which parts of your document are fixed, and which can change. – Michael Kay Nov 18 '17 at 13:20
  • @Yash Both of those XPaths will return the same element, the `A` tag. – JeffC Nov 18 '17 at 21:12
  • Welcome to Stack Overflow! Please read [ask], especially the part about [mcve] (MCVE), and [How much research effort is expected?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) This will help you debug your own programs and solve problems for yourself. If you do this and are still stuck you can come back and post your MCVE, what you tried, and the execution result including any error messages so we can better help you. Also provide a link to the page and/or the relevant HTML. – JeffC Nov 18 '17 at 21:16

1 Answers1

0

If xPath is not available just make your own

//a[@class='login header-right-label open']

Use this it surely gonna work

Syntax:

//HTMLtag[@locatorname='Locatorvalue'] 

This syntax is used to make xPath.