Dynamic Web table with pagination | Selenium Forum
M
Posted on 08/10/2015
We have a dynamic web table with pagination which expand or collapse depend on the customer requests,How to i get total number of row for this table.

int i=1;
int totalRows=0;
String xpath_start="//div[@id='ext-gen255']/div[";
String xpath_end="]/table/tbody/tr/td[1]/div";

while((driver.findElement(By.xpath(xpath_start+i+xpath_end )) != null))
{
i++;
totalRows++;
}
System.out.println("Total rows -- " +totalRows);

when i run this code it is taking up to 25 rows as per pagination ,26th row throwing error "Unable to locate element: {"method":"xpath","selector":"//div[@id='ext-gen255']/div[26]/table/tbody/tr/td[1]/div"}[/color]

M
Replied on 08/10/2015

[color=#FF0000:2s77u6st]Unable to locate element: {"method":"xpath","selector":"//div[@id='ext-gen255']/div[26]/table/tbody/tr/td[1]/div"}[/color:2s77u6st]

this error comes when there is no corresponding xpath can be found on web page.

so as you said in your comments there are only 25 rows. so it is giving you an error on [color=#FF0000:2s77u6st]div[26][/color:2s77u6st] because there are no rows there.