アサーションリファレンス
アサーションはステップの結果を検証します。AI エージェントが MCP ツールを通じて QA プランを構築する際に、各ステップにアサーションを含めます。各ステップには、1 つ以上のアサーションオブジェクトを含む assertions 配列を指定できます。ステップが成功とみなされるには、ステップ内のすべてのアサーションがパスする必要があります。
HTTP アサーション
Section titled “HTTP アサーション”http_request アクションタイプのステップに適用されるアサーションです。
status_code
Section titled “status_code”レスポンスのステータスコードが正確な値と一致するかチェックします。
{ "type": "status_code", "expected": 200 }| フィールド | 型 | 説明 |
|---|---|---|
type | "status_code" | アサーションタイプの識別子です。 |
expected | number | 期待する HTTP ステータスコードです。 |
status_code_in
Section titled “status_code_in”レスポンスのステータスコードが許可された値のいずれかであるかチェックします。
{ "type": "status_code_in", "expected": [200, 201] }| フィールド | 型 | 説明 |
|---|---|---|
type | "status_code_in" | アサーションタイプの識別子です。 |
expected | number[] | 許容される HTTP ステータスコードの配列です。 |
json_path
Section titled “json_path”レスポンスボディ内の特定の JSON パスにある値を検証します。
{ "type": "json_path", "path": "$.user.email", "expected": "alice@example.com" }| フィールド | 型 | 説明 |
|---|---|---|
type | "json_path" | アサーションタイプの識別子です。 |
path | string | チェックする値を指す JSONPath 式です。 |
condition | "exists" | "not_exists" | "contains" | (省略可) 比較モードです。省略すると完全一致となります。 |
expected | any | (exists/not_exists 使用時は省略可) 期待する値です。 |
条件の動作:
- 省略 —
pathの値とexpectedの完全一致チェックを行います。 "exists"— 指定したパスに値が存在すればパスします。expectedフィールドは無視されます。"not_exists"— 指定したパスに値が存在しなければパスします。expectedフィールドは無視されます。"contains"—pathの文字列値がexpectedを部分文字列として含んでいればパスします。
ブラウザアサーション
Section titled “ブラウザアサーション”browser アクションタイプのステップに適用されるアサーションです。
element_text
Section titled “element_text”要素のテキストコンテンツをチェックします。
{ "type": "element_text", "selector": ".welcome-message" }{ "type": "element_text", "selector": ".welcome-message", "contains": "Hello" }| フィールド | 型 | 説明 |
|---|---|---|
type | "element_text" | アサーションタイプの識別子です。 |
selector | string | 対象要素の CSS セレクタです。 |
contains | string | (省略可) 要素のテキストに含まれるべき部分文字列です。省略すると、要素にテキストコンテンツがあることをアサートします。 |
element_visible
Section titled “element_visible”要素がページ上で表示されていることをアサートします。
{ "type": "element_visible", "selector": "#main-content" }| フィールド | 型 | 説明 |
|---|---|---|
type | "element_visible" | アサーションタイプの識別子です。 |
selector | string | 対象要素の CSS セレクタです。 |
element_not_visible
Section titled “element_not_visible”要素がページ上で表示されていないことをアサートします。
{ "type": "element_not_visible", "selector": ".error-banner" }| フィールド | 型 | 説明 |
|---|---|---|
type | "element_not_visible" | アサーションタイプの識別子です。 |
selector | string | 対象要素の CSS セレクタです。 |
url_contains
Section titled “url_contains”現在のページ URL が部分文字列を含むことをアサートします。
{ "type": "url_contains", "expected": "/dashboard" }| フィールド | 型 | 説明 |
|---|---|---|
type | "url_contains" | アサーションタイプの識別子です。 |
expected | string | URL に含まれるべき部分文字列です。 |
ページタイトルが正確な値と一致することをアサートします。
{ "type": "title", "expected": "Dashboard - My App" }| フィールド | 型 | 説明 |
|---|---|---|
type | "title" | アサーションタイプの識別子です。 |
expected | string | 期待するページタイトルです。 |
screenshot
Section titled “screenshot”スクリーンショットをキャプチャします。このアサーションは常にパスし、視覚的なドキュメントとして使用されます。
{ "type": "screenshot", "name": "checkout-page", "description": "Final state of the checkout form" }| フィールド | 型 | 説明 |
|---|---|---|
type | "screenshot" | アサーションタイプの識別子です。 |
name | string | (省略可) スクリーンショットファイルの名前です。 |
description | string | (省略可) スクリーンショットが何をキャプチャしているかの説明です。 |
element_count
Section titled “element_count”セレクタに一致する要素の数をアサートします。
{ "type": "element_count", "selector": ".cart-item", "expected": 3 }| フィールド | 型 | 説明 |
|---|---|---|
type | "element_count" | アサーションタイプの識別子です。 |
selector | string | 対象要素の CSS セレクタです。 |
expected | number | 一致する要素の期待数です。 |
element_attribute
Section titled “element_attribute”要素の属性値をアサートします。
{ "type": "element_attribute", "selector": "#submit-btn", "attribute": "disabled", "expected": "true" }| フィールド | 型 | 説明 |
|---|---|---|
type | "element_attribute" | アサーションタイプの識別子です。 |
selector | string | 対象要素の CSS セレクタです。 |
attribute | string | チェックする属性名です。 |
expected | string | 期待する属性値です。 |
cookie_exists
Section titled “cookie_exists”指定した名前のクッキーが存在することをアサートします。
{ "type": "cookie_exists", "name": "session_id" }| フィールド | 型 | 説明 |
|---|---|---|
type | "cookie_exists" | アサーションタイプの識別子です。 |
name | string | チェックするクッキー名です。 |
cookie_value
Section titled “cookie_value”クッキーの値をアサートします。
{ "type": "cookie_value", "name": "theme", "expected": "dark", "match": "exact" }| フィールド | 型 | 説明 |
|---|---|---|
type | "cookie_value" | アサーションタイプの識別子です。 |
name | string | クッキー名です。 |
expected | string | 期待するクッキーの値です。 |
match | "exact" | "contains" | (省略可) マッチモードです。デフォルトは "exact" です。 |
localstorage_exists
Section titled “localstorage_exists”localStorage にキーが存在することをアサートします。
{ "type": "localstorage_exists", "key": "auth_token" }| フィールド | 型 | 説明 |
|---|---|---|
type | "localstorage_exists" | アサーションタイプの識別子です。 |
key | string | チェックする localStorage のキーです。 |
localstorage_value
Section titled “localstorage_value”localStorage エントリの値をアサートします。
{ "type": "localstorage_value", "key": "locale", "expected": "en-US", "match": "exact" }| フィールド | 型 | 説明 |
|---|---|---|
type | "localstorage_value" | アサーションタイプの識別子です。 |
key | string | localStorage のキーです。 |
expected | string | 期待する値です。 |
match | "exact" | "contains" | (省略可) マッチモードです。デフォルトは "exact" です。 |