Selenium webdriver - How to get inner text of the cell of a html table

package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Example {
 public static void main(String[] args)
     {

  WebDriver driver = new FirefoxDriver();
 
  driver.get("http://www.w3schools.com/html/html_tables.asp");
 
  String text=driver.findElement(By.xpath("//table/tbody/tr[3]/td[2]")).getText();
 
  System.out.println(text);
 
  }

Output:- Jackson
Above script gets 3rd row,2nd column cell text from below shown table.

working with webtables selenium webdriver
 

No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge