Read Web-table
Code Here :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class test_table {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
driver.get("http://www.w3schools.com/html/html_tables.asp");
String s="";
int i,j;
for( i=1;i<=5;i++){
for( j=1;j<=4;j++)
{
System.out.println(i+" ,"+ j);
if (i==1)
s=s+" "+driver.findElement(By.xpath("//table[@class='reference']//tr["+i+"]//th["+j+"]")).getText();
else
s=s+" "+driver.findElement(By.xpath("//table[@class='reference']//tr["+i+"]//td["+j+"]")).getText();
}
s=s+"\n";
}
System.out.println(s);
}
}
No comments:
Post a Comment