# simulator_tap

> 這個 MCP 工具會在團隊模擬器的螢幕上某個點，或在選擇器指定的元素上點一下或長按。

Source: https://air.build/tw/docs/mcp-tools/simulator_tap/

`simulator_tap` 會以下列兩種方式之一點一下團隊正在執行的模擬器的螢幕。必須剛好提供一種：

- **座標**：`x` 和 `y`，使用 [螢幕座標](https://air.build/tw/docs/mcp-tools/simulator_screen/#coordinates)。點一下會立即落在那裡，無論下方是什麼。
- **元素**：一個選擇器，可以是 `text`、`id`、`value`、`role` 和來自 [simulator_describe_ui](https://air.build/tw/docs/mcp-tools/simulator_describe_ui/) 或 [simulator_find](https://air.build/tw/docs/mcp-tools/simulator_find/) 的 `nodeId` 中的任意幾個（請參閱 [選擇器](https://air.build/tw/docs/mcp-tools/simulator_find/#selector)）。工具最多等待 `timeoutSeconds`，直到出現已啟用且靜止的符合元素，然後點一下它（它的中心，或對於開關等控制項由 iOS 提供的點）。它不會捲動：請先用 [simulator_scroll_to](https://air.build/tw/docs/mcp-tools/simulator_scroll_to/) 把元素帶到螢幕上。

`duration` 會按住手指：即長按。工具不會檢查點一下的效果；請用 [simulator_describe_ui](https://air.build/tw/docs/mcp-tools/simulator_describe_ui/) 查看，或用 [simulator_wait](https://air.build/tw/docs/mcp-tools/simulator_wait/) 等待結果。

| 唯讀 | 破壞性 | 冪等 |
| --- | --- | --- |
| 否 | 否 | 否 |

## 輸入

| 輸入 | 類型 | 必填 | 預設值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字串（UUID） | 是 | — | 團隊，來自 [list_teams](https://air.build/tw/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 團隊的預設裝置 | 哪種裝置，使用 [list_simulators](https://air.build/tw/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `x` | 數字，-100000 到 100000 | 與 `y` 一起使用 | — | 點一下的位置，橫向 |
| `y` | 數字，-100000 到 100000 | 與 `x` 一起使用 | — | 點一下的位置，縱向 |
| `text`, `id`, `value`, `role`, `nodeId`, `exact`, `strict` | 請參閱 [選擇器](https://air.build/tw/docs/mcp-tools/simulator_find/#selector) | 代替 `x`、`y` | — | 要點一下的元素 |
| `duration` | 數字，0 到 60 | 否 | 一般的點一下 | 按住的秒數：長按 |
| `timeoutSeconds` | 數字，0 到 600 | 否 | `10` | 使用選擇器時：等待元素的時間 |
| `display` | string | 否 | 正在使用的顯示器 | 使用座標且在摺疊裝置上時：來自 [simulator_displays](https://air.build/tw/docs/mcp-tools/simulator_displays/) 的顯示器 `screenId` |

## 結果

使用座標時：

| 欄位 | 說明 |
| --- | --- |
| `ok` | `true` |

使用選擇器時：

| 欄位 | 說明 |
| --- | --- |
| `ok` | `true` |
| `element` | 被點一下的元素（欄位與 [simulator_find](https://air.build/tw/docs/mcp-tools/simulator_find/#result) 中相同） |
| `point` | `x`、`y`：點一下落下的位置 |
| `exact` | 它的文字是否與查詢相同 |
| `matchCount` | 有多少可用元素符合；大於 1 表示由排序選擇 |
| `excluded` | 符合但被排除的元素，帶有 `reason` |
| `elapsedMs` | 等待超過一輪時：等待了多久，以毫秒計 |

```json
{
  "ok": true,
  "element": { "label": "New note", "identifier": "new-note", "role": "AXButton",
               "frame": { "x": 16, "y": 120, "width": 370, "height": 52 }, "enabled": true, "interactive": true, "adjustable": false },
  "point": { "x": 201, "y": 146 },
  "exact": true,
  "matchCount": 1,
  "excluded": []
}
```

## 錯誤

| 訊息 | 何時出現 | 處理方式 |
| --- | --- | --- |
| Give both x and y. | 只有一個座標 | 兩個都傳送 |
| Give coordinates or a selector, not both. | 同時提供了座標和選擇器欄位 | 只傳送其中一種 |
| Name the element: text, id, value, role or nodeId. | 既沒有座標也沒有選擇器 | 傳送其中一個 |
| no usable element matching _selector_ within _n_s | 在時限內沒有符合可用的元素 | 請參閱 [選擇器錯誤](https://air.build/tw/docs/mcp-tools/simulator_find/#selector) |

另外還有其他 [選擇器錯誤](https://air.build/tw/docs/mcp-tools/simulator_find/#selector)，以及每個模擬器工具都可能傳回的錯誤：請參閱 [start_simulator](https://air.build/tw/docs/mcp-tools/start_simulator/#device-errors)。

## 範例

```json
{"name": "simulator_tap", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "id": "new-note"}}
```
