Files
OrcaSlicer/tools/mcp/tests/webview_modal.json
T
SoftFever 457ed1aacb Let MCP agents read and drive web dialogs and plugin pages
Agents can also answer a native message box that is already open (Windows and Linux), and URLs in
replies hide credential values.
2026-10-31 17:56:38 +08:00

34 lines
2.3 KiB
JSON

// Scripts in the web views of modal dialogs, which webview_eval runs in whenever the dialog is the
// topmost: by default and by locator, and the bundle dialog closed from its page's own button, which
// replies closed. Run it on a fresh datadir set up with the default printer:
// tools/mcp/orca_mcp.py run-script tools/mcp/tests/webview_modal.json --out /tmp/webview_modal
// The refusals (a web view behind a modal, a dialog under the topmost) are in
// tools/mcp/test_webview_modal.py; the same dialogs driven through the GUI tools are in web_dialogs.json.
{
"orca_script": 1,
"name": "web views in modal dialogs",
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "set_view", "args": {"window_size": [1920, 1200]}},
// ---- The preset bundle dialog ----
{"tool": "run_action", "args": {"id": "orca_command:preset_bundle:orca"}, "await": false, "save_as": "bundle"},
{"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}},
{"tool": "webview_eval", "args": {"script": "document.title"},
"expect": {"/result": {"eq": "Preset Bundle"}, "/url": {"contains": "PresetBundleDialog"}}},
{"tool": "webview_eval", "args": {"script": "!!document.getElementById('close_btn')", "target": {"class": "webview", "within": "Preset Bundle"}},
"expect": {"/result": {"eq": true}}},
{"tool": "webview_eval", "args": {"script": "document.getElementById('close_btn').click()"}, "expect": {"/closed": {"eq": true}}},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.bundle}"}},
{"tool": "get_state", "expect": {"/dialogs": {"empty": true}}},
// ---- The setup wizard: its page is read, and the dialog only closed ----
{"tool": "run_action", "args": {"id": "orca_command:help_setup_wizard:orca"}, "await": false, "save_as": "wizard"},
{"tool": "wait", "args": {"for": "dialog", "timeout_s": 30}, "expect": {"/satisfied": {"eq": true}}},
{"tool": "webview_eval", "args": {"script": "typeof document.title"}, "expect": {"/result": {"eq": "string"}, "/url": {"contains": "/guide/"}}},
{"tool": "dialog_respond", "args": {"dialog": {"title": "Setup Wizard"}, "button": "close"}},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.wizard}"}},
{"tool": "get_state", "expect": {"/dialogs": {"empty": true}}}
]
}