コンテンツにスキップ

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

アサーションはステップの結果を検証します。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 を部分文字列として含んでいればパスします。

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" です。