Display perticular cell in table using selenium webdriver

package tableAutomation;

import org.testng.annotations.Test;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;

public class SelectdValue {
    WebDriver driver;
     @Test//(enabled=false)
      public void SelectedCell() throws Exception {
          driver.get("http://www.seleniumlearn.com/table");
          driver.manage().timeouts().implicitlyWait(19, TimeUnit.SECONDS);
          Thread.sleep(3000);    
          WebElement table=driver.findElement(By.xpath("//table"));
          List<WebElement> rows=table.findElements(By.xpath("//*[@id='node-147']/div/div[1]/div/div/table/tbody/tr[8]/td[7]"));
          for(int td=0;td<rows.size();td++)
          {
          System.out.println("=============Selected value================="); 
          System.out.println(rows.get(td).getText());
          }
          }
  @BeforeTest
  public void beforeTest() {
     driver=new FirefoxDriver();
    // System.setProperty("webdriver.chrome.driver","D:\\lib\\chromedriver.exe"); //---> Chromedriver path
    //driver = new ChromeDriver();
    driver.manage().window().maximize();
      
  }

}

Comments