assert_condition
Verify an expected browser condition, such as element visibility or URL match, and raise an error if the assertion fails or times out. Use for read-only checks that enforce page state without modifying content.
Instructions
Verify a browser condition and report failure as an error.
Use this tool when an expected page state must be explicitly verified. It is a read-only verification operation: it does not click, type, navigate, scroll, or otherwise intentionally modify the page.
Element and text assertions may block while SeleniumBase waits for the
condition, up to timeout seconds. Title and URL assertions are checked
immediately and ignore timeout. A failed assertion or timeout is
handled by handle_sb_errors and returned as a descriptive tool error;
it is not reported as a successful result.
Unlike check_if_condition, this tool does not merely return whether a condition is true: a failed expectation is an error. Unlike wait_for_condition, its purpose is to verify an expectation, not merely synchronize with a changing page.
Args: check: - "element_present": Verify that the selector identifies a present element. - "element_visible": Verify that the selector identifies a visible element. - "text_visible": Verify that expected text is visible within selector, or within the whole HTML document if selector is omitted. - "title": Verify the exact current page title immediately. - "url": Verify the exact current URL immediately. - "url_contains": Verify that the current URL contains expected immediately.
selector: CSS or SeleniumBase selector for element and text checks.
Required for element checks; optional for text_visible.
expected: Expected text, title, or URL value. Required for
text_visible, title, url, and url_contains.
exact: For text_visible only, require an exact text match instead
of a substring match.
timeout: Maximum seconds to wait for element/text assertions.
Must be >= 0. Ignored for title and URL assertions.Returns: A confirmation message when the assertion passes. If the assertion fails or times out, the error handler returns the resulting error instead of a success message.
Tool selection: - Inspect a condition without failing -> check_if_condition. - Wait for a condition to become true -> wait_for_condition. - Verify that an expected condition is true -> assert_condition.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| check | No | element_visible | |
| exact | No | ||
| timeout | No | ||
| expected | No | ||
| selector | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |