开发者

Row counts of all pages in selenium

I have 5 pages(we are using pagination). Each page has 10 records on it. If i us开发者_运维百科e

int rcount =  selenium.getXpathCount("//table[@id='bank']/tbody/tr").intValue();

I am getting rcount as 10, that means it is only getting the 1st page count only I want to get all records of 5 pages(total 50 records) Help me...


You will need to loop over all the pages clicking the next button and summing the values of the row count:

int rcount = selenium.getXpathCount("//table[@id='bank']/tbody/tr").intValue();
while(selenium.isElementPresent("next button locator")) {
    selenium.click("next button locator");
    selenium.waitForPageToLoad("timeout");
    rcount += selenium.getXpathCount("//table[@id='bank']/tbody/tr").intValue();
}


Selenium works like a browser user!

So selenium test can only "see" what a use see (if he looks at the HTML code), and do want a user can do.

So if your application has a page size function, you need to set it first to lets say 100. For you selenium test: it means click/invoke the page size function for 100 items first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