Back To Normal

Subscribe To Our E-Mail Newsletter

Wednesday, December 14, 2011

How to read HtmlTable data by using Selenium Webdriver ?


Couch ModePrint It

public void ReadTableData(String sTableID)
{
WebElement table = driver.findElement(By.id(sTableID)));
// Now get all the TR elements from the table

List allRows = table.findElements(By.tagName("tr"));
// And iterate over them, getting the cells

for (WebElement row : allRows) {
List cells = row.findElements(By.tagName("td"));
for (WebElement cell : cells) {
Object CellValue = cell.getText();
System.out.Println("Cellvalue" +Cellvalue.toString )
}
}

}



Click Here For Smileys :D
:D
:)
:[
;)
:D
:O
(6)
(A)
:'(
:|
:o)
8)
(K)
(M)

2 comments:

Unknown said...

Good One, thanks.

QA-Testing said...

for (WebElement row : allRows)

Above line gives ERROR, Type Mismatch- Can not Convert Object to Webelement . Any solution

560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .