{"record":{"id":"07e50a4f986cf6d9","repo":"grafana/k6","slug":"node-is-not-queryable","errorCode":null,"errorMessage":"node is not queryable","messagePattern":"node is not queryable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1915,"sourceCode":"\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\",\n\t\t\"error:notfillableinputtype\":   \"input of this type cannot be filled\",\n\t\t\"error:notfillablenumberinput\": \"cannot type text into input[type=number]\",\n\t\t\"error:notvaliddate\":           \"malformed value\",\n\t\t\"error:notinput\":               \"node is not an HTMLInputElement\",\n\t\t\"error:notfile\":                \"node is not an input[type=file] element\",\n\t\t\"error:hasnovalue\":             \"node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement\",\n\t\t\"error:notselect\":              \"element is not a <select> element\",\n\t\t\"error:notcheckbox\":            \"not a checkbox or radio button\",\n\t\t\"error:notmultiplefileinput\":   \"non-multiple file input can only accept single file\",\n\t\t\"error:strictmodeviolation\":    \"strict mode violation, multiple elements returned for selector query\",\n\t\t\"error:notqueryablenode\":       \"node is not queryable\",\n\t\t\"error:nthnocapture\":           \"can't query n-th element in a chained selector with capture\",\n\t\t\"error:intercept\":              \"another element is intercepting with pointer action\",\n\t}\n\tif err, ok := errs[serr]; ok {\n\t\treturn errors.New(err)\n\t}\n\n\treturn errors.New(serr)\n}\n","sourceCodeStart":1897,"sourceCodeEnd":1920,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/element_handle.go#L1897-L1920","documentation":"Mapped from 'error:notqueryablenode' by errorFromDOMError (element_handle.go:1896-1916). The injected DOM engine can only run element queries on nodes that are queryable; calling $/$$ (querySelector) on a handle whose underlying remote object is not such a node (a text node, a plain JS value, or a node in a detached context) yields this error.","triggerScenarios":"Getting a handle to a non-element node and querying it: const h = await page.evaluateHandle(() => document.body.firstChild); await h.$('div'); calling elementHandle.$ on a JSHandle obtained from evaluateHandle that wraps null, a primitive, or a text node; querying a handle whose frame was detached by navigation.","commonSituations":"Using evaluateHandle for flexibility and then treating the result as an element; holding handles across page.goto where the old context is destroyed; grabbing childNodes instead of children.","solutions":["Convert/validate the handle first: use handle.asElement() (returns null for non-elements) before querying","Re-query from the frame or page after navigation instead of reusing pre-navigation handles","For non-element nodes, use page.evaluate with a native querySelector inside the page function","Dispose stale handles and acquire fresh ones on the current frame"],"exampleFix":"// before\nconst h = await page.evaluateHandle(() => document.body.firstChild);\nawait h.$('div'); // text node: not queryable\n\n// after\nconst h = await page.evaluateHandle(() => document.body);\nawait h.$('div');","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// asElement() returns null for non-element handles\nconst raw = await page.evaluateHandle(() => document.body.firstChild);\nconst el = raw.asElement(); // null unless it is an element\nif (el) {\n  const child = await el.$('div');\n}","tryCatchPattern":"try {\n  await handle.$('div');\n} catch (e) {\n  if (/not queryable/.test(e.message)) {\n    const el = handle.asElement();\n    if (!el) throw new Error('handle is not an element; re-query with page.$');\n  } else throw e;\n}","preventionTips":["Always run asElement() after evaluateHandle before querying","Use page.$/frame.$ for element lookups, evaluateHandle only for real JS values","Discard handles captured before page.goto and re-query afterwards"],"tags":["browser","selector","dom","jshandle"],"backgroundTag":"invalid-element-state","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}