コンテンツにスキップ

アサーションリファレンス

アサーションはステップの結果を検証します。AI エージェントが MCP ツールを通じて QA プランを構築する際に、各ステップにアサーションを含めます。各ステップには、1 つ以上のアサーションオブジェクトを含む assertions 配列を指定できます。ステップが成功とみなされるには、ステップ内のすべてのアサーションがパスする必要があります。

http_request アクションタイプのステップに適用されるアサーションです。

レスポンスのステータスコードが正確な値と一致するかチェックします。

{ "type": "status_code", "expected": 200 }
フィールド説明
type"status_code"アサーションタイプの識別子です。
expectednumber期待する HTTP ステータスコードです。

レスポンスのステータスコードが許可された値のいずれかであるかチェックします。

{ "type": "status_code_in", "expected": [200, 201] }
フィールド説明
type"status_code_in"アサーションタイプの識別子です。
expectednumber[]許容される HTTP ステータスコードの配列です。

レスポンスボディ内の特定の JSON パスにある値を検証します。

{ "type": "json_path", "path": "$.user.email", "expected": "alice@example.com" }
フィールド説明
type"json_path"アサーションタイプの識別子です。
pathstringチェックする値を指す JSONPath 式です。
condition"exists" | "not_exists" | "contains"(省略可) 比較モードです。省略すると完全一致となります。
expectedanyexists/not_exists 使用時は省略可) 期待する値です。

条件の動作:

  • 省略path の値と expected の完全一致チェックを行います。
  • "exists" — 指定したパスに値が存在すればパスします。expected フィールドは無視されます。
  • "not_exists" — 指定したパスに値が存在しなければパスします。expected フィールドは無視されます。
  • "contains"path の文字列値が expected を部分文字列として含んでいればパスします。

バイナリレスポンス: json_path はバイナリレスポンス(画像や PDF ダウンロード等)では常に失敗し、明示的なメッセージを返します。代わりに headerbody_sizebody_hash を使用してください。

レスポンスヘッダーの値を検証します。ヘッダー名は大文字小文字を区別しません。

{ "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=" }
フィールド説明
type"header"アサーションタイプの識別子です。
namestringヘッダー名(大文字小文字を区別しない)。
condition"equals" | "contains" | "exists" | "not_exists" | "matches"(省略可) マッチ条件。既定は "equals""matches"expected を正規表現として扱う。
expectedstring(equals/contains/matches で必須) 期待する値、または正規表現パターン。

レスポンス body のバイト長を検証します。ダウンロードファイルが空でないことや、想定範囲に収まることの確認に有効です。

{ "type": "body_size", "expected": 12345 }
{ "type": "body_size", "condition": "between", "expected": [1000, 5000] }
{ "type": "body_size", "condition": "greater_than", "expected": 0 }
フィールド説明
type"body_size"アサーションタイプの識別子です。
condition"equals" | "greater_than" | "less_than" | "between"(省略可) 比較条件。既定は "equals"
expectednumber | [number, number]期待するバイト数。"between" の場合は [min, max] のタプル(両端含む)を指定。

レスポンス body のハッシュ値を検証します。生成 PDF / Excel 等の golden file 比較に有効です。

{ "type": "body_hash", "expected": "<sha256 hex>" }
{ "type": "body_hash", "algorithm": "md5", "expected": "<md5 hex>" }
フィールド説明
type"body_hash"アサーションタイプの識別子です。
algorithm"sha256" | "md5"(省略可) ハッシュアルゴリズム。既定は "sha256"
expectedstring期待する hex digest(大文字小文字を区別しない)。

(テキスト)レスポンス body に部分文字列が含まれることを検証します。HTML ページ、プレーンテキスト webhook 等の非 JSON テキストレスポンスに有効です。

{ "type": "body_contains", "expected": "Welcome back" }
フィールド説明
type"body_contains"アサーションタイプの識別子です。
expectedstringレスポンス body に含まれているべき部分文字列。

