grafana/k6 · error
inserting text
Error message
inserting text: %w
What it means
Wrap of Keyboard.insertText in the public Keyboard.InsertText: text insertion uses the CDP Input.insertText command (ime-like input without key events), and this wrap reports the command failed — the session was closed or canceled mid-test, or the browser rejected the insertion call. Unlike typing, insertText does not validate characters against a layout.
Solutions
- Ensure the element to receive text is focused before calling insertText
- Keep the browser session alive during the call
- Use type() instead when per-key events and delays are required
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/keyboard.go:83 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/ed7f2eed07b67e59.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/keyboard.go:83
}
return nil
}
// Press sends a key press message to a session target.
// It delays the action if `Delay` option is specified.
// A press message consists of successive key down and up messages.
func (k *Keyboard) Press(key string, kbdOpts KeyboardOptions) error {
if err := k.comboPress(key, kbdOpts); err != nil {
return fmt.Errorf("pressing key: %w", err)
}
return nil
}
// InsertText inserts a text without dispatching key events.
func (k *Keyboard) InsertText(text string) error {
if err := k.insertText(text); err != nil {
return fmt.Errorf("inserting text: %w", err)
}
return nil
}
// Type sends a press message to a session target for each character in text.
// It delays the action if `Delay` option is specified.
//
// It sends an insertText message if a character is not among
// valid characters in the keyboard's layout.
func (k *Keyboard) Type(text string, kbdOpts KeyboardOptions) error {
if err := k.typ(text, kbdOpts); err != nil {
return fmt.Errorf("typing text: %w", err)
}
return nil
}
func (k *Keyboard) down(key string) error {
key = k.platformSpecificResolution(key)View on GitHub (pinned to 01ffac6f24)