{"record":{"id":"71ffad568d0f1663","repo":"grafana/k6","slug":"typing-text-w","errorCode":null,"errorMessage":"typing text: %w","messagePattern":"typing text: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/keyboard.go","lineNumber":95,"sourceCode":"\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)\n\n\tkeyInput := keyboardlayout.KeyInput(key)\n\tif _, ok := k.layout.ValidKeys[keyInput]; !ok {\n\t\treturn fmt.Errorf(\"%q is not a valid key for layout %q\", key, k.layoutName)\n\t}\n\n\tkeyDef := k.keyDefinitionFromKey(keyInput)\n\tk.modifiers |= k.modifierBitFromKeyName(keyDef.Key)\n\ttext := keyDef.Text\n\n\tk.pressedKeysMu.Lock()\n\t_, autoRepeat := k.pressedKeys[keyDef.KeyCode]","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/keyboard.go#L77-L113","documentation":"Wrap of Keyboard.typ in the public Keyboard.Type: typing iterates each character, dispatching press events for layout-valid keys and falling back to insertText for characters outside the layout. This wrap means the loop failed partway — an invalid key path, an interrupted delay wait, or a CDP dispatch failure on a closed session. The inner error identifies which character and stage failed.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/keyboard.go:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Prefer page.fill() or locator.fill() for plain text entry — faster and more robust","Avoid typing while the page is navigating or closing","Break very long strings into smaller type() calls to reduce exposure to mid-sequence failures"],"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"}