Cycles (loops)

Table of contents


A cycle is an action, or a group of actions, that are performed either a specified number of times or before a specific event occurs.

In general, we recommend using loops not very often, because this is a complex construction and it may contain a number of unforeseen errors (especially if you do not understand programming).

Creation

Automatic

Creating a loop in ZennoPoster is quite simple: to do this, right-click on an action (or a group of actions) and select the Repeat in loop item from the context menu:

After clicking, a window for selecting an exit from the cycle will appear:

Repeat a specified number of times

When you select this item, you will need to enter the desired number of repetitions in the input field, and after clicking on the OK button, a counter variable, an action for comparing a counter with a specified number and an action for increasing the counter value will be created.

Repeat while the condition is true

In the input field you enter the necessary conditions and while it returns True, the cycle will continue. After clicking OK, the data from this field will be transferred to the IF action, so the same rules for constructing expressions must be followed in it as in the standard action.

Manual cycle creation

The options for automatic creation of cycles were considered above, but you can do it manually.

Let's take an example: you need to get data from the site, the site has many pages and to go to the next page, you need to click on the Next button, if the pages are over, then this button is not.

In this case, the exit condition will be an error when clicking the Next button (when the action does not find an element, it will fail).

Usage Tips

  • Don't use eternal loops!

Add a counter to your loops. For example, you need to wait for an element to appear on the page and you have made an eternal loop waiting for it. But at some point, the site changes its structure and your template freezes because it will never wait for the necessary element to appear.

  • Don't loop your templates!

This can lead to all sorts of errors!

Useful links: