grafana/k6 · error
getting element's input value: %w
Error message
getting element's input value: %w
What it means
Returned by ElementHandle.inputValue() when the underlying evaluation fails. The injected script explicitly throws 'Node is not an <input>, <textarea> or <select> element' when the handle points at any other node type, and that error surfaces wrapped here. Other wrapped causes are stale handles, destroyed contexts, and timeouts.
Source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:1042
applySlowMo(h.ctx)
s, ok := v.(string)
if !ok {
return "", fmt.Errorf("unexpected type %T (expecting string)", v)
}
return s, nil
}
// InputValue returns the value of the input element.
func (h *ElementHandle) InputValue(opts *ElementHandleBaseOptions) (string, error) {
inputValue := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
return handle.inputValue(apiCtx)
}
inputValueAction := h.newAction([]string{}, inputValue, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout)
v, err := call(h.ctx, inputValueAction, opts.Timeout)
if err != nil {
return "", fmt.Errorf("getting element's input value: %w", err)
}
s, ok := v.(string)
if !ok {
return "", fmt.Errorf("unexpected type %T (expecting string)", v)
}
return s, nil
}
// IsChecked checks if a checkbox or radio is checked.
func (h *ElementHandle) IsChecked() (bool, error) {
ok, err := h.isChecked(h.ctx, 0)
// We don't care about timeout errors here!
if err != nil && !errors.Is(err, ErrTimedOut) {
return false, fmt.Errorf("checking element is checked: %w", err)
}
View on GitHub (pinned to 93accf6570)
Solutions
- Verify the element is an input/textarea/select before calling: check tagName via evaluate
- Tighten the selector so it resolves to the actual field element (inspect in devtools)
- For shadow-DOM/web components, pierce with a selector that reaches the inner input
- Re-query the handle immediately before inputValue()
Example fix
// before
const el = await page.$('#output'); // actually a div
const v = await el.inputValue();
// after
const el = await page.$('#output');
const tag = (await el.evaluate((e) => e.tagName)).toLowerCase();
if (tag === 'input' || tag === 'textarea' || tag === 'select') {
const v = await el.inputValue();
} Defensive patterns
Strategy: validation
Validate before calling
const tag = (await handle.evaluate((e) => e.tagName)).toLowerCase();
if (tag === 'input' || tag === 'textarea' || tag === 'select') {
const v = await handle.inputValue();
} Type guard
async function isValueHolder(handle) {
const tag = (await handle.evaluate((e) => e.tagName)).toLowerCase();
return tag === 'input' || tag === 'textarea' || tag === 'select';
} Try / catch
try {
return await handle.inputValue();
} catch (e) {
if (String(e).includes("getting element's input value")) {
return handle.evaluate((e) => e.value);
}
throw e;
} Prevention
- Verify tagName before inputValue() - only input/textarea/select are supported
- Ensure selectors target the field itself, not a wrapper
- Pierce shadow DOM to reach the actual input in web components
When it happens
Trigger: Calling inputValue() on a div/span/anchor instead of an input, textarea, or select; a stale handle after re-render/navigation; the evaluation timing out; page/browser closed mid-call.
Common situations: Selectors accidentally matching a wrapper element around the real field; custom web components that render a shadow-DOM input under a non-input host; reading values after dynamic list re-renders.
Related errors
- parsing element input value options: %w
- predicate function is not callable
- element is not attached to the DOM
- getting document element: nil document
- clicking the checkbox did not change its state
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/7e50708eb043b107.
Report an issue: GitHub.