简体   繁体   English

如何对仅显示一位数字的链接文本进行循环浏览?

[英]How to make a loop for a link text that has only one digit present so as to navigate through pages?

I have to navigate through the pages that have href as: 我必须浏览具有href为的页面:

href="/Amazon-com-Amazon-Appstore/product-reviews/B071NZZHF9/ref=cm_cr_getr_d_paging_btm_2?ie=UTF8&filterByStar=critical&pageNumber=2&pageSize=10"

and link text as '2' which keeps on changing corresponding to the page i wany to navigate. 并将文本链接为“ 2”,该文本根据我想要浏览的页面不断变化。

i have total of 6 pages and for that i wanted to make a for loop so that i dont have to give the href again and again. 我总共有6页,为此,我想进行一个for循环,这样我就不必一次又一次地给href提供信息。

Can someone please help me with this. 有人可以帮我吗

for(int j = 2; j <= 5; j++) { WebDriverWait pagechange_star = new WebDriverWait(dr,20);
                        pagechange_star.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='cm_cr-pagination_bar']/ul/li["+j+"]/a")));
dr.findElement(By.xpath(".//*[@id='cm_cr-pagination_bar']/ul/li["+j+"]/a")).click();
}

so j is a variable here which will increase its value from 2 to 5. hence we can scroll through different pages using it in the xpath. 所以j是一个变量,它将其值从2增加到5。因此,我们可以在xpath中使用它来滚动浏览不同的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM