# simulator_slider

> 这个 MCP 工具把团队模拟器上的标准滑块设置为某个百分比，并读回值。

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

`simulator_slider` 把团队正在运行的模拟器上的滑块移动到其轨道的 `percent` 处，然后再次读取滑块的值，确认它到达了目标。值最终必须在 3 个百分点以内；为此它最多移动滑块四次。滑块通过 [选择器](https://air.build/cn/docs/mcp-tools/simulator_find/#selector) 指定，从不通过坐标指定。工具总是查找角色为 `AXSlider` 的元素，并且始终是严格的，所以选择器必须恰好匹配一个滑块。它最多等待 10 秒。它只适用于标准的从左到右的 iOS 滑块，其辅助功能值为 0 到 1 的小数或百分比。自定义范围和竖直滑块会被拒绝。对于这些滑块，请使用 [simulator_adjust](https://air.build/cn/docs/mcp-tools/simulator_adjust/) 或 [simulator_drag](https://air.build/cn/docs/mcp-tools/simulator_drag/)。再次设置相同的百分比不会有影响。检查失败时，滑块可能已经移动过。

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

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `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`, `id`, `value`, `role`, `nodeId`, `exact`, `strict` | 见 [选择器](https://air.build/cn/docs/mcp-tools/simulator_find/#selector) | 前五个中至少一个 | — | 滑块。`role` 只能是 `AXSlider`；`strict` 始终开启 |
| `percent` | 数字，0 到 100 | 是 | — | 把滑块放在哪里：0 为左端，100 为右端 |

## 结果

| 字段 | 说明 |
| --- | --- |
| `element` | 移动后读取的滑块。它的 `value` 是现在的值。其他字段与 [simulator_find](https://air.build/cn/docs/mcp-tools/simulator_find/#result) 中相同 |
| `point` | `x`、`y`：滑块的点按位置 |
| `exact` | 它的文本是否与查询相同 |
| `matchCount` | `1` |
| `excluded` | 匹配但被排除的滑块，带有 `reason` |

```json
{
  "element": { "label": "Volume", "value": "0.75", "identifier": "volume", "role": "AXSlider",
               "frame": { "x": 16, "y": 400, "width": 370, "height": 44 }, "enabled": true, "interactive": true, "adjustable": true },
  "point": { "x": 201, "y": 422 },
  "exact": true,
  "matchCount": 1,
  "excluded": []
}
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| percent is required. | 缺少 `percent` | 发送 0 到 100 |
| percent must be a number from 0 to 100. | `percent` 超出范围 | 发送 0 到 100 |
| slider selector role must be AXSlider | `role` 指定了其他角色 | 省略 `role` 或发送 `AXSlider` |
| slider is disabled | 滑块呈灰色 | 先在 App 中启用它 |
| slider has no accessible percentage value | 滑块不报告值 | 使用 [simulator_drag](https://air.build/cn/docs/mcp-tools/simulator_drag/) |
| slider value is not normalized 0..1; custom ranges are unsupported | 滑块以它自己的刻度报告值 | 使用 [simulator_adjust](https://air.build/cn/docs/mcp-tools/simulator_adjust/) |
| no supported horizontal slider track | 该滑块不是标准的水平滑块 | 使用 [simulator_drag](https://air.build/cn/docs/mcp-tools/simulator_drag/) |
| slider track is off-screen | 轨道的一部分在屏幕外 | 用 [simulator_scroll_to](https://air.build/cn/docs/mcp-tools/simulator_scroll_to/) 把它滚动到视图中 |
| slider verification failed: requested _p_%, observed _q_% | 移动四次后，值仍相差超过 3 个百分点 | 用 [simulator_find](https://air.build/cn/docs/mcp-tools/simulator_find/) 读取它；重试或使用 `simulator_adjust` |
| ambiguous selector _selector_: _n_ usable matches; add an id, role, or value filter | 匹配到多个滑块 | 通过 `id` 或 `nodeId` 指定 |
| no usable element matching _selector_ within 10s | 10 秒内没有匹配到滑块 | 用 [simulator_find](https://air.build/cn/docs/mcp-tools/simulator_find/) 检查 |

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

## 示例

```json
{"name": "simulator_slider", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "id": "volume", "percent": 75}}
```
