{"record":{"id":"7e50708eb043b107","repo":"grafana/k6","slug":"getting-element-s-input-value-w","errorCode":null,"errorMessage":"getting element's input value: %w","messagePattern":"getting element's input value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1042,"sourceCode":"\tapplySlowMo(h.ctx)\n\n\ts, ok := v.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type %T (expecting string)\", v)\n\t}\n\n\treturn s, nil\n}\n\n// InputValue returns the value of the input element.\nfunc (h *ElementHandle) InputValue(opts *ElementHandleBaseOptions) (string, error) {\n\tinputValue := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.inputValue(apiCtx)\n\t}\n\tinputValueAction := h.newAction([]string{}, inputValue, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout)\n\tv, err := call(h.ctx, inputValueAction, opts.Timeout)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting element's input value: %w\", err)\n\t}\n\n\ts, ok := v.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type %T (expecting string)\", v)\n\t}\n\n\treturn s, nil\n}\n\n// IsChecked checks if a checkbox or radio is checked.\nfunc (h *ElementHandle) IsChecked() (bool, error) {\n\tok, err := h.isChecked(h.ctx, 0)\n\t// We don't care about timeout errors here!\n\tif err != nil && !errors.Is(err, ErrTimedOut) {\n\t\treturn false, fmt.Errorf(\"checking element is checked: %w\", err)\n\t}\n","sourceCodeStart":1024,"sourceCodeEnd":1060,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1024-L1060","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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()"],"exampleFix":"// before\nconst el = await page.$('#output'); // actually a div\nconst v = await el.inputValue();\n// after\nconst el = await page.$('#output');\nconst tag = (await el.evaluate((e) => e.tagName)).toLowerCase();\nif (tag === 'input' || tag === 'textarea' || tag === 'select') {\n  const v = await el.inputValue();\n}","handlingStrategy":"validation","validationCode":"const tag = (await handle.evaluate((e) => e.tagName)).toLowerCase();\nif (tag === 'input' || tag === 'textarea' || tag === 'select') {\n  const v = await handle.inputValue();\n}","typeGuard":"async function isValueHolder(handle) {\n  const tag = (await handle.evaluate((e) => e.tagName)).toLowerCase();\n  return tag === 'input' || tag === 'textarea' || tag === 'select';\n}","tryCatchPattern":"try {\n  return await handle.inputValue();\n} catch (e) {\n  if (String(e).includes(\"getting element's input value\")) {\n    return handle.evaluate((e) => e.value);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["browser","element-handle","input-value","wrong-element","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}