The ‘IfAssert’ action allows you to handle multiple scenarios in your journeys by checking for a selector then directing the script either to the ‘Then’ or ‘Else’. Within these two outcomes you are then able to include other actions such as a click, capture, send keys for each outcome to perform.
There are endless possible uses for the IfAssert however here are some common applications:
- Checking and closing a newsletter/cookie banner/pop-up without failing the journey
- Assisting in randomisation possibilities such as checking and clicking on sizing options if present occasionally on products
- Coping with light A/B testing such as a slight change in a button
It is worth noting however that for more complicated scenarios such as A/B testing with more than two scenarios we have the IfElement which is more equipped to handle this. Here is an example of the IfAssert in action:
In this example we are using the action in arguable its more common use which is checking and closing a cookie banner. The reason we might nestle the click within an IfAssert is incase the banner doesn’t appear which will cause a failure.
If we look into the fields within the action, the selector is the selector we are trying to evaluate. If the selector is clickable we will continue to the ‘Then’ scenario, if it isn’t clickable we will continue to the ‘Else’.