title: How to store list of WebElements from a table in to a list while implementing selenium webdriver?
body: <p>I am trying to save a column of elements into a list from a table structure with the below expression on which I need to perform a click operation to validate those buttons.</p>
  
  <p>Code :</p>
  
  <p>I have the value for <code>Total_element = 37</code>.</p>
  
  <pre><code>for(int start=0; start &lt;= Total_element; start++)  
  {  
      int startn=start+1;  
      System.out.println(start);  
      List &lt;WebElement&gt; Element1 = new ArrayList&lt;WebElement&gt;() ;
  
      try{  
          Element1.add(Naveen.findElement(By.xpath(".//*[@id='data_grid']/tbody/tr["+startn+"]/td[2]/a/img")));  
      }catch(Throwable t){  
          System.out.println(t);  
      }  
      System.out.println(Element1.get(start));  
      System.out.println("The element" + start + "is :"+ Element1.get(start));  
      Naveen.findElement(By.xpath(Element1.get(start).toString())).click();  
      Naveen.findElement(By.xpath(".//*[@id='action']/a/span/div")).click();  
      System.out.println("The element" + start + "is :"+ Element1);  
      Thread.sleep(5000);  
  }
  </code></pre>
  
  <p>Error :  </p>
  
  <p>when I try to retrieve the elements from the list I get the following output :  </p>
  
  <p><code>[[FirefoxDriver: firefox on XP (586a8f1f-f784-4ae7-adf5-5f920dfad8e0)] -&gt; xpath: .//*[@id='data_grid']/tbody/tr[1]/td[2]/a/img]</code>  </p>
  
  <p>further which my is saying my operation is failing.  </p>