When to Use Control Flow Bricks
The following table describes scenarios where you might use each type of control flow brick:
Scenario | Control Flow Brick | |
---|---|---|
You need to run multiple bricks if a condition is met | If-Else | |
You need to run one brick(s) if a condition is met, and a different brick(s) if the condition is not met | If-Else | |
You are calling an API that sometimes fails | Retry | |
You want to wait for a condition to be met. For example: an API results to change | Retry | In the Retry body, add a "Cancel Current Action" that runs if the condition has not been met yet (See Exceptions/Errors below) |
You want to wait for an element to appear on the page | N/A - use the Wait for a DOM element brick | Trick question! The Wait for a DOM element brick has better performance because it can use native browser APIs to detect new elements |
You want to show a custom error message/instructions to the user if a brick fails | Try-Except | Leave the catch branch blank |
You want to ignore an error code when calling an API | Try-Except | Leave the catch branch blank |
You want to perform an action for each item in a list of items returned from an API | For-Each | By default an element key is made available to the body You can customize the name of the key provided to the body |
You want to preform an action for each element currently on the page that matches a selector | For-Each Element | Current the Page Editor does not support selecting multiple elements. You must manually tweak the automatically generated selector to match multiple elements |
Last updated