title: java selenium navigate through a webpage using xpath
body: <p>I'm trying to use selenium to make a login, navigate, fill a form and download a file.
  When i'm trying to navigate i need to click a link, sounds pretty basic.
  Since it has no id or name, i used FirePath to get the xPath(<code>.//*[@id='id25']/li[4]/a</code>) then i did the following:</p>
  
  <pre><code>driver.findElement(By.xpath(".//*[@id='id25']/li[4]/a"));
  </code></pre>
  
  <p>Selenium returns me  <strong>Unable to locate element:</strong>
  I did some reading here and there and tried a few different things:</p>
  
  <pre><code>driver.findElement(By.linkText("Network Support")).click();
  
  driver.findElement(By.xpath("//a[@title='Network Support']")).click();
  
  driver.findElement(By.cssSelector(".LI_Primary"));
  
  driver.findElement(By.xpath("[@id='id25']/li[4]/a"));
  
  driver.findElement(By.xpath("/html/body/form/span/div[1]/div/div[1]/div/ul/li[4]/a")).click();
  </code></pre>
  
  <p>None of those work, selenium always return <strong>"Unable to locate element:"</strong></p>
  
  <p><strong>The html:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html&gt;
  
      &lt;head id="Head1"&gt;&lt;/head&gt;
      &lt;frameset id="EbpFrame" frameborder="0" marginwidth="0" marginheight="0" rows="111px,*"&gt;
          &lt;frame style="border:0px !important;" noresize="noresize" frameborder="0" framespacing="0" scrolling="no" marginheight="0" marginwidth="0" name="upper" src="/general/UpperNavigationRibbon.aspx?header=noname"&gt;
              #document
                  &lt;!DOCTYPE html&gt;
                  &lt;!--
  
                  [if lte IE 7 ]&gt;    &lt;html class="ie7"&gt; &lt;![endif]
  
                  --&gt;
                  &lt;!--
  
                  [if IE 8 ]&gt;    &lt;html class="ie8"&gt; &lt;![endif]
  
                  --&gt;
                  &lt;!--
  
                  [if IE 9 ]&gt;    &lt;html class="ie9"&gt; &lt;![endif]
  
                  --&gt;
                  &lt;!--
  
                  [if (gt IE 9)|!(IE)]&gt;&lt;!
  
                  --&gt;
                  &lt;html&gt;
                      &lt;!--
  
                      &lt;![endif]
  
                      --&gt;
                      &lt;head id="Head1"&gt;&lt;/head&gt;
                      &lt;body class="header" onload="SetFrameHeight()"&gt;
                          &lt;form id="formm" action="UpperNavigationRibbon.aspx?header=noname" method="post"&gt;
                              &lt;div class="aspNetHidden"&gt;&lt;/div&gt;
                              &lt;div class="aspNetHidden"&gt;&lt;/div&gt;
                              &lt;span id="spanContent"&gt;
                                  &lt;div id="page_container" class="header"&gt;
                                      &lt;ul id="global_nav"&gt;&lt;/ul&gt;
                                      &lt;div id="primary_links"&gt;
                                          &lt;a class="eLogo" title="Home" href="javascript:menu_Controll('/Portal/Home.aspx')"&gt;&lt;/a&gt;
                                          &lt;div style="width:810px"&gt;
                                              &lt;div id="primary_nav"&gt;
                                                  &lt;ul id="id25" class="clearfix"&gt;
                                                      &lt;li&gt;&lt;/li&gt;
                                                      &lt;li&gt;&lt;/li&gt;
                                                      &lt;li&gt;&lt;/li&gt;
                                                      &lt;li&gt;
                                                          &lt;a class="LI_Primary" title="Network Support" href="javascript:menu_Controll('/ContactAndhelp/ContactsAdmin.aspx?CategoryID=10')"&gt;&lt;/a&gt;
                                                      &lt;/li&gt;
                                                      &lt;li&gt;&lt;/li&gt;
                                                  &lt;/ul&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div class="clientLogo"&gt;&lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="bottomgrad"&gt;&lt;/div&gt;
                              &lt;/span&gt;
                              &lt;input id="hdnSerVar" type="hidden" value="fjunior@timbrasil.com.br" name="hdnSerVar"&gt;&lt;/input&gt;
                          &lt;/form&gt;
                          &lt;script type="text/javascript"&gt;&lt;/script&gt;
                      &lt;/body&gt;
                  &lt;/html&gt;
          &lt;/frame&gt;
          &lt;frame style="border:0px !important;" onload="AppBodyTrackHistory()" noresize="noresize" frameborder="0" framespacing="0" scrolling="auto" marginheight="0" marginwidth="0" name="portalmain" src="/Portal/Home.aspx"&gt;&lt;/frame&gt;
      &lt;/frameset&gt;
  
  &lt;/html&gt;
  </code></pre>