バイナリレスポンス: body_contains はバイナリレスポンスでは常に失敗し、明示的なメッセージを返します。代わりに body_size または body_hash を使用してください。

browser アクションタイプのステップに適用されるアサーションです。

要素のテキストコンテンツをチェックします。

{ "type": "element_text", "selector": ".welcome-message" }
{ "type": "element_text", "selector": ".welcome-message", "contains": "Hello" }
フィールド説明
type"element_text"アサーションタイプの識別子です。
selectorstring対象要素の CSS セレクタです。
containsstring(省略可) 要素のテキストに含まれるべき部分文字列です。省略すると、要素にテキストコンテンツがあることをアサートします。

要素がページ上で表示されていることをアサートします。

{ "type": "element_visible", "selector": "#main-content" }
フィールド説明
type"element_visible"アサーションタイプの識別子です。
selectorstring対象要素の CSS セレクタです。

要素がページ上で表示されていないことをアサートします。

{ "type": "element_not_visible", "selector": ".error-banner" }
フィールド説明
type"element_not_visible"アサーションタイプの識別子です。
selectorstring対象要素の CSS セレクタです。

現在のページ URL が部分文字列を含むことをアサートします。

{ "type": "url_contains", "expected": "/dashboard" }
フィールド説明
type"url_contains"アサーションタイプの識別子です。
expectedstringURL に含まれるべき部分文字列です。

ページタイトルが正確な値と一致することをアサートします。

{ "type": "title", "expected": "Dashboard - My App" }
フィールド説明
type"title"アサーションタイプの識別子です。
expectedstring期待するページタイトルです。

スクリーンショットをキャプチャします。このアサーションは常にパスし、視覚的なドキュメントとして使用されます。

{ "type": "screenshot", "name": "checkout-page", "description": "Final state of the checkout form" }
フィールド説明
type"screenshot"アサーションタイプの識別子です。
namestring(省略可) スクリーンショットファイルの名前です。
descriptionstring(省略可) スクリーンショットが何をキャプチャしているかの説明です。

セレクタに一致する要素の数をアサートします。

{ "type": "element_count", "selector": ".cart-item", "expected": 3 }
フィールド説明
type"element_count"アサーションタイプの識別子です。
selectorstring対象要素の CSS セレクタです。
expectednumber一致する要素の期待数です。

要素の属性値をアサートします。

{ "type": "element_attribute", "selector": "#submit-btn", "attribute": "disabled", "expected": "true" }
フィールド説明
type"element_attribute"アサーションタイプの識別子です。
selectorstring対象要素の CSS セレクタです。
attributestringチェックする属性名です。
expectedstring期待する属性値です。

指定した名前のクッキーが存在することをアサートします。

{ "type": "cookie_exists", "name": "session_id" }
フィールド説明
type"cookie_exists"アサーションタイプの識別子です。
namestringチェックするクッキー名です。

クッキーの値をアサートします。

{ "type": "cookie_value", "name": "theme", "expected": "dark", "match": "exact" }
フィールド説明
type"cookie_value"アサーションタイプの識別子です。
namestringクッキー名です。
expectedstring期待するクッキーの値です。
match"exact" | "contains"(省略可) マッチモードです。デフォルトは "exact" です。

localStorage にキーが存在することをアサートします。

{ "type": "localstorage_exists", "key": "auth_token" }
フィールド説明
type"localstorage_exists"アサーションタイプの識別子です。
keystringチェックする localStorage のキーです。

localStorage エントリの値をアサートします。

{ "type": "localstorage_value", "key": "locale", "expected": "en-US", "match": "exact" }
フィールド説明
type"localstorage_value"アサーションタイプの識別子です。
keystringlocalStorage のキーです。
expectedstring期待する値です。
match"exact" | "contains"(省略可) マッチモードです。デフォルトは "exact" です。