grafana/k6 · error
pressing on
Error message
pressing %q on %q: %w
What it means
Wrapped failure from Frame.press while dispatching the given key to the element matched by the locator's selector (strict mode forced). Fires on zero/multiple matches, when the element cannot receive focus, when the key name is not a recognized key, or when the CDP key events fail.
Solutions
- Use a valid key name (e.g. 'Enter', 'ArrowDown', 'a') as accepted by CDP
- Ensure the target element is visible and focusable with a unique selector
- Use Type for literal text instead of Press for single characters if key naming is the issue
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/locator.go:548 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/8f7ce5fc6e52e43e.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/locator.go:548
return nil, fmt.Errorf("selecting option on %q: %w", l.selector, err)
}
applySlowMo(l.ctx)
return v, nil
}
// Press the given key on the element found that matches the locator's
// selector with strict mode on.
func (l *Locator) Press(key string, opts *FramePressOptions) error {
l.log.Debugf(
"Locator:Press", "fid:%s furl:%q sel:%q key:%q opts:%+v",
l.frame.ID(), l.frame.URL(), l.selector, key, opts,
)
opts.Strict = true
if err := l.frame.press(l.selector, key, opts); err != nil {
return fmt.Errorf("pressing %q on %q: %w", key, l.selector, err)
}
applySlowMo(l.ctx)
return nil
}
// PressSequentially focuses on the element and sequentially sends a keydown,
// keypress, and keyup events for each character in the provided string.
// For handling special keys, use the [Locator.Press] method.
func (l *Locator) PressSequentially(text string, opts *FrameTypeOptions) error {
l.log.Debugf(
"Locator:PressSequentially", "fid:%s furl:%q sel:%q text:%q opts:%+v",
l.frame.ID(), l.frame.URL(), l.selector, text, opts,
)
_, span := TraceAPICall(l.ctx, l.frame.page.targetID.String(), "locator.pressSequentially")
defer span.End()
View on GitHub (pinned to 01ffac6f24)