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());
}
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