simulator_scroll_to
這個 MCP 工具會捲動團隊模擬器的螢幕,直到某個元素可見,但不點一下它。
simulator_scroll_to 會在團隊正在執行的模擬器上一次一次地滑動捲動,直到某個元素完全出現在螢幕上,然後停止。它不會點一下該元素:之後請使用 simulator_tap。已經在螢幕上的元素不需要滑動。每次滑動最多移動捲動區域的一半,並輕輕放開,所以內容不會甩過該元素。當元素出現、內容不再移動(到達清單結尾)、滑動 maxScrolls 次後,或經過 timeoutSeconds 後,搜尋就會結束;搜尋失敗時,螢幕可能已經捲動過。一次搜尋最長持續 25 秒:再次呼叫即可繼續。
direction 表示內容所在的方向,而不是手指移動的方向:down(預設值)會顯示下方的內容,所以手指向上移動。當螢幕有多個捲動區域時,請用 withinId 或 withinText 指定要捲動的區域:它必須剛好符合一個可見元素。
| 唯讀 | 破壞性 | 冪等 |
|---|---|---|
| 否 | 否 | 否 |
輸入
| 輸入 | 類型 | 必填 | 預設值 | 作用 |
|---|---|---|---|---|
teamId |
字串(UUID) | 是 | — | 團隊,來自 list_teams |
simulator |
string | 否 | 團隊的預設裝置 | 哪種裝置,使用 list_simulators 中的 id |
text |
string | text、id、nodeId 之一 |
— | 元素的可見文字,與 選擇器 中相同 |
id |
string | text、id、nodeId 之一 |
— | 元素的 accessibilityIdentifier |
nodeId |
string | text、id、nodeId 之一 |
— | 來自 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 中相同 |
scrolls |
滑動了多少次 |
elapsedMs |
耗時,以毫秒計 |
{ "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 ns | 時間用完了 | 再次呼叫以繼續 |
| 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。
範例
{"name": "simulator_scroll_to", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "text": "Settings", "direction": "down"}}