Example, there is a web page in which there is an ability to move to another page with button - "Next Page". Does selenium provide an ability to cycle through this pages, I have one page with 100 "Next Page" butttons, and second with 200 "Next Page". Can i make something like
do {
selenium.click("next page");
}while (next_page exists);
This an example, but I hope you understood the idea.
Of course. Selenium can automate pagination.
Let the id's of the page nums be pageX
- X
being the page number.
in Java (pseudo) -
public void nextPage() {
if (selenium.isElementPresent("css=a#page" + (i+1)))
selenium.click("css=a#page" + (i+1));
}
Just wrap that in a loop, like you did up there.
EDIT : I noticed in the comments you want it in a do{}while()
public boolean hasNextPage() {
return selenium.isElementPresent("css=a#page" + (i+1));
}
So your loop would be -
do {
nextPage();
} while (hasNextPage())
do
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.