RE: how to get td (pending) value in this table data.I wrote some code to fetch rows But Total rows is 0 While Im running :Can u please provide some code.

Answered

<tbody>
<tr>
<td>
<input type=”checkbox” name=”data[399]” id=”checker”>
</td>
<td>Innovate</td>
<td>9/23/2014 9:43:34</td>
<td>Pending</td>
<td><a onclick=”DoPost(399,0);”>View Profile</a></td>
</tr>
<tr>

surekha Train Asked on September 24, 2014 in Selenium WebDriver.
Add Comment
1 Answers
Best answer

Hi Surekha,

Please try this code.

WebElement Webtable=driver.findElement(By.id(“TableID”)); // Replace TableID with Actual Table ID or Xpath
List<WebElement> TotalRowCount=Webtable.findElements(By.xpath(“//*[@id=’TableID’]/tbody/tr”));
System.out.println(“No. of Rows in the WebTable: “+TotalRowCount.size());

// Now we will Iterate the Table and print the Values
int RowIndex=1;
for(WebElement rowElement:TotalRowCount)
{
List<WebElement> TotalColumnCount=rowElement.findElements(By.xpath(“td”));
int ColumnIndex=1;
for(WebElement colElement:TotalColumnCount)
{
System.out.println(“Row “+RowIndex+” Column “+ColumnIndex+” Data “+colElement.getText());
ColumnIndex=ColumnIndex+1;
}
RowIndex=RowIndex+1;
}

Thanks,
Vishal

Doctor Answered on September 24, 2014.

Put an if condition after you get the column data according to your need.

on September 24, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.