Thursday, January 16, 2014

Read Data or HTML table Using WebDriver

Code Snippet for how to Read Data or HTML table Using WebDriver

WebElement tab=driver.findElement(By.xpath("//table[@id='availabilityTable1']"));
List<WebElement> tableRows = tab.findElements(By.tagName("tr"));
  {
    for (WebElement cell:tableRows)
          {
           List<WebElement>data=cell.findElements(By.xpath("//td[5]"));
           //Reading 5th Column of the Table
          for(WebElement d:data)
          {
             System.out.println(d.getText());
         }

No comments:

Post a Comment