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 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,10 @@ type InteractiveBrowser interface {
|
|||||||
KeyboardType(text string) error
|
KeyboardType(text string) error
|
||||||
// KeyboardPress presses a special key (e.g. "Enter", "Tab", "Backspace").
|
// KeyboardPress presses a special key (e.g. "Enter", "Tab", "Backspace").
|
||||||
KeyboardPress(key string) error
|
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 takes a full-page screenshot as JPEG with the given quality (0-100).
|
||||||
Screenshot(quality int) ([]byte, error)
|
Screenshot(quality int) ([]byte, error)
|
||||||
@@ -282,6 +286,10 @@ func (ib *interactiveBrowser) KeyboardPress(key string) error {
|
|||||||
return ib.page.Keyboard().Press(key)
|
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) {
|
func (ib *interactiveBrowser) Screenshot(quality int) ([]byte, error) {
|
||||||
return ib.page.Screenshot(playwright.PageScreenshotOptions{
|
return ib.page.Screenshot(playwright.PageScreenshotOptions{
|
||||||
Type: playwright.ScreenshotTypeJpeg,
|
Type: playwright.ScreenshotTypeJpeg,
|
||||||
|
|||||||
Reference in New Issue
Block a user