title: Why is my XPath expression "unable to locate element"?
body: <p>Below is the HTML code, I am trying to make a XPath expression for the user name text box which is inside the table.</p>
  
  <p>I tried following expressions:</p>
  
  <ol>
  <li>To traverse the table: <code>//table[@id='Login:LoginScreen:LoginDV']</code></li>
  <li>To reach out to the user name: <code>//input[@id='Login:LoginScreen:LoginDV:password']</code></li>
  <li>To reach to Log in button: <code>//div/div[2]/div/table/tbody/tr/td/table/tbody/tr[4]/td[5]/a/span[2]</code></li>
  </ol>
  
  <p>I'm getting following error message:</p>
  
  <blockquote>
    <p>Unable to locate element: </p>
  
  <pre><code>{"method":"xpath","selector":"//input[@id='Login:LoginScreen:LoginDV:username']"‌​}
  </code></pre>
  </blockquote>
  
  <p>I am very new to XPath. I am reading the stuff on google and trying on what I have understood out of my readings. </p>
  
  <pre><code>&lt;div id="mainContent"&gt;
  &lt;div id="Login" class="content"&gt;
  &lt;div id="Login:LoginScreen:ttlBar" class="screentitle"&gt;
  &lt;input id="Login:LoginScreen:_msgs" type="hidden" name="Login:LoginScreen:_msgs"/&gt;
  &lt;span id="Login:LoginScreen:_msgs_msgs"/&gt;
  &lt;div id="Login:LoginScreen:0" class="info"&gt;The submitted user name/password is invalid.&lt;/div&gt;
  &lt;table id="Login:LoginScreen:LoginDV" class="dv "&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td valign="top"&gt;
  &lt;table id="Login:LoginScreen:LoginDV:0" class="dvColumn" border="0" cellspacing="0" cellpadding="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td class="empty-cell"&gt;
  &lt;img height="1px" width="1px" border="0" src="images/trans_pixel.gif"/&gt;
  &lt;/td&gt;
  &lt;td class="empty-cell"&gt;
  &lt;img height="1px" width="1px" border="0" src="images/trans_pixel.gif"/&gt;
  &lt;/td&gt;
  &lt;td class="inputLabel"&gt;
  &lt;span&gt;User name&lt;/span&gt;
  &lt;/td&gt;
  &lt;td class="empty-cell"&gt;
  &lt;img height="1px" width="1px" border="0" src="images/trans_pixel.gif"/&gt;
  &lt;/td&gt;
  &lt;td class="inputValue"&gt;
  &lt;input id="Login:LoginScreen:LoginDV:username" class="textBox" type="text" contenteditable="true" onblur="EventHandlers.onBlur(event)" onfocus="EventHandlers.onFocus(event)" helptext="__UseTitle__" size="20" style="text-align: left" delayonchange="false" onclick="event.cancelBubble = true;" onkeydown="DHTML.cancelBubbleIfNoAltKeyOrEnter();" onchange="if (EventHandlers.valueChanged(event, this)==false) return false;" value="" label="User name" name="Login:LoginScreen:LoginDV:username"/&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>