Sunday 15 May 2011

java - How to identify the xpath for below html which is having text and link -



java - How to identify the xpath for below html which is having text and link -

please find code below html

<div class="content-table-pagination"> page 1 <a href="getsavedsearch.do?startswith=20">2 </a> <a href="getsavedsearch.do?startswith=40">3 </a>

i've tried below code. loop on pages.

list<webelement> allrows = driver.findelements(by.xpath("//*[@id='content']/div[3]/table/tbody/tr")); system.out.println("total rows :" +allrows.size()); //getting page count list<webelement> allpages = driver.findelements(by.xpath("//div[@class='content-table-pagination']//a")); system.out.println("total pages :" +allpages.size()); for(int i=1; i<=(allpages.size()); i++) { list<webelement> allrows1 = driver.findelements(by.xpath("//*[@id='content']/div[3]/table/tbody/tr")); for(int row=1; row<=allrows.size(); row++) { system.out.println("total rows :" +allrows1.size()); string validatorsorucerefid = driver.findelement(by.xpath("//*[@id='content']/div[3]/table/tbody/tr["+row+"]/td[7]")).gettext(); system.out.println(validatorsorucerefid); system.out.println("row loop"); //if(validatorsorucerefid==constants.sourcerefid){ if(validatorsorucerefid.contains("mantplap27102014090917528")){ system.out.println("is found"); break; } else { system.out.println("element doesn't exist"); } allpages = driver.findelements(by.xpath("//div[@class='content-table-pagination']//a")); } driver.manage().timeouts().pageloadtimeout(20, timeunit.seconds); allpages.get(i).click(); system.out.println("i'm in page number"+ i);

if utilize method click on paination, clicks 1 , 3 pages.it skips 2nd page.

allpages.get(i).click();

help me on this

java selenium-webdriver

No comments:

Post a Comment