Skip to content

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.

These assertions apply to steps with the http_request action type.

Check that the response status code matches an exact value.

{ "type": "status_code", "expected": 200 }
FieldTypeDescription
type"status_code"Assertion type identifier.
expectednumberThe expected HTTP status code.

Check that the response status code is one of the allowed values.

{ "type": "status_code_in", "expected": [200, 201] }
FieldTypeDescription
type"status_code_in"Assertion type identifier.
expectednumber[]An array of acceptable HTTP status codes.

Validate a value at a specific JSON path in the response body.

{ "type": "json_path", "path": "$.user.email", "expected": "alice@example.com" }
FieldTypeDescription
type"json_path"Assertion type identifier.
pathstringA JSONPath expression pointing to the value to check.
condition"exists" | "not_exists" | "contains"(optional) The comparison mode. Omit for exact match.
expectedany(optional when using exists/not_exists) The expected value.

Condition behavior:

  • Omitted — Performs an exact equality check between the value at path and expected.
  • "exists" — Passes if a value exists at the given path. The expected field is ignored.
  • "not_exists" — Passes if no value exists at the given path. The expected field is ignored.
  • "contains" — Passes if the string value at path contains expected as a substring.

Binary responses: json_path always fails on a binary response (e.g. an image or PDF download) with an explicit message. Use header, body_size, or body_hash instead.

Validate a response header value. Header names are matched case-insensitively.

{ "type": "header", "name": "Content-Type", "expected": "application/json" }
{ "type": "header", "name": "Location", "condition": "contains", "expected": "/users/" }
{ "type": "header", "name": "X-Request-Id", "condition": "exists" }
{ "type": "header", "name": "Set-Cookie", "condition": "matches", "expected": "session_id=" }
FieldTypeDescription
type"header"Assertion type identifier.
namestringHeader name (case-insensitive).
condition"equals" | "contains" | "exists" | "not_exists" | "matches"(optional) Match condition. Defaults to "equals". "matches" interprets expected as a regular expression.
expectedstring(required for equals/contains/matches) The expected value or regex pattern.

Validate the byte length of the response body. Useful for verifying that file downloads are non-empty or fall within an expected range.

{ "type": "body_size", "expected": 12345 }
{ "type": "body_size", "condition": "between", "expected": [1000, 5000] }
{ "type": "body_size", "condition": "greater_than", "expected": 0 }
FieldTypeDescription
type"body_size"Assertion type identifier.
condition"equals" | "greater_than" | "less_than" | "between"(optional) Comparison condition. Defaults to "equals".
expectednumber | [number, number]Numeric byte count. For "between", pass a [min, max] tuple (inclusive on both ends).

Validate the hash digest of the response body. Useful for golden-file comparisons of generated reports (PDF, Excel, etc.).

{ "type": "body_hash", "expected": "<sha256 hex>" }
{ "type": "body_hash", "algorithm": "md5", "expected": "<md5 hex>" }
FieldTypeDescription
type"body_hash"Assertion type identifier.
algorithm"sha256" | "md5"(optional) Hash algorithm. Defaults to "sha256".
expectedstringExpected hex digest (case-insensitive).

Assert that the (text) response body contains a substring. Useful for HTML pages, plain-text webhooks, and other non-JSON text responses.

{ "type": "body_contains", "expected": "Welcome back" }
FieldTypeDescription
type"body_contains"Assertion type identifier.
expectedstringSubstring that must appear in the response body.

Binary responses: body_contains always fails on a binary response with an explicit message. Use body_size or body_hash instead.

These assertions apply to steps with the browser action type.

Check the text content of an element.

{ "type": "element_text", "selector": ".welcome-message" }
{ "type": "element_text", "selector": ".welcome-message", "contains": "Hello" }
FieldTypeDescription
type"element_text"Assertion type identifier.
selectorstringCSS selector for the target element.
containsstring(optional) Substring that the element’s text must contain. If omitted, asserts that the element has any text content.

Assert that an element is visible on the page.

{ "type": "element_visible", "selector": "#main-content" }
FieldTypeDescription
type"element_visible"Assertion type identifier.
selectorstringCSS selector for the target element.

Assert that an element is not visible on the page.

{ "type": "element_not_visible", "selector": ".error-banner" }
FieldTypeDescription
type"element_not_visible"Assertion type identifier.
selectorstringCSS selector for the target element.

Assert that the current page URL contains a substring.

{ "type": "url_contains", "expected": "/dashboard" }
FieldTypeDescription
type"url_contains"Assertion type identifier.
expectedstringSubstring that the URL must contain.

Assert that the page title matches an exact value.

{ "type": "title", "expected": "Dashboard - My App" }
FieldTypeDescription
type"title"Assertion type identifier.
expectedstringThe expected page title.

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" }
FieldTypeDescription
type"screenshot"Assertion type identifier.
namestring(optional) A name for the screenshot file.
descriptionstring(optional) A description of what the screenshot captures.

Assert the number of elements matching a selector.

{ "type": "element_count", "selector": ".cart-item", "expected": 3 }
FieldTypeDescription
type"element_count"Assertion type identifier.
selectorstringCSS selector for the target elements.
expectednumberThe expected number of matching elements.

Assert the value of an element’s attribute.

{ "type": "element_attribute", "selector": "#submit-btn", "attribute": "disabled", "expected": "true" }
FieldTypeDescription
type"element_attribute"Assertion type identifier.
selectorstringCSS selector for the target element.
attributestringThe attribute name to check.
expectedstringThe expected attribute value.

Assert that a cookie with the given name exists.

{ "type": "cookie_exists", "name": "session_id" }
FieldTypeDescription
type"cookie_exists"Assertion type identifier.
namestringThe cookie name to check for.

Assert the value of a cookie.

{ "type": "cookie_value", "name": "theme", "expected": "dark", "match": "exact" }
FieldTypeDescription
type"cookie_value"Assertion type identifier.
namestringThe cookie name.
expectedstringThe expected cookie value.
match"exact" | "contains"(optional) Match mode. Defaults to "exact".

Assert that a key exists in localStorage.

{ "type": "localstorage_exists", "key": "auth_token" }
FieldTypeDescription
type"localstorage_exists"Assertion type identifier.
keystringThe localStorage key to check for.

Assert the value of a localStorage entry.

{ "type": "localstorage_value", "key": "locale", "expected": "en-US", "match": "exact" }
FieldTypeDescription
type"localstorage_value"Assertion type identifier.
keystringThe localStorage key.
expectedstringThe expected value.
match"exact" | "contains"(optional) Match mode. Defaults to "exact".