{"record":{"id":"ee7c47bddd7f4f66","repo":"grafana/k6","slug":"typing-q-in-q-w","errorCode":null,"errorMessage":"typing %q in %q: %w","messagePattern":"typing %q in %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":1913,"sourceCode":"\tjs := `() => document.title`\n\tv, err := f.Evaluate(js)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting frame title: %w\", err)\n\t}\n\ts, ok := v.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"getting frame title: expected string, got %T\", v)\n\t}\n\n\treturn s, nil\n}\n\n// Type text on the first element found matches the selector.\nfunc (f *Frame) Type(selector, text string, popts *FrameTypeOptions) error {\n\tf.log.Debugf(\"Frame:Type\", \"fid:%s furl:%q sel:%q text:%q\", f.ID(), f.URL(), selector, text)\n\n\tif err := f.typ(selector, text, popts); err != nil {\n\t\treturn fmt.Errorf(\"typing %q in %q: %w\", text, selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) typ(selector, text string, opts *FrameTypeOptions) error {\n\ttypeText := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn nil, handle.typ(apiCtx, text, opts.ToKeyboardOptions())\n\t}\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, typeText,\n\t\t[]string{}, false, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}","sourceCodeStart":1895,"sourceCodeEnd":1931,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L1895-L1931","documentation":"Wrapper error from k6 browser's frame.Type(selector, text): the wait-for-element plus type-into-element action failed. The wrapped cause is typically a selector timeout, the element not being focusable/editable, or strict-mode ambiguity.","triggerScenarios":"page.type(sel, text)/frame.type() where the selector never matches within the timeout, matches multiple elements with strict:true, the element is disabled/readonly or cannot receive focus, or it detaches mid-typing.","commonSituations":"Typing into inputs that appear after async rendering (login forms, search boxes); disabled submit-state inputs; elements inside iframes requiring the inner frame; slow pages under load exceeding the default 30s timeout.","solutions":["Wait for an editable element: page.waitForSelector(sel, { state: 'visible' }) and confirm it is enabled","Fix selector uniqueness for strict mode","Increase the timeout: page.type(sel, text, { timeout: 60000 })","For iframes, get the containing frame and call type on it"],"exampleFix":"// before\npage.type('#email', 'user@example.com');\n\n// after\npage.waitForSelector('#email', { state: 'visible', timeout: 10000 });\npage.type('#email', 'user@example.com', { timeout: 10000 });","handlingStrategy":"retry","validationCode":"page.waitForSelector(sel, { state: 'visible', timeout: 10000 });\nconst editable = page.$eval(sel, el => !el.disabled && !el.readOnly);\nif (!editable) throw new Error('target input is disabled/readonly; cannot type');","typeGuard":null,"tryCatchPattern":"const typeWithRetry = (page, sel, text, tries = 3) => {\n  for (let i = 0; i < tries; i++) {\n    try { page.type(sel, text, { timeout: 15000 }); return; }\n    catch (e) {\n      if (i === tries - 1) throw e;\n      page.waitForSelector(sel, { state: 'visible', timeout: 5000 });\n    }\n  }\n};","preventionTips":["Wait for the input to be visible and enabled before typing","Use unique selectors for strict mode","For iframe inputs, resolve the inner frame and type through it"],"tags":["k6","browser","keyboard","typing","timeout"],"backgroundTag":"actionability-timeout","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}