grafana/k6 · error

checking element

Error message

checking element: %w

What it means

Returned by ElementHandle.SetChecked when the internal setChecked pointer action (scroll into view, actionability checks, click to toggle) fails. The wrapped error holds the actual cause: element not visible/enabled/editable, hit-target interception, timeout, or detachment. It is a wrap-only site; the retry logic lives in newPointerAction.

Solutions

  1. Wait for the element to be actionable (visible, enabled, editable) before setting checked
  2. Increase the timeout option
  3. Use force:true to skip actionability checks when appropriate
  4. Verify the element is an input that supports checking
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/element_handle.go:1335 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/4ee7f50e6ce4da39. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/element_handle.go:1335

		return cmp.Compare(a.index, b.index)
	})

	els := make([]*ElementHandle, 0, len(indexedElems))
	for _, ie := range indexedElems {
		els = append(els, ie.elem)
	}

	return els, nil
}

// SetChecked checks or unchecks an element.
func (h *ElementHandle) SetChecked(checked bool, opts *ElementHandleSetCheckedOptions) error {
	setChecked := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {
		return nil, handle.setChecked(apiCtx, checked, p)
	}
	setCheckedAction := h.newPointerAction(setChecked, &opts.ElementHandleBasePointerOptions)
	if _, err := call(h.ctx, setCheckedAction, opts.Timeout); err != nil {
		return fmt.Errorf("checking element: %w", err)
	}

	applySlowMo(h.ctx)

	return nil
}

// Uncheck scrolls element into view, and if it's an input element of type
// checkbox that is already checked, clicks on it to mark it as unchecked.
func (h *ElementHandle) Uncheck(opts *ElementHandleSetCheckedOptions) error {
	return h.SetChecked(false, opts)
}

// Check scrolls element into view, and if it's an input element of type
// checkbox that is unchecked, clicks on it to mark it as checked.
func (h *ElementHandle) Check(opts *ElementHandleSetCheckedOptions) error {
	return h.SetChecked(true, opts)
}

View on GitHub (pinned to 3fcf5388d7)