Most eCommerce websites include pop-ups for advertising new products, sales initiatives or trying to capture user data such as email addresses for marketing campaigns. These kinds of behaviours can be problematic to Synthetic User Journeys. They are often unpredictable and block elements that your Scripts are targeting. A real user can deal with these situations by simply deciding to close the pop-up. However, Synthetic scripts are much more fixed and need to have this intelligence “coded in”.
To handle these scenarios, we first need to determine the parameters for a pop-up appearing. Are they triggered by simply navigating to a specific page, or based on the length of time a user has been visiting the website? In either case, an IfElement action can be used to deal with them. However, we need to know where the pop-up might appear so we know where to place the action.
IfElement actions enable you to add intelligent logic to handle situations that are not guaranteed to always occur in the same way. They use a coding practice called if/else to determine which actions to run. The ‘if’ logic has a WaitForElement-style logic that allows you to do things like this:
By dealing with pop-ups in this way, you’re able to avoid journeys failing due to non-issues that could otherwise could cause test failures.