Assertions Reference
Assertions validate the outcome of a step. The AI agent includes assertions in QA plan steps when building plans via MCP tools. Each step can contain an assertions array with one or more assertion objects. All assertions in a step must pass for the step to be considered successful.
HTTP Assertions
Section titled “HTTP Assertions”These assertions apply to steps with the http_request action type.
status_code
Section titled “status_code”Check that the response status code matches an exact value.
{ "type": "status_code", "expected": 200 }| Field | Type | Description |
|---|---|---|
type | "status_code" | Assertion type identifier. |
expected | number | The expected HTTP status code. |
status_code_in
Section titled “status_code_in”Check that the response status code is one of the allowed values.
{ "type": "status_code_in", "expected": [200, 201] }| Field | Type | Description |
|---|---|---|
type | "status_code_in" | Assertion type identifier. |
expected | number[] | An array of acceptable HTTP status codes. |
json_path
Section titled “json_path”Validate a value at a specific JSON path in the response body.
{ "type": "json_path", "path": "$.user.email", "expected": "alice@example.com" }| Field | Type | Description |
|---|---|---|
type | "json_path" | Assertion type identifier. |
path | string | A JSONPath expression pointing to the value to check. |
condition | "exists" | "not_exists" | "contains" | (optional) The comparison mode. Omit for exact match. |
expected | any | (optional when using exists/not_exists) The expected value. |
Condition behavior:
- Omitted — Performs an exact equality check between the value at
pathandexpected. "exists"— Passes if a value exists at the given path. Theexpectedfield is ignored."not_exists"— Passes if no value exists at the given path. Theexpectedfield is ignored."contains"— Passes if the string value atpathcontainsexpectedas a substring.
Browser Assertions
Section titled “Browser Assertions”These assertions apply to steps with the browser action type.
element_text
Section titled “element_text”Check the text content of an element.
{ "type": "element_text", "selector": ".welcome-message" }{ "type": "element_text", "selector": ".welcome-message", "contains": "Hello" }| Field | Type | Description |
|---|---|---|
type | "element_text" | Assertion type identifier. |
selector | string | CSS selector for the target element. |
contains | string | (optional) Substring that the element’s text must contain. If omitted, asserts that the element has any text content. |
element_visible
Section titled “element_visible”Assert that an element is visible on the page.
{ "type": "element_visible", "selector": "#main-content" }| Field | Type | Description |
|---|---|---|
type | "element_visible" | Assertion type identifier. |
selector | string | CSS selector for the target element. |
element_not_visible
Section titled “element_not_visible”Assert that an element is not visible on the page.
{ "type": "element_not_visible", "selector": ".error-banner" }| Field | Type | Description |
|---|---|---|
type | "element_not_visible" | Assertion type identifier. |
selector | string | CSS selector for the target element. |
url_contains
Section titled “url_contains”Assert that the current page URL contains a substring.
{ "type": "url_contains", "expected": "/dashboard" }| Field | Type | Description |
|---|---|---|
type | "url_contains" | Assertion type identifier. |
expected | string | Substring that the URL must contain. |
Assert that the page title matches an exact value.
{ "type": "title", "expected": "Dashboard - My App" }| Field | Type | Description |
|---|---|---|
type | "title" | Assertion type identifier. |
expected | string | The expected page title. |
screenshot
Section titled “screenshot”Capture a screenshot. This assertion always passes and is used for visual documentation.
{ "type": "screenshot", "name": "checkout-page", "description": "Final state of the checkout form" }| Field | Type | Description |
|---|---|---|
type | "screenshot" | Assertion type identifier. |
name | string | (optional) A name for the screenshot file. |
description | string | (optional) A description of what the screenshot captures. |
element_count
Section titled “element_count”Assert the number of elements matching a selector.
{ "type": "element_count", "selector": ".cart-item", "expected": 3 }| Field | Type | Description |
|---|---|---|
type | "element_count" | Assertion type identifier. |
selector | string | CSS selector for the target elements. |
expected | number | The expected number of matching elements. |
element_attribute
Section titled “element_attribute”Assert the value of an element’s attribute.
{ "type": "element_attribute", "selector": "#submit-btn", "attribute": "disabled", "expected": "true" }| Field | Type | Description |
|---|---|---|
type | "element_attribute" | Assertion type identifier. |
selector | string | CSS selector for the target element. |
attribute | string | The attribute name to check. |
expected | string | The expected attribute value. |
cookie_exists
Section titled “cookie_exists”Assert that a cookie with the given name exists.
{ "type": "cookie_exists", "name": "session_id" }| Field | Type | Description |
|---|---|---|
type | "cookie_exists" | Assertion type identifier. |
name | string | The cookie name to check for. |
cookie_value
Section titled “cookie_value”Assert the value of a cookie.
{ "type": "cookie_value", "name": "theme", "expected": "dark", "match": "exact" }| Field | Type | Description |
|---|---|---|
type | "cookie_value" | Assertion type identifier. |
name | string | The cookie name. |
expected | string | The expected cookie value. |
match | "exact" | "contains" | (optional) Match mode. Defaults to "exact". |
localstorage_exists
Section titled “localstorage_exists”Assert that a key exists in localStorage.
{ "type": "localstorage_exists", "key": "auth_token" }| Field | Type | Description |
|---|---|---|
type | "localstorage_exists" | Assertion type identifier. |
key | string | The localStorage key to check for. |
localstorage_value
Section titled “localstorage_value”Assert the value of a localStorage entry.
{ "type": "localstorage_value", "key": "locale", "expected": "en-US", "match": "exact" }| Field | Type | Description |
|---|---|---|
type | "localstorage_value" | Assertion type identifier. |
key | string | The localStorage key. |
expected | string | The expected value. |
match | "exact" | "contains" | (optional) Match mode. Defaults to "exact". |