Use a loop and animate the next button with the index of the loop.
Define an index for the loop. It will increase starting from 0.
Create a mode as much as your number of pages, take into account that the index starts from 0 here, you can +1 depending on the situation.
Click the Next button.If there is no next button, if you only need to click on the numbers, you can still calculate with the index and the number of rows in the page.
You can also try this case, but the URL should contain meaningful alternatives. If there is a long URL that could change, you may need to fix it later.