title: Locating data in a complex table in Selenium Webdriver
body: <p>I am currently trying to drill down on a user in a table full of users using Selenium webdriver, I have worked out how to iterate through the table but I'm having trouble actually selecting the person I want.</p>
  
  <p>Here is the HTML  (modified with X's due to it not being my data)</p>
  
  <pre><code>&lt;table id="XXXXXXXXX_list" cellspacing="0" cellpadding="0" style=" border:0px black solid;WIDTH:100%;"&gt;
  &lt;tbody&gt;
  &lt;tr cellspacing="0" style="height: 16px;"&gt;
  &lt;tr&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',1,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',2,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',3,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',4,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',5,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',6,this,event)"&gt;
  &lt;tr onclick="widgetListView_onClick('XXXX_list',7,this,event)"&gt;
  &lt;td class="listView_default_dataStyle" nowrap="" style="font-size:12px ;
  font-family: sans-serif ;color: black ;background: #FFFFFF " 
  ondblclick="XXXXListView_onDblClick('XXXXX_list',17, event)"&gt;NAME&lt;/td&gt;
  &lt;td class="listView_default_dataStyle" nowrap="" style="font-size:12px ;font-family: sans-serif;
  color: black ;background: #FFFFFF " ondblclick="XXXXX_onDblClick('XXXX_list',17, event)"&gt; &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Here is the code I am writing to try and find the user going by NAME in the table.</p>
  
  <pre><code>WebElement table = driver.findElement(By.id("table_list"));
  
      // Now get all the TR elements from the table
      List&lt;WebElement&gt; allRows = table.findElements(By.tagName("tr"));
      // And iterate over them, getting the cells
      for (WebElement row : allRows) {
       List&lt;WebElement&gt; cells = row.findElements(By.tagName("td"));
       for (WebElement cell : cells) {         
          List&lt;WebElement&gt; Names = cell.findElements(By.xpath("//td[text()='NAME']"));
          System.out.println(Names);
  </code></pre>
  
  <p>This just prints thousands of []  (the table is huge in the real application).
  Essentially what I need is to stop when I find the correct name and create a web element out of that table row. Which I can then click and drill down on. </p>
  
  <p>Sorry if any of this is a bit vague, </p>