Runs never stop? Fixing infinite loops

If you have a run that paginates through many results pages, you might have an error when the run never finishes, or, if it collect the last page's data several times.

This is likely due to the last page of the run reloading the page, because it is trying to click a button that doesn't do anything!

This tutorial will show you how to make sure your runs finish, with no extra data!

Prevent Infinite Loops

After adding the "Click" tool, you want to make sure that you did not create an infinite loop in the project.
On some websites the "next" button is still visible on the last page of the results, although it is disabled and not click-able. This causes ParseHub to continue paginating even with nothing left.

First, we need to make sure that the "next" button is not available on the last page: switch to the Browse Mode on ParseHub and go to the last page of the results.

Click on the "Select button" node and make sure that the selection node shows (0). If it is shows (1), this means that we are still selecting the "next" button on the last page.

To prevent creating this infinite loop, you should add a condition to skip the "next" button if it is disabled. This won't always require the same conditional on every page.

Right click on the next button the the last page and press Inspect Elements. You should look around in the html and find a unique attribute in the next button HTML, for when the button is disabled.


You should add a conditional command right after the Select button node and enter !$e.prop("class").toLowerCase().contains("disabled") in the condition text box.

If the HTML you found is in a different attribute (for example, name="disabled") make sure to change the expression to this attribute name, instead of class

If the HTML you found has a different unique name for the final page's button (for example, class="button_off") make sure to change the expression from disabled to this attribute.

Have more questions? Submit request!


Please sign in to leave a comment.