reading data from web table --webdriver

import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;


public class read_table
{
    public static void main(String[] args) throws Exception
    {
        String str;
        FirefoxDriver fd=new FirefoxDriver();
        fd.get("http://content.icicidirect.com/newsiteContent/Market/MarketStats.asp?stats=DailySharePrices");
        Thread.sleep(8000);
                  ////for example we want to read from 5th row then
        for(int c=1;c<=8;c++)
        {
                 /////////in the xpath, the row 5 is constant , the td is changing from 1 to 8 columns
            str=fd.findElement(By.xpath("//*[@id='gridSource']/tbody/tr[5]/td["+c+"]")).getText();
            System.out.println(str);
        }

    }

}

Comments