{"record":{"id":"ac246389415e1c55","repo":"grafana/k6","slug":"evaluating-handle-for-element-w","errorCode":null,"errorMessage":"evaluating handle for element: %w","messagePattern":"evaluating handle for element: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/js_handle.go","lineNumber":151,"sourceCode":"}\n\n// Evaluate will evaluate provided page function within an execution context.\nfunc (h *BaseJSHandle) Evaluate(pageFunc string, args ...any) (any, error) {\n\targs = append([]any{h}, args...)\n\tres, err := h.execCtx.Eval(h.ctx, pageFunc, args...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluating element: %w\", err)\n\t}\n\n\treturn res, nil\n}\n\n// EvaluateHandle will evaluate provided page function within an execution context.\nfunc (h *BaseJSHandle) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error) {\n\targs = append([]any{h}, args...)\n\teh, err := h.execCtx.EvalHandle(h.ctx, pageFunc, args...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluating handle for element: %w\", err)\n\t}\n\n\treturn eh, nil\n}\n\n// GetProperties retreives the JS handle's properties.\nfunc (h *BaseJSHandle) GetProperties() (map[string]JSHandleAPI, error) {\n\thandles, err := h.getProperties()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tjsHandles := make(map[string]JSHandleAPI, len(handles))\n\tfor k, v := range handles {\n\t\tjsHandles[k] = v\n\t}\n\n\treturn jsHandles, nil","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/js_handle.go#L133-L169","documentation":"Wrap of an ExecutionContext.EvalHandle failure in BaseJSHandle.EvaluateHandle: like Evaluate, the page function runs in the browser with the handle as first argument, but the result is expected to be a new remote object wrapped as a JSHandle. The wrapped error indicates the evaluation threw in the page (exception or syntax error), or the result could not be materialized as a handle (e.g., the function returned a primitive that cannot be referenced as a remote object).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/js_handle.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the page function returns an object or DOM node rather than a primitive","Check the function for runtime exceptions by testing it in devtools","Re-acquire the source handle if navigation may have invalidated its execution context"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}