{"record":{"id":"1890df444785c064","repo":"grafana/k6","slug":"expected-node-but-got-s","errorCode":null,"errorMessage":"expected node but got %s","messagePattern":"expected node but got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1884,"sourceCode":"\t\tserr = e\n\tcase error:\n\t\tif e == nil {\n\t\t\treturn errors.New(\"DOM error is nil\")\n\t\t}\n\t\terr, serr = e, e.Error()\n\tdefault:\n\t\treturn fmt.Errorf(\"unexpected DOM error type %T\", v)\n\t}\n\tif _, ok := errors.AsType[*k6ext.UserFriendlyError](err); ok {\n\t\treturn err\n\t}\n\tif strings.Contains(serr, \"timed out\") {\n\t\treturn &k6ext.UserFriendlyError{\n\t\t\tErr: ErrTimedOut,\n\t\t}\n\t}\n\tif s := \"error:expectednode:\"; strings.HasPrefix(serr, s) {\n\t\treturn fmt.Errorf(\"expected node but got %s\", strings.TrimPrefix(serr, s))\n\t}\n\n\tif serr == \"error:notconnected\" {\n\t\treturn ErrElementNotAttachedToDOM\n\t}\n\n\tif errors.Is(err, ErrElementNotVisible) {\n\t\treturn ErrElementNotVisible\n\t}\n\n\tif errors.Is(err, ErrElementNotAttachedToDOM) {\n\t\treturn ErrElementNotAttachedToDOM\n\t}\n\n\terrs := map[string]string{\n\t\t\"error:notelement\":             \"node is not an element\",\n\t\t\"error:nothtmlelement\":         \"not an HTMLElement\",\n\t\t\"error:notfillableelement\":     \"element is not an <input>, <textarea> or [contenteditable] element\",","sourceCodeStart":1866,"sourceCodeEnd":1902,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1866-L1902","documentation":"Returned by errorFromDOMError when the injected script's error string starts with the 'error:expectednode:' prefix: an API expected a DOM node but received something else (e.g. operating on a handle whose underlying remote object is not a node, or the node was replaced). The suffix names what was actually received.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle.go:1881 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the handle used is an element handle obtained from a selector, not a generic JS value","Re-resolve the element handle after DOM changes","Avoid calling node-requiring APIs on document or text-only handles"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}