grafana/k6 · error

selecting option on

Error message

selecting option on %q: %w

What it means

Wrapped failure from Frame.selectOption while selecting options on the element matched by the locator's selector (strict mode forced). Fires when the selector matches zero/multiple elements, the target is not a select element, none of the requested options exist, or the CDP selection call fails.

Solutions

  1. Ensure the target is a <select> element matched by a unique selector
  2. Verify the option values/labels passed actually exist in the select
  3. Wait for the options to be populated (e.g. after async load) before selecting
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/locator.go:530 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/e6c459ecb5351312. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/locator.go:530

	opts.Strict = true
	v, err := l.frame.inputValue(l.selector, opts)
	if err != nil {
		return "", fmt.Errorf("getting input value of %q: %w", l.selector, err)
	}

	return v, nil
}

// SelectOption filters option values of the first element that matches
// the locator's selector (with strict mode on), selects the options,
// and returns the filtered options.
func (l *Locator) SelectOption(values []any, opts *FrameSelectOptionOptions) ([]string, error) {
	l.log.Debugf("Locator:SelectOption", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)

	opts.Strict = true
	v, err := l.frame.selectOption(l.selector, values, opts)
	if err != nil {
		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)

View on GitHub (pinned to 01ffac6f24)