Block reference / Control flow
Conditions
Send the run down one of several paths, depending on values, page elements or code.
In both apps
WarpX Browser
WarpX Phone
Use Conditions when the next step depends on something: a price, a variable, whether an element is on the page. You add paths, give each path its own conditions, and connect each path's output to the blocks it should run. The first path whose conditions hold is taken; if none holds, the run leaves by Fallback.
Settings
- Description
A note shown on the block in the canvas. It does not change what the block does.
ExampleRoute by price- Add path
Adds a path, named Path 1, Path 2 and so on, up to 20. Each path gets its own output on the block. Click the pencil to open its conditions and rename it at the top of that window; drag paths to change the order they are checked in.
ExampleOver budget In budget
- Condition builder
The window where you write a path's conditions. Each row is a left value, a comparison and a right value. AND adds a row that must also hold; OR starts a new group, and the path holds when any one group holds in full.
Example{{variables.price}} | Greater than | 100- Value
The first box of a row picks what to read: Value, Code, Data exists, Element text, Element exists, Element not exists, Element visible, Element visible in screen, Element hidden in screen or Element attribute value. The right side of a row can only be Value, Element text or Element attribute value. Types that answer yes or no by themselves, such as Element exists, need no comparison.
ExampleValue- Value
The text to compare, with
{{references}}allowed. For element types the box is CSS selector or XPath (plus Attribute name for an attribute), and for Data exists it is variables@variableName, such asvariables@discountCode.Example{{variables.price}}- Equals
The comparison. Options: Equals, Equals (case insensitive), Not equals, Greater than, Greater than or equal, Less than, Less than or equal, Contains, Contains (case insensitive), Not contains, Not contains (case insensitive), Starts with, Ends with, Match with RegEx, Is truthy and Is falsy.
ExampleGreater than- Retry if no conditions are met
Behind the settings button. When on and no path holds, the block checks all paths again instead of leaving by Fallback at once. Useful when you wait for a page to change.
ExampleUnchecked- Try forwhen Retry if no conditions are met is on
How many more times to check before giving up and leaving by Fallback.
Example10- Timeout (milliseconds)when Retry if no conditions are met is on
How long to wait between checks.
Example1000
Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.
What it hands on
Leaves by the output of the first path whose conditions hold, checked top to bottom. If none holds, it leaves by Fallback, the bottom output that appears once you add a path. The log records which path was taken and the values it compared.
Example: Skip products over budget
- Start
- New tab
- Get text
- Conditions
- Click element
- Add a New tab block with New tab URL set to the product page.
- Add a Get text block on
.product-price, tick Assign to variable and set Variable name toprice. - Add a Conditions block and click Add path twice. Rename the paths Over budget and In budget.
- Open Over budget and add the condition
{{variables.price}}Greater than100. - Open In budget and add
{{variables.price}}Less than or equal100. - Connect In budget to a Click element block on
button.add-to-cart. Leave Over budget and Fallback unconnected, so the run ends there.
On WarpX Phone
- A WarpX Phone run has no page. The Element types, and Code with Execution context Active tab, fail the block there. Value, Data exists and Code in Background work as they do here.
- To branch on what the phone shows, run the phone's Element exists block with Assign to variable ticked first, then compare that variable with Is truthy.
Good to know
- The first path that holds wins. Put the narrowest path at the top.
- A block with no paths fails with "Conditions are empty".
{{table.price}}reads the price column of the first row. Use{{table.$last.price}}for the latest row, or{{loopData.<id>.price}}inside a loop.- Equals compares text exactly, including case. Greater than and the other number comparisons treat both sides as numbers only when both look like plain numbers;
$120is compared as text. Start a value withnumber::,boolean::,json::orstring::to convert it, for examplenumber::100. - Code runs the JavaScript you write and uses what it returns, so it must
returna value. Execution context Background runs it in the app, away from the page; Active tab runs it in the page.automaRefDataand top-levelawaitwork in both. - Element types run in the page of the tab the workflow is working in, so a tab must be open. If the page cannot answer, the block fails with an error instead of guessing a path.
- Deleting a path also removes the connections from its output.
See also
- Element exists — Check whether an element is on the page and continue by one of two outputs.
- While loop — Keep running a stretch of blocks while a condition holds.
- Get text — Read the text of one element or many, and save it to the table or a variable.