grafana/k6 · error
waiting for
Error message
waiting for %q: %w
What it means
Wrapped failure from Frame.waitFor (bounded to 20 internal attempts) while waiting for the element matching the locator's selector (strict mode forced). Fires when the element does not reach the required state within the timeout, or when the wait loop exhausts retries or the CDP query fails.
Solutions
- Increase the timeout in FrameWaitForSelectorOptions for slow pages
- Ensure the selector is correct and matches a single element
- Wait for preceding navigation/rendering steps before waiting on the element
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/locator.go:653 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/cd6b72841bb07558.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/locator.go:653
opts.Strict = true
if err := l.frame.dispatchEvent(l.selector, typ, eventInit, opts); err != nil {
return fmt.Errorf("dispatching locator event %q to %q: %w", typ, l.selector, err)
}
applySlowMo(l.ctx)
return nil
}
// WaitFor waits for the element matching the locator's selector with strict mode on.
func (l *Locator) WaitFor(opts *FrameWaitForSelectorOptions) error {
l.log.Debugf("Locator:WaitFor", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)
opts.Strict = true
_, err := l.frame.waitFor(l.selector, opts, 20)
if err != nil {
return fmt.Errorf("waiting for %q: %w", l.selector, err)
}
return nil
}
// DefaultTimeout returns the default timeout for the locator.
// This is an internal API and should not be used by users.
func (l *Locator) DefaultTimeout() time.Duration {
return l.frame.defaultTimeout()
}
// FrameLocator represent a way to find element(s) in an iframe.
type FrameLocator struct {
selector string
frame *Frame
ctx context.ContextView on GitHub (pinned to 01ffac6f24)