Skip to main content

Loop through similar web elements

Sophie avatar
Written by Sophie
Updated this week

Definition and Usage

Loop through each item in a list of similar elements on a web page. This command allows you to iterate through multiple elements with the same structure (such as rows in a table, list items, or search results) and perform operations on each element individually.


Parameter Values

Input parameters

Parameter

Description

Possible Values

Required

Options / Notes

Web page

Select a variable that contains the web page to work with

Any web page variable

Yes

Must be a valid web page object

Element

Select or capture an element to operate on

Any web element

Yes

Use the Capture button to select the element on the page

Store loop index in variable

When selected, this will automatically output the position of the current item in the list, starting from 0

Boolean (checkbox)

No

Useful for tracking the current iteration

Save loop item as

Store the current loop item in a new variable

Variable name

Yes

This will store each web element during iteration

Advanced settings

Parameter

Description

Possible Values

Required

Options / Notes

Element timeout (s)

Wait time for element to appear (seconds)

Numeric value

No

Default is 20 seconds

Loop from bottom

Loop the similar elements from the bottom of the list

Boolean (checkbox)

No

When checked, iteration starts from the last element

Variables produced

  • Save loop item as: Stores the current web element being processed in the loop

  • Save loop index as: Position of the current item in the list, starting from 0 (only available when "Store loop index in variable" is checked)


Using Variables in Conditions

You can use the variables produced by this command in subsequent actions by referencing them with the {variable} syntax. The loop item variable contains the current web element, which can be used for actions like clicking, extracting text, or other web element operations. The loop index variable contains a numeric value representing the current iteration (starting from 0).


Notes

  • This command creates a loop structure that will iterate through all matching elements on the page

  • Make sure to select a representative element that has the same structure as all items you want to iterate through

  • The command will identify all elements with the same selector pattern as your captured element

  • If elements load dynamically (like in infinite scrolling pages), you may need to adjust the timeout settings

  • You can use this command with nested loops to process complex data structures on web pages

  • The loop will end automatically when all matching elements have been processed

Did this answer your question?