Each Page Links to Next

Pages are linked to a subsequent page, typically with a link at the bottom to the next page.


Each page links to next

Use the Repeat action to loop through such pages. This action loops through the pages that are supplied to it by another action named Next.

Repeat and Next must be used collaboratively to have any effect.

  1. On the first page add a Repeat step.
  2. Insert additional actions as required.
  3. Insert a Next step.

    When the robot execution reaches the next step, it reverts back to the repeat step and executes another iteration of the steps. The page is transferred to the repeat step and a new page is loaded with each iteration.

    You can add other loops between the repeat and next steps to extract additional information from the page, as needed.


    Repeat example in robot

    Here, like before, we are looping through the result pages from a search request, symbolized by the Submit Form step.

    The form submission step will output the first result page, which we give to the Repeat action. In the first branch from the Repeat action, we process the current page. In the second branch, we load the next page by clicking its link. The Next action sends the page back to the Repeat action, which will output it in the next iteration. When the last page is reached, the Click action generates an error. To do this, the Click step is configured to terminate the loop. In the Click step, this is done in the Error Handling tab by setting the Then property to Break Loop.

  4. To terminate the loop, In the Error Handling tab, set the Then property to Break Loop.

    If the process does not find a Next page, the process terminates.

    See Handling Errors for more information.

    An alternative way of handling the last page is shown in the following robot excerpt:


    Error handling example

    You can use a Test Tag action in a second branch to detect when the last page has been reached. The Test Tag action checks that the page contains a next-page link, for example by looking for an <a>-tag containing the text Next. If the page contains such a link, we load this page and give it to the Next action. When the last page is reached, the Test Tag action stops execution down the second branch, and no new page is given to the Repeat action, causing the loop to end.

    Finding the link to the next page can be tricky. A common mistake is to find the previous-page link on some pages instead of the next-page link, because the layout of the pages changes slightly between the first page, the subsequent pages, and the last page. Another common mistake is to not detect the last page reliably. You may have to configure the tag finders of the steps carefully to make things work (see Using Tag Finders).

    When you are working with a robot in Design Studio, you may not always be able to step correctly back and forth between iterations of a Repeat action. If you are not sure whether Design Studio has gotten it right, click Refresh to update.