# \[Feature\] Conditions in Macros

**URL:** <https://forums.distill.io/t/feature-conditions-in-macros/2586>\
**Category:** Announcements\
**Tags:** conditions, macros\
**Created:** [October 9, 2023, 7:06am UTC](https://forums.distill.io/t/feature-conditions-in-macros/2586 "2023-10-09T07:06:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [October 9, 2023, 7:06am UTC](https://forums.distill.io/t/feature-conditions-in-macros/2586/1 "2023-10-09T07:06:01Z")

</div>

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.

```auto
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:

> [@Conditionally skip a macro step?](https://forums.distill.io/t/conditionally-skip-a-macro-step/2496):
>
> The website I’m monitoring sometimes has an initial “Click here to continue” message, and sometimes doesn’t. The times that it does not, my macro, which is set to click the “Click here to continue” button, fails because it doesn’t find that button. Is there any way for that step in my macro to be skipped for the times the button doesn’t show up? But continue to click it for the times that it does show up?

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.

[https://www.loom.com/share/bead83d7b2ec46178beac6f275ba7d1e?sid=118f75d1-3402-4b85-84e2-54c92bc8ff81](https://www.loom.com/share/bead83d7b2ec46178beac6f275ba7d1e?sid=118f75d1-3402-4b85-84e2-54c92bc8ff81)

**Please share your thoughts and feedback.**

**Future developments** :

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

---

_[View the full topic](https://forums.distill.io/t/feature-conditions-in-macros/2586)._
