title: How to find the element within element in selenium
body: <p>I am creating a framework for the data validation using selenium. The issue I am struggling with is I want to locate the element "td"(html tag) within element "tr"(html tag) . This is the code I have written.</p>
  
  <pre><code>Iterator&lt;WebElement&gt; i = rows.iterator();
  While(i.hasnext()){
  List&lt;WebElement&gt; columns = row.findElements(By.tagName("td"));
  for(WebElement s:columns)
  {
      System.out.println("columnDetails : "+s.getText().toString());
  }
  if(columns.isEmpty())
  {
      ElementNotFoundException e = new ElementNotFoundException("No data in table");
      throw e;
  }
  Iterator&lt;WebElement&gt; j = columns.iterator();// does some other work
  ClusterData c = new ClusterData(); // does some other work
  ClusterDataInitializer.initUI(c, j, lheaders); // does some other work
  CUIData.put(c.getCN(), c); // does some other work
  }
  </code></pre>
  
  <p>Now the issue with this is:</p>
  
  <p><img src="https://i.stack.imgur.com/wM23x.jpg" alt="The Data from table which i am trying to fetch in arraylist"></p>
  
  <p>I am trying to fetch the data from the rows(see table data) in arraylist and use that arraylist further. Currently whats happening is the data for column header is fetched at start of which I have no use.I only want the rows's data. I am not able to determine the proper way to collect the data of table rows only.
  if xPath of the table will help you understand it properly then here are the details :</p>
  
  <p><strong>Table header <code>xPath</code> of cluster name column:</strong></p>
  
  <pre><code>/html/body/table/tbody/tr[2]/td[2]/div[2]/div/div/div[2]/div/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr/td[2]/div/div[2]
  </code></pre>
  
  <p><strong>Table row (Table Data) <code>xPath</code> of test cluster 01:</strong></p>
  
  <pre><code>/html/body/table/tbody/tr[2]/td[2]/div[2]/div/div/div[2]/div/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div/div[3]/div[2]/div/table/tbody/tr/td[2]/div/div/a
  </code></pre>
  
  <p>Please let me know if you need anything else. </p>
  
  <p>I am using the following code to extract row data from table.</p>
  
  <pre><code>List&lt;WebElement&gt; rows = getElement(driver,sBy,"table_div_id").findElements(By.tagName("tr"));
  </code></pre>
  
  <p>where <code>sBy = By.id</code> and <code>table_div_id = id</code> of <code>div</code> in which table is present. This extracts all the rows into <code>arraylist</code> and then i am using code to extract the row data into another <code>arraylist</code>. It is where I am stuck.</p>