I’ll be showing you two ways to automate clicking the next page button on a website using Power Automate Desktop for 2 scenarios:
- For websites where the last page does not contain a “Next button”, like Google.
- For websites where the last page contains a “Next button”, but it cannot be clicked.
Last page does not contain a “Next button”
For this scenario, I’ll go to Google, type ‘sumi painting koshu’ in the search bar, and then press the Google Search button.
After the search results appear, I will click through the pages and count how many pages are navigated


- Launch new Chrome: Opens a new Chrome browser window and navigates to Google while storing the browser instance in a variable ‘Browser‘
- Populate text field on web page: Fills the Google search bar with the search term “sumi painting koshu” using emulated typing
- Press button on web page: Clicks the “Google Search” button to initiate the search.
- Set variable: A variable named ‘NextPage‘ is initialized with the value TRUE. This variable will be used to control the loop.
- Set variable: Another variable named ‘PageCount‘ is initialized with the value 1 to keep track of the number of pages visited.
- Loop condition: set the loop runs as long as ‘NextPage‘ is TRUE.
- If web page contains: Checks if the “Next button” is present on the current web page.
- Click link on web page: If the “Next button” is found, it clicks on it to go to the next page.
- Increase variable: Increase the ‘PageCount‘ variable by 1
- Else: If the “Next button” is not found (i.e., no more pages to navigate), the loop exits.
- End: Marks the end of the loop and the end of if
- Display message: Shows a message box displaying the value of ‘PageCount‘, indicating how many pages were visited.
Last page contain a “Next button” but cannot be clicked
For this scenario, I’ll go to SE-ED books websites that already include the search result (replace % with %%)
Then navigates through a series of paginated web pages and counts the total number of pages by looking for the “Next button” which can be clicked, and stopping when “Next button” which cannot be clicked.



- Launch Chrome : Opens a new Chrome browser window and navigate to the SE-ED books product search webpage (that includes a search keyword “yoga” in Thai language) while storing the browser instance in a variable ‘Browser‘
- Set variable: A variable named ‘NextPage‘ is initialized and set to TRUE. This variable is used to control the loop for checking the pagination.
- Set variable: Another variable ‘PageCount‘ is initialized and set to 1. This will track the number of pages navigated.
- Loop Condition: This loop will continue as long as ‘NextPage‘ is set to TRUE. Inside the loop, the flow looks for the ‘Next’ button on the web page to determine if there are more pages to navigate.
- Wait for web page content: The flow waits for the “Next button” without Class “next” to appear on the page.
- If web page contains: Checks if the “Next button” exists on the page with Class “next”
- Click link on web page: If the “Next button” found, it clicks the “Next button” to navigate to the next page
- Increase variable: Increase the ‘PageCount‘ variable by 1
- Else: If the “Next button” is not found (i.e., no more pages to navigate), the loop exits.
- End: Marks the end of the loop and the end of if
- Display message: Shows a message box displaying the value of ‘PageCount‘, indicating how many pages were visited.
You can copy the source code of this article from below link and paste it into your Power Automate Desktop’s Workspace.


Leave a comment