2017-07-25 41 views

回答

0

你可以做的就是检查当前的网址。当你点击下一个按钮时,URL会改变。 http://biz.chosun.com/svc/list_in/list.html?catid=1A&pn=0

2页的URL - -

第1页的URL http://biz.chosun.com/svc/list_in/list.html?catid=1A&pn=2

假设你是最后一页上,如果尝试点击下一步按钮,它会给你同样的URL。

所以,你应该在代码是这样的:

String current_URL = driver.getCurrentUrl(); 
String previous_URL = null; 
while (current_URL != previous_URL) 
{ 
    // perform operations; 
    previous_URL = driver.getCurrentUrl(); 
    // click on next; 
    current_URL = driver.getCurrentUrl(); 
} 
+0

感谢您的反馈,所以我假设ü要我做这样的事情串current_URL = driver.getCurrentUrl(); String previous_URL = null; while(current_URL!= previous_URL) {gotourl(oldurl) //执行操作; previous_URL = driver.getCurrentUrl(); //点击下一步;gotourl(nexturl) current_URL = driver.getCurrentUrl(); } –

+0

你好,其实你知道如何解决这个问题,当我输入While(当前url!=前面的url)时,它说我不能自动将字符串转换为bool ... –

+0

你可以使用 while(!current_url。等于( “previous_url”)) – tester