# simulator_scroll_to

> 这个 MCP 工具滚动团队模拟器的屏幕，直到某个元素可见，但不点按它。

Source: https://air.build/cn/docs/mcp-tools/simulator_scroll_to/

`simulator_scroll_to` 在团队正在运行的模拟器上一次一次地轻扫滚动，直到某个元素完全出现在屏幕上，然后停止。它不会点按该元素：之后请使用 [simulator_tap](https://air.build/cn/docs/mcp-tools/simulator_tap/)。已经在屏幕上的元素无需轻扫。每次轻扫最多移动滚动区域的一半，并轻轻松开，所以内容不会甩过该元素。当元素出现、内容不再移动（到达列表末尾）、轻扫 `maxScrolls` 次后，或经过 `timeoutSeconds` 后，查找结束；查找失败时，屏幕可能已经滚动过。一次查找最长持续 25 秒：再次调用即可继续。

`direction` 表示内容所在的方向，而不是手指移动的方向：`down`（默认值）会显示下方的内容，所以手指向上移动。当屏幕有多个滚动区域时，用 `withinId` 或 `withinText` 指定要滚动的区域：它必须恰好匹配一个可见元素。

| 只读 | 破坏性 | 幂等 |
| --- | --- | --- |
| 否 | 否 | 否 |

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字符串（UUID） | 是 | — | 团队，来自 [list_teams](https://air.build/cn/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 团队的默认设备 | 哪种设备，使用 [list_simulators](https://air.build/cn/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `text` | string | `text`、`id`、`nodeId` 之一 | — | 元素的可见文本，与 [选择器](https://air.build/cn/docs/mcp-tools/simulator_find/#selector) 中相同 |
| `id` | string | `text`、`id`、`nodeId` 之一 | — | 元素的 `accessibilityIdentifier` |
| `nodeId` | string | `text`、`id`、`nodeId` 之一 | — | 来自 [simulator_describe_ui](https://air.build/cn/docs/mcp-tools/simulator_describe_ui/) 的 `nodeId` |
| `exact` | boolean | 否 | `false` | `text` 必须完全匹配 |
| `direction` | 字符串：`down`、`up`、`left` 或 `right` | 否 | `down` | 要显示的内容所在的方向 |
| `withinId` | string | 否 | 整个屏幕 | 滚动区域，按它的 `accessibilityIdentifier` 指定 |
| `withinText` | string | 否 | 整个屏幕 | 滚动区域，按它的文本指定 |
| `withinExact` | boolean | 否 | `false` | `withinText` 必须完全匹配 |
| `timeoutSeconds` | 数字，0 到 25 | 否 | `20` | 查找多长时间，以秒计 |
| `maxScrolls` | 整数，1 到 100 | 否 | `25` | 最多轻扫多少次 |

## 结果

| 字段 | 说明 |
| --- | --- |
| `ok` | `true` |
| `element`, `point`, `exact`, `matchCount`, `excluded` | 找到的元素，与 [simulator_tap](https://air.build/cn/docs/mcp-tools/simulator_tap/#result) 中相同 |
| `scrolls` | 轻扫了多少次 |
| `elapsedMs` | 耗时，以毫秒计 |

```json
{ "ok": true, "element": { "label": "Settings", "role": "AXCell", "frame": { "x": 0, "y": 610, "width": 402, "height": 44 }, "enabled": true, "interactive": true, "adjustable": false },
  "point": { "x": 201, "y": 632 }, "exact": true, "matchCount": 1, "excluded": [], "scrolls": 3, "elapsedMs": 4200 }
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| Name the element: text, id or nodeId. | 三者都没有提供 | 添加一个 |
| direction must be one of down, up, left, right. | 其他 `direction` | 使用这四种之一 |
| scroll content stopped changing after _n_ swipes without revealing _selector_; reached the end or the gesture did not scroll | 到达内容末尾，或该区域无法滚动 | 尝试另一个 `direction`，或指定滚动区域 |
| _selector_ not visible after _n_ scroll attempts | 已达到 `maxScrolls` | 再次调用，或调高 `maxScrolls` |
| scroll-to _selector_ did not happen within _n_s | 时间用完了 | 再次调用以继续 |
| scroll container _selector_ must match exactly one visible element (found _n_) | `withinId` / `withinText` 没有匹配到，或匹配到多个 | 缩小范围 |
| max-scrolls must be between 1 and 100 | `maxScrolls` 超出范围 | 发送 1 到 100 |

另外还有每个模拟器工具都可能返回的错误：见 [start_simulator](https://air.build/cn/docs/mcp-tools/start_simulator/#device-errors)。

## 示例

```json
{"name": "simulator_scroll_to", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "text": "Settings", "direction": "down"}}
```
