Skip to content

Commit 4a64e44

Browse files
author
GitLab CI
committed
fix: add go_online tool, fix screenshot_element selector param
- go_online: restore network after go_offline (prevents timeout cascade) - screenshot_element: add 'selector' to tool definition (handler already supported it) - Tool count: 176 → 177
1 parent 77c9bf4 commit 4a64e44

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

lib/src/bridge/cdp_browser_methods.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,17 @@ extension CdpBrowserMethods on CdpDriver {
401401
return {"success": true, "offline": true};
402402
}
403403

404+
/// Go back online — restore normal network conditions.
405+
Future<Map<String, dynamic>> goOnline() async {
406+
await _call('Network.emulateNetworkConditions', {
407+
'offline': false,
408+
'latency': 0,
409+
'downloadThroughput': -1,
410+
'uploadThroughput': -1,
411+
});
412+
return {"success": true, "offline": false};
413+
}
414+
404415
/// Clear browser data.
405416
Future<Map<String, dynamic>> clearBrowserData() async {
406417
await _call('Network.clearBrowserCookies');

lib/src/cli/tool_handlers/cdp_tool_handlers.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ extension _CdpToolHandlers on FlutterMcpServer {
514514
case 'go_offline':
515515
return await cdp.goOffline();
516516

517+
case 'go_online':
518+
return await cdp.goOnline();
519+
517520
case 'clear_browser_data':
518521
return await cdp.clearBrowserData();
519522

lib/src/cli/tool_handlers/tool_definitions.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extension _ToolDefinitions on FlutterMcpServer {
5252
'block_urls',
5353
'throttle_network',
5454
'go_offline',
55+
'go_online',
5556
'clear_browser_data',
5657
'accessibility_audit',
5758
'a11y_full_audit',
@@ -940,7 +941,12 @@ After starting, point the web SDK at ws://127.0.0.1:<port>.""",
940941
},
941942
{
942943
"name": "go_offline",
943-
"description": "Simulate offline mode (no network)",
944+
"description": "Simulate offline mode (no network). Use go_online to restore.",
945+
"inputSchema": {"type": "object", "properties": {}}
946+
},
947+
{
948+
"name": "go_online",
949+
"description": "Restore normal network conditions after go_offline.",
944950
"inputSchema": {"type": "object", "properties": {}}
945951
},
946952
{
@@ -1765,10 +1771,11 @@ By default, saves screenshot to a temporary file and returns file path. Optional
17651771
},
17661772
{
17671773
"name": "screenshot_element",
1768-
"description": "Take a screenshot of a specific element",
1774+
"description": "Take a screenshot of a specific element by CSS selector, key, or text content",
17691775
"inputSchema": {
17701776
"type": "object",
17711777
"properties": {
1778+
"selector": {"type": "string", "description": "CSS selector (e.g. 'h1', '.my-class', '#my-id')"},
17721779
"key": {"type": "string", "description": "Element key"},
17731780
"text": {"type": "string", "description": "Text to find"},
17741781
},

lib/src/engine/tool_registry.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class ToolRegistry {
6363
'block_urls',
6464
'throttle_network',
6565
'go_offline',
66+
'go_online',
6667
'clear_browser_data',
6768
'accessibility_audit',
6869
'set_geolocation',
@@ -940,7 +941,12 @@ After starting, point the web SDK at ws://127.0.0.1:<port>.""",
940941
},
941942
{
942943
"name": "go_offline",
943-
"description": "Simulate offline mode (no network)",
944+
"description": "Simulate offline mode (no network). Use go_online to restore.",
945+
"inputSchema": {"type": "object", "properties": {}}
946+
},
947+
{
948+
"name": "go_online",
949+
"description": "Restore normal network conditions after go_offline.",
944950
"inputSchema": {"type": "object", "properties": {}}
945951
},
946952
{
@@ -1773,12 +1779,13 @@ By default, saves screenshot to a temporary file and returns file path. Optional
17731779
},
17741780
{
17751781
"name": "screenshot_element",
1776-
"description": "Take a screenshot of a specific element",
1782+
"description": "Take a screenshot of a specific element by CSS selector, key, or text content",
17771783
"inputSchema": {
17781784
"type": "object",
17791785
"properties": {
1786+
"selector": {"type": "string", "description": "CSS selector (e.g. 'h1', '.my-class', '#my-id')"},
17801787
"key": {"type": "string", "description": "Element key"},
1781-
"text": {"type": "string", "description": "Text to find"}
1788+
"text": {"type": "string", "description": "Text content to find"}
17821789
}
17831790
}
17841791
},

0 commit comments

Comments
 (0)