{"record":{"id":"06831ab24d721f44","repo":"grafana/k6","slug":"getting-element-handle-for-selector-q-w","errorCode":null,"errorMessage":"getting element handle for selector %q: %w","messagePattern":"getting element handle for selector %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1281,"sourceCode":"\t\treturn nil, fmt.Errorf(\"parsing selector %q: %w\", selector, err)\n\t}\n\tresult, err := eval(\n\t\th.ctx,\n\t\tevalOptions{forceCallable: true, returnByValue: false},\n\t\tjs.QueryAll,\n\t\tparsedSelector,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying all selectors %q: %w\", selector, err)\n\t}\n\tif result == nil {\n\t\t// it is ok to return a nil slice because it means we didn't find any elements.\n\t\treturn nil, nil\n\t}\n\n\thandles, ok := result.(JSHandleAPI)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"getting element handle for selector %q: %w\", selector, ErrJSHandleInvalid)\n\t}\n\tdefer func() {\n\t\tif err := handles.Dispose(); err != nil {\n\t\t\terr = fmt.Errorf(\"disposing element handles: %w\", err)\n\t\t\trerr = errors.Join(err, rerr)\n\t\t}\n\t}()\n\n\tprops, err := handles.GetProperties()\n\tif err != nil {\n\t\t// GetProperties has a rich error already, so we don't need to wrap it.\n\t\treturn nil, err //nolint:wrapcheck\n\t}\n\n\ttype indexedElem struct {\n\t\tindex int\n\t\telem  *ElementHandle\n\t}","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1263-L1299","documentation":"Returned by ElementHandle.queryAll as a type guard: the QueryAll evaluation returned a non-nil result that does not implement JSHandleAPI, so it cannot be destructured into element handles. It wraps the sentinel ErrJSHandleInvalid. Indicates an unexpected result type from the page evaluation, not a user-actionable DOM condition.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle.go:1281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a potential k6 browser module bug with a reproducing script","Ensure k6 browser module build is consistent (no partial upgrades)","Retry in case of a transient evaluation anomaly"],"exampleFix":null,"handlingStrategy":"type-guard","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"}