Loop Through Tags with Different Classes

Looping through tags with the same class is a common scenario, but not the most simple one you might run into. Often it is necessary to loop through tags that do not all have the same class. An alternative scenario will be explored here.

The For Each Tag step is very efficient in most cases where For Tags With Class fails. The For Each Tag step loops over all types of tags, which are directly inside the found tag. It does take a little more configuration than just right-click and insert. Here is how to use it.

Use For Each Tag to loop over each tag of a given type, which is directly inside the found tag.


For each tag example

Note that the found tag contains three div tags, but they do not all have the same class. In this scenario, use For Each Tag to handle the differences.

  1. Insert an empty New Step New Step and select the For Each Tag action.
  2. In the Page View, select the Found tag.
  3. In the Step Action View, Tag field, select the tag type.
  4. Add steps after the For Each Tag step.

    These steps are repeated for each iteration of the loop.