ZennoLab

Automate everything

User Tools

Site Tools


Sidebar

Translations of this page:

en:looping

Loops

Generally speaking we do not recommend you to use loops very often as this is a complex structure and you may encounter a whole range of unforeseen errors (especially if you are not very good at programming).

A loop consists of two key elements, namely repeated actions and exit conditions.

If you know exactly how many times an action should be repeated

Firstly you have to create variable by Variable processing - Set value action. When initializing a counter you indicate its initial value and a name, by which to later distinguish it, get it and increase it (its value). Inside the loop you need to increase your counter value once and then you should wait until it surpasses the required value - this will be a signal to exit the loop. Otherwise you return to the start of the loop. When comparing the counter and the value you do not have to put in brackets either the value or the counter macro as you are basically comparing values and not texts.

Exiting the loop following an event on the web page

This event could be appearance of a specific text on the web page or a jump to the required URL - in any case you will need to use Logic - If action in which you will write the criterion for exiting the loop using JavaScript. Please be reminded that exit with error (through the red point) from this action occurs when your JavaScript generates false at execution. You don't need to learn JavaScript. Just look at screenshots and change data to fit your needs.

Exiting the loop following an error

It's the easiest scenario, when you don't know how many times the loop will run and what will be the condition of its end, however you do know that at some point in a project an execution error will occur and the loop will be disrupted. For instance, when parsing search engines you press the Next button in your loop, it's obvious that soon you will get to the last page and this button will disappear and the loop will end in error. An error in this example does not mean that something will go wrong, it is simply an exit from the project in case of branch execution errors and in this particular case this error helps us exit the loop.


Variable counter

If-logic action

How to create a basic loop

en/looping.txt · Last modified: 2015/08/13 16:18 by vladz