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,