Tuesday, April 14, 2015

How to play with Web table in Selenium Webdriver ?

Web table is a different type of web element and we can not directly get all data in one variable.
To access web table data we need to locate web table using findelement method and then identified all the tr tags using findelements method.
Code for the same as below.

WebDriver driver =  new InternetExplorerDriver();
WebElement table = driver.findElement(By.id("tableid));
List<WebElement> tablerows = table.findElements(By.tagName("tr")); // To get all Rows

int rowcount  =  tablerows.size();  \\To get count of total rows

for (WebElement tablerow : tablerows )
{
tablerowindex = 0;
     List <WebElement> tablecolumns = tablerow.findelements(By.tagName("td"));
     int columncount = tablecolumns.size();
     for (WebElement tablecolumn : tablecolumns)
     {




      }



No comments:

Post a Comment