grafana/k6 · error
getting element's input value
Error message
getting element's input value: %w
What it means
ElementHandle.inputValue() wraps the failure of a CDP evaluation whose injected JavaScript explicitly throws 'Node is not an <input>, <textarea> or <select> element' for wrong node types, plus the usual evaluation failures (stale handle, destroyed context, timeout).
Solutions
- Select the actual input/textarea/select element (poke into shadow DOM or use a more specific selector)
- Verify the node first: await el.evaluate(e => /^(INPUT|TEXTAREA|SELECT)$/.test(e.nodeName))
- If you just need the value, fall back to await el.evaluate(e => e.value)
- Re-acquire the handle if a re-render may have detached it
Example fix
// before
const el = await page.$('.x-field');
const v = await el.inputValue(); // wrapper div is not an input
// after
const el = await page.$('.x-field input, .x-field textarea, .x-field select');
const v = await el.inputValue(); Defensive patterns
Strategy: validation
Validate before calling
// Confirm the node is a value-bearing control before inputValue()
const isField = await el.evaluate(
(e) => /^(INPUT|TEXTAREA|SELECT)$/.test(e.nodeName)
);
if (!isField) {
throw new Error('not an input/textarea/select; target the real field');
}
const v = await el.inputValue(); Try / catch
try {
const v = await el.inputValue();
} catch (e) {
if (/not an <input>/i.test(String(e.message))) {
const v = await el.evaluate((e2) => String(e2.value ?? '')); // raw value read
} else throw e;
} Prevention
- Select the inner native control of custom components, not the wrapper
- Check nodeName when components conditionally render different field types
When it happens
Trigger: Calling inputValue() on a button, div, span, or any element that is not input/textarea/select; the handle resolves to a component wrapper (shadow-DOM host, kendo/material wrapper) instead of the inner field; the element detached before the evaluation ran.
Common situations: Custom UI components where the real input lives in shadow DOM or deeper in the tree; form libraries that render custom widgets; mistaking a label or container for the input.
Related errors
- converting result ( of type %t) to size
- filling element
- focusing on element
- getting attribute of element: unexpected type %T (expecting…
- getting attribute of element
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/7e50708eb043b107.
Report an issue: GitHub.
Appendix: 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 3fcf5388d7)