From e807dbb2ff914f4f5f5221729430f2678c3d335c Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 9 Feb 2026 15:16:15 +0000 Subject: [PATCH] feat: add KeyboardInsertText to InteractiveBrowser Exposes Playwright's Keyboard.InsertText() which dispatches only an input event (no keydown/keyup). This is essential for pasting text into password fields and custom input components that don't handle rapid-fire synthetic key events from Type(). Co-Authored-By: Claude Opus 4.6 --- interactive.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interactive.go b/interactive.go index ca1d371..8a0b60d 100644 --- a/interactive.go +++ b/interactive.go @@ -32,6 +32,10 @@ type InteractiveBrowser interface { KeyboardType(text string) error // KeyboardPress presses a special key (e.g. "Enter", "Tab", "Backspace"). KeyboardPress(key string) error + // KeyboardInsertText inserts text directly into the focused element by dispatching + // only an input event (no keydown, keypress, or keyup). This is more reliable than + // KeyboardType for pasting into password fields and custom input components. + KeyboardInsertText(text string) error // Screenshot takes a full-page screenshot as JPEG with the given quality (0-100). Screenshot(quality int) ([]byte, error) @@ -282,6 +286,10 @@ func (ib *interactiveBrowser) KeyboardPress(key string) error { return ib.page.Keyboard().Press(key) } +func (ib *interactiveBrowser) KeyboardInsertText(text string) error { + return ib.page.Keyboard().InsertText(text) +} + func (ib *interactiveBrowser) Screenshot(quality int) ([]byte, error) { return ib.page.Screenshot(playwright.PageScreenshotOptions{ Type: playwright.ScreenshotTypeJpeg,