grafana/k6 · error
typing in
Error message
typing %q in %q: %w
What it means
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.
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
Example fix
// before
page.type('#email', 'user@example.com');
// after
page.waitForSelector('#email', { state: 'visible', timeout: 10000 });
page.type('#email', 'user@example.com', { timeout: 10000 }); Defensive patterns
Strategy: retry
Validate before calling
page.waitForSelector(sel, { state: 'visible', timeout: 10000 });
const editable = page.$eval(sel, el => !el.disabled && !el.readOnly);
if (!editable) throw new Error('target input is disabled/readonly; cannot type'); Try / catch
const typeWithRetry = (page, sel, text, tries = 3) => {
for (let i = 0; i < tries; i++) {
try { page.type(sel, text, { timeout: 15000 }); return; }
catch (e) {
if (i === tries - 1) throw e;
page.waitForSelector(sel, { state: 'visible', timeout: 5000 });
}
}
}; Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- pressing on
- an error occurred communicating with k6 Cloud
- " " attribute is only supported for roles: "`).join(", ")}
- " " does not support " " matcher
- " " must be one of
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/ee7c47bddd7f4f66.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:1913
js := `() => document.title`
v, err := f.Evaluate(js)
if err != nil {
return "", fmt.Errorf("getting frame title: %w", err)
}
s, ok := v.(string)
if !ok {
return "", fmt.Errorf("getting frame title: expected string, got %T", v)
}
return s, nil
}
// Type text on the first element found matches the selector.
func (f *Frame) Type(selector, text string, popts *FrameTypeOptions) error {
f.log.Debugf("Frame:Type", "fid:%s furl:%q sel:%q text:%q", f.ID(), f.URL(), selector, text)
if err := f.typ(selector, text, popts); err != nil {
return fmt.Errorf("typing %q in %q: %w", text, selector, err)
}
applySlowMo(f.ctx)
return nil
}
func (f *Frame) typ(selector, text string, opts *FrameTypeOptions) error {
typeText := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
return nil, handle.typ(apiCtx, text, opts.ToKeyboardOptions())
}
act := f.newAction(
selector, DOMElementStateAttached, opts.Strict, typeText,
[]string{}, false, withRetry, opts.NoWaitAfter, opts.Timeout,
)
if _, err := call(f.ctx, act, opts.Timeout); err != nil {
return errorFromDOMError(err)
}View on GitHub (pinned to 3fcf5388d7)