> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# アクション

> 手順書の12種類のアクション型リファレンス。

## 概要

各ステップには `type` フィールドを持つ `action` オブジェクトがあります。使用可能なフィールドはアクション型によって異なります。

## 共通アクションフィールド

| フィールド      | 型                              |  必須  | 説明                                    |
| ---------- | ------------------------------ | :--: | ------------------------------------- |
| `type`     | ActionType                     |  Yes | 以下の12種類のアクション型                        |
| `selector` | [Selector](/ja/yaml/selectors) | 型による | 対象要素（click, input, select, hover で必須） |
| `value`    | string                         | 型による | テキスト値 — `{{variable}}` テンプレート構文対応     |

## アクション型

### `click`

DOM 要素をクリックします。

```yaml theme={null}
action:
  type: click
  selector:
    tagName: button
    innerText: "Submit"
```

| フィールド      |  必須 | 説明       |
| ---------- | :-: | -------- |
| `selector` | Yes | クリックする要素 |

### `input`

フォームフィールドにテキストを入力します。入力前にフィールドはクリアされます。

```yaml theme={null}
action:
  type: input
  value: "{{email}}"
  selector:
    tagName: input
    inputType: email
```

| フィールド      |  必須 | 説明                              |
| ---------- | :-: | ------------------------------- |
| `selector` | Yes | 入力要素                            |
| `value`    | Yes | 入力テキスト（`{{variable}}` テンプレート対応） |

### `select`

`<select>` ドロップダウンからオプションを選択します。

```yaml theme={null}
action:
  type: select
  value: "us-west-2"
  optionText: "US West (Oregon)"
  selector:
    tagName: select
    name: "region"
```

| フィールド        |  必須 | 説明                      |
| ------------ | :-: | ----------------------- |
| `selector`   | Yes | select 要素               |
| `value`      |  No | オプションの `value` 属性       |
| `optionText` |  No | 表示テキスト（`value` 未設定時に使用） |

### `navigate`

ブラウザを URL に遷移させます。

```yaml theme={null}
action:
  type: navigate
  url: "https://app.example.com/dashboard"
```

| フィールド |  必須 | 説明      |
| ----- | :-: | ------- |
| `url` | Yes | 遷移先 URL |

### `scroll`

ページをスクロールします。追加フィールドは不要です。

```yaml theme={null}
action:
  type: scroll
```

### `wait`

指定の条件または一定時間待機します。非同期ロードのページで有用です。

```yaml theme={null}
action:
  type: wait
```

### `hover`

要素にホバーしてメニューやツールチップを表示します。

```yaml theme={null}
action:
  type: hover
  selector:
    tagName: div
    ariaLabel: "User menu"
```

| フィールド      |  必須 | 説明      |
| ---------- | :-: | ------- |
| `selector` | Yes | ホバーする要素 |

### `extract`

ページコンテキストで JavaScript を実行し、結果をキャプチャします。

```yaml theme={null}
action:
  type: extract
  script: "document.querySelector('.total').textContent"
captures:
  - name: totalAmount
    strategy: expression
    expression: "{{__extracted}}"
```

| フィールド    |  必須 | 説明                  |
| -------- | :-: | ------------------- |
| `script` | Yes | ページで評価する JavaScript |

<Tip>
  抽出された値は `{{__extracted}}` として[キャプチャ](/ja/yaml/captures)で使用できます。
</Tip>

### `download`

クリックやナビゲーションでトリガーされるファイルをダウンロードします。

```yaml theme={null}
action:
  type: download
  downloadPath: "./downloads/report.csv"
  selector:
    tagName: a
    innerText: "Download CSV"
```

| フィールド          |  必須 | 説明              |
| -------------- | :-: | --------------- |
| `selector`     |  No | ダウンロードをトリガーする要素 |
| `downloadPath` |  No | ファイルの保存先パス      |

### `export`

[メモリコレクション](/ja/yaml/memory-operations)を CSV または JSON ファイルにエクスポートします。

```yaml theme={null}
action:
  type: export
  exportCollection: "products"
  exportFormat: csv
  exportPath: "./output/products.csv"
```

| フィールド              |  必須 | 説明               |
| ------------------ | :-: | ---------------- |
| `exportCollection` | Yes | メモリコレクション名       |
| `exportFormat`     | Yes | `csv` または `json` |
| `exportPath`       | Yes | 出力ファイルパス         |

### `memory`

[メモリ操作](/ja/yaml/memory-operations)（append または aggregate）を実行します。このアクション型はショートハンドです。任意のステップで `memoryOperations` を使用することもできます。

```yaml theme={null}
action:
  type: memory
```

詳細は[メモリ操作](/ja/yaml/memory-operations)を参照してください。

### `key`

キーボードキーまたはキーの組み合わせを押します。

```yaml theme={null}
action:
  type: key
  keys: "Enter"
```

| フィールド  |  必須 | 説明                                                             |
| ------ | :-: | -------------------------------------------------------------- |
| `keys` | Yes | Playwright 形式のキー名（例: `Enter`, `Tab`, `ArrowDown`, `Control+a`） |

## サマリーテーブル

| アクション      | セレクタ |  値  | その他のフィールド                                        |
| ---------- | :--: | :-: | ------------------------------------------------ |
| `click`    |  必須  |  —  | —                                                |
| `input`    |  必須  |  必須 | —                                                |
| `select`   |  必須  |  任意 | `optionText`                                     |
| `navigate` |   —  |  —  | `url`                                            |
| `scroll`   |   —  |  —  | —                                                |
| `wait`     |   —  |  —  | —                                                |
| `hover`    |  必須  |  —  | —                                                |
| `extract`  |   —  |  —  | `script`                                         |
| `download` |  任意  |  —  | `downloadPath`                                   |
| `export`   |   —  |  —  | `exportCollection`, `exportFormat`, `exportPath` |
| `memory`   |   —  |  —  | —                                                |
| `key`      |   —  |  —  | `keys`                                           |
