Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c098bd3

Browse filesBrowse files
committed
feat: Add playwright_iframe_fill
1 parent dae228f commit c098bd3
Copy full SHA for c098bd3

File tree

Expand file treeCollapse file tree

4 files changed

+52
-1
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+52
-1
lines changed

‎docs/docs/playwright-web/Supported-Tools.mdx

Copy file name to clipboardExpand all lines: docs/docs/playwright-web/Supported-Tools.mdx
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ Click elements in an iframe on the page.
171171

172172
---
173173

174+
### Playwright_iframe_fill
175+
Fill elements in an iframe on the page.
176+
177+
- **`iframeSelector`** *(string)*:
178+
CSS selector for the iframe containing the element to fill.
179+
180+
- **`selector`** *(string)*:
181+
CSS selector for the element to fill.
182+
183+
---
184+
174185
### Playwright_hover
175186
Hover over elements on the page.
176187

‎src/toolHandler.ts

Copy file name to clipboardExpand all lines: src/toolHandler.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {
2525
FillTool,
2626
SelectTool,
2727
HoverTool,
28-
EvaluateTool
28+
EvaluateTool,
29+
IframeFillTool
2930
} from './tools/browser/interaction.js';
3031
import {
3132
VisibleTextTool,
@@ -73,6 +74,7 @@ let closeBrowserTool: CloseBrowserTool;
7374
let consoleLogsTool: ConsoleLogsTool;
7475
let clickTool: ClickTool;
7576
let iframeClickTool: IframeClickTool;
77+
let iframeFillTool: IframeFillTool;
7678
let fillTool: FillTool;
7779
let selectTool: SelectTool;
7880
let hoverTool: HoverTool;
@@ -310,6 +312,7 @@ function initializeTools(server: any) {
310312
if (!consoleLogsTool) consoleLogsTool = new ConsoleLogsTool(server);
311313
if (!clickTool) clickTool = new ClickTool(server);
312314
if (!iframeClickTool) iframeClickTool = new IframeClickTool(server);
315+
if (!iframeFillTool) iframeFillTool = new IframeFillTool(server);
313316
if (!fillTool) fillTool = new FillTool(server);
314317
if (!selectTool) selectTool = new SelectTool(server);
315318
if (!hoverTool) hoverTool = new HoverTool(server);
@@ -474,6 +477,9 @@ export async function handleToolCall(
474477

475478
case "playwright_iframe_click":
476479
return await iframeClickTool.execute(args, context);
480+
481+
case "playwright_iframe_fill":
482+
return await iframeFillTool.execute(args, context);
477483

478484
case "playwright_fill":
479485
return await fillTool.execute(args, context);

‎src/tools.ts

Copy file name to clipboardExpand all lines: src/tools.ts
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ export function createToolDefinitions() {
133133
required: ["iframeSelector", "selector"],
134134
},
135135
},
136+
{
137+
name: "playwright_iframe_fill",
138+
description: "Fill an element in an iframe on the page",
139+
inputSchema: {
140+
type: "object",
141+
properties: {
142+
iframeSelector: { type: "string", description: "CSS selector for the iframe containing the element to fill" },
143+
selector: { type: "string", description: "CSS selector for the element to fill" },
144+
value: { type: "string", description: "Value to fill" },
145+
},
146+
required: ["iframeSelector", "selector", "value"],
147+
},
148+
},
136149
{
137150
name: "playwright_fill",
138151
description: "fill out an input field",
@@ -418,6 +431,7 @@ export const BROWSER_TOOLS = [
418431
"playwright_screenshot",
419432
"playwright_click",
420433
"playwright_iframe_click",
434+
"playwright_iframe_fill",
421435
"playwright_fill",
422436
"playwright_select",
423437
"playwright_hover",

‎src/tools/browser/interaction.ts

Copy file name to clipboardExpand all lines: src/tools/browser/interaction.ts
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ export class IframeClickTool extends BrowserToolBase {
6565
}
6666
}
6767

68+
/**
69+
* Tool for filling elements inside iframes
70+
*/
71+
export class IframeFillTool extends BrowserToolBase {
72+
/**
73+
* Execute the iframe fill tool
74+
*/
75+
async execute(args: any, context: ToolContext): Promise<ToolResponse> {
76+
return this.safeExecute(context, async (page) => {
77+
const frame = page.frameLocator(args.iframeSelector);
78+
if (!frame) {
79+
return createErrorResponse(`Iframe not found: ${args.iframeSelector}`);
80+
}
81+
82+
await frame.locator(args.selector).fill(args.value);
83+
return createSuccessResponse(`Filled element ${args.selector} inside iframe ${args.iframeSelector} with: ${args.value}`);
84+
});
85+
}
86+
}
87+
6888
/**
6989
* Tool for filling form fields
7090
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.