Skip to main content
Use assert_locator_node to check whether a specific element is present on the page and store the result. It evaluates a Playwright locator within a timeout and writes a boolean into output_variable_name (true if the assertion passes, false if it does not). You then branch on that variable with an if_else_node. This is the lowest-overhead way to capture element presence—no LLM call, no extraction step, just a direct visibility check that becomes a reusable variable.

Structure

{
  "type": "assert_locator_node",
  "locator": "get_by_role(\"alert\", name=\"Error\")",
  "assertion": "to_be_visible",
  "output_variable_name": "error_visible",
  "timeout": 5.0
}
The node above stores error_visible = [true] or error_visible = [false]. Reference it later as {error_visible[0]}.

Properties

PropertyTypeDefaultDescription
type"assert_locator_node"RequiredNode discriminator
locatorstrRequiredPlaywright locator command (page.<locator> style)
assertion"to_be_visible" | "to_be_hidden"RequiredCondition to test
output_variable_namestrRequiredVariable to store the boolean result, as a single-element list (e.g. [true])
timeoutfloat5.0Seconds to wait for the assertion before treating it as failed
The result is stored as a single-element list, matching the convention used by other variables, so you reference it with index [0] (e.g. {error_visible[0]}).

Assertions

AssertionResult is true when
to_be_visibleThe element exists in the DOM and is visible within timeout seconds
to_be_hiddenThe element is absent or hidden within timeout seconds
If the assertion does not pass within timeout, the variable is set to false (no error is raised). If the locator does not resolve at all, the result is also false.

Examples

Dismiss an element only when it appears

Check whether an error alert is visible, then dismiss it with a following if_else_node:
[
  {
    "type": "assert_locator_node",
    "locator": "get_by_role(\"alert\", name=\"Error\")",
    "assertion": "to_be_visible",
    "output_variable_name": "error_visible",
    "timeout": 5.0
  },
  {
    "type": "if_else_node",
    "condition": "{error_visible[0]}",
    "if_nodes": [
      {
        "type": "action_node",
        "interaction_action": {
          "click_element": {
            "command": "get_by_role(\"button\", name=\"Dismiss\")"
          }
        }
      }
    ],
    "else_nodes": []
  }
]

Wait for a spinner to disappear, then branch

Wait up to 10 seconds for a loading spinner to be hidden, then submit or fail:
[
  {
    "type": "assert_locator_node",
    "locator": "get_by_test_id(\"loading-spinner\")",
    "assertion": "to_be_hidden",
    "output_variable_name": "spinner_gone",
    "timeout": 10.0
  },
  {
    "type": "if_else_node",
    "condition": "{spinner_gone[0]}",
    "if_nodes": [
      {
        "type": "action_node",
        "interaction_action": {
          "click_element": {
            "command": "get_by_role(\"button\", name=\"Submit\")"
          }
        }
      }
    ],
    "else_nodes": [
      {
        "type": "action_node",
        "misc_action": {
          "fail_state": {
            "message": "Loading spinner did not disappear within 10 seconds"
          }
        }
      }
    ]
  }
]

Variable substitution in the locator

locator supports {variable[index]} substitution, so you can target elements dynamically:
{
  "type": "assert_locator_node",
  "locator": "get_by_text(\"{order_id[0]}\")",
  "assertion": "to_be_visible",
  "output_variable_name": "order_found",
  "timeout": 5.0
}

assert_locator_node vs if_else_node

assert_locator_nodeif_else_node
RoleCaptures element visibility as a boolean variableBranches on a Python expression over a variable
ConditionPlaywright locator visibilityPython expression on a variable
Requires extraction?NoYes — needs a variable to branch on (e.g. from assert_locator_node or an extraction_action)
CostZero (no LLM)Zero (expression eval)
Best forElement present/absent checksActing on a captured boolean or comparing extracted values
assert_locator_node produces the boolean; if_else_node consumes it. Pair them to run steps conditionally on element presence, or use the variable in any later condition.

Locator Syntax

The locator field uses the same Playwright command syntax as interaction actions—omit the leading page.:
{ "locator": "get_by_role(\"button\", name=\"Submit\")" }
{ "locator": "get_by_label(\"Email\")" }
{ "locator": "get_by_text(\"Order confirmed\")" }
{ "locator": "locator(\"#error-banner\")" }
For full locator syntax guidance see Locators.