grafana/k6 · error
typing %q in %q: %w
Error message
typing %q in %q: %w
What it means
Frame.Type() wraps the internal type-text action as 'typing "<text>" in "<selector>": <cause>'. The cause is the real error: element wait timeout, actionability failure (hidden/disabled), mid-typing detach, or keyboard event dispatch failing because the frame died.
Source
Thrown at internal/js/modules/k6/browser/common/frame.go:1905
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 93accf6570)
Solutions
- Wait first: await frame.waitForSelector(sel, { state: 'visible' }) then type().
- For controlled inputs that re-render, prefer fill() (single set) or type with small delay and verify the final value.
- Use { timeout: 60_000 } on slow environments and a selector that matches exactly one element.
- Use { force: true } only if the invisibility is a styling artifact you control.
Example fix
// before
await frame.type('#email', 'a@b.c'); // input hidden by wizard step
// after
await frame.waitForSelector('#email', { state: 'visible' });
await frame.type('#email', 'a@b.c', { timeout: 60_000 }); Defensive patterns
Strategy: validation
Validate before calling
await frame.waitForSelector(sel, { state: 'visible', timeout: 60_000 }); Try / catch
try { await frame.type(sel, text, { timeout: 60_000 }); }
catch (e) { if (/typing .* in/.test(e.message)) { /* inspect cause: timeout vs re-render vs strict */ } throw e; } Prevention
- Wait for visible inputs before typing
- Prefer fill() for controlled inputs that re-render
- Verify the final input value after typing into framework inputs
When it happens
Trigger: frame.type(sel, text) where the element never appears within timeout; element not visible/enabled with force=false; element re-rendered mid-typing (React controlled input); strict-mode multi-match; page navigated while typing.
Common situations: Typing into inputs behind overlays; typing into inputs whose value is wiped by framework re-render; wrong selector; slow CI exceeding the default 30s timeout.
Related errors
- pressing %q on %q: %w
- pressing %q on element: %w
- clicking on %q: %w
- checking %q: %w
- double clicking on %q: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/ee7c47bddd7f4f66.
Report an issue: GitHub.