{"record":{"id":"ed7f2eed07b67e59","repo":"grafana/k6","slug":"inserting-text-w","errorCode":null,"errorMessage":"inserting text: %w","messagePattern":"inserting text: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":83,"sourceCode":"\t}\n\treturn nil\n}\n\n// Press sends a key press message to a session target.\n// It delays the action if `Delay` option is specified.\n// A press message consists of successive key down and up messages.\nfunc (k *Keyboard) Press(key string, kbdOpts KeyboardOptions) error {\n\tif err := k.comboPress(key, kbdOpts); err != nil {\n\t\treturn fmt.Errorf(\"pressing key: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// InsertText inserts a text without dispatching key events.\nfunc (k *Keyboard) InsertText(text string) error {\n\tif err := k.insertText(text); err != nil {\n\t\treturn fmt.Errorf(\"inserting text: %w\", err)\n\t}\n\treturn nil\n}\n\n// Type sends a press message to a session target for each character in text.\n// It delays the action if `Delay` option is specified.\n//\n// It sends an insertText message if a character is not among\n// valid characters in the keyboard's layout.\nfunc (k *Keyboard) Type(text string, kbdOpts KeyboardOptions) error {\n\tif err := k.typ(text, kbdOpts); err != nil {\n\t\treturn fmt.Errorf(\"typing text: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (k *Keyboard) down(key string) error {\n\tkey = k.platformSpecificResolution(key)","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L65-L101","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}