Welcome to the community
You can try keeping the table extraction in a loop and perform the steps of clicking next after the table extraction…
The loop can continue till the next button is disabled which can be found using find element or Element exists
Hope this helps
cheers