[Feature] Conditions in Macros

Hi all,

We are excited to announce the release of a new feature in Macros: Conditionals.

This introduces a new type of step in Macro, the Conditional (If..Else). It allows you to execute specific steps based on wether a condition evaluates to true or false. This is similar to the If..Else structure in programming languages.

if ( this expression evaluates to true) {
    //Execute these of steps
} else if ( this other expression evaluates to true) {
   // Execute these other steps

Example Use cases:

  1. Handling Popups: On certain page loads, a popup may appear while at other times it doesn’t. If your macro has a step to click on the close button of the popup, it might encounter errors if the popup is absent. To address this, you can set a Conditional to click the popup’s close button only if the popup is present. Reference to a similar query can be found in this thread:
  1. Login if not already logged in: Execute a list of steps to login, only when you are prompted to login. If you are not prompted to login (because you are already logged in), these steps are automatically skipped.

The following video shows how to use Conditionals to skip a step when not needed.

The content in the demo page is accessible only after user clicks on the Agree button. Once agreed, the button is no longer visible until the cookie expires. We create a macro that clicks the button when present and skip when it it is not.

Please share your thoughts and feedback.

Future developments:

  1. Make it easier to move steps in and out of Condition block.

Seems to work well, thank you! I accidentally seem to have reset my Macro to the previously saved version by clicking on the “# steps” and had to redo my entire Condition block, but now that everything is set up properly it seems to be working. Will monitor it over time!

1 Like

I wish there a while as well, because the the pop up keeps coming for an uncertain number of times, so I believe a while loop would solve this problem, also what other conditions can we use in the if block, just like you used a button.

There is plan to add looping too.

what other conditions can we use in the if block

Currently we have “element_exists” and “element_has_text” for conditions in an If block. More conditions will be added on the basis of need.