{"record":{"id":"142fb9bc956d3030","repo":"grafana/k6","slug":"getproperties-w","errorCode":null,"errorMessage":"getProperties: %w","messagePattern":"getProperties: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":1742,"sourceCode":"\t\treturn handle.selectOption(apiCtx, values)\n\t}\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, selectOption,\n\t\t[]string{}, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tv, err := call(f.ctx, act, opts.Timeout)\n\tif err != nil {\n\t\treturn nil, errorFromDOMError(err)\n\t}\n\tselectHandle, ok := v.(jsHandle)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected select element type %T\", v)\n\t}\n\n\t// pack the selected <option> values inside <select> into a slice\n\toptHandles, err := selectHandle.getProperties()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getProperties: %w\", err)\n\t}\n\tvals := make([]string, 0, len(optHandles))\n\tfor _, oh := range optHandles {\n\t\tval, err := oh.JSONValue()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"reading value: %w\", err)\n\t\t}\n\t\tvals = append(vals, val)\n\t\tif err := oh.dispose(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"optionHandle.dispose: %w\", err)\n\t\t}\n\t}\n\tif err := selectHandle.dispose(); err != nil {\n\t\treturn nil, fmt.Errorf(\"selectHandle.dispose: %w\", err)\n\t}\n\n\treturn vals, nil\n}","sourceCodeStart":1724,"sourceCodeEnd":1760,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L1724-L1760","documentation":"In k6 browser's frame.selectOption, after selecting, the code calls getProperties() on the <select> element's JSHandle via CDP Runtime.getProperties to enumerate the chosen <option> values. This error means that CDP call failed, typically because the execution context or session died between selection and property read.","triggerScenarios":"The page navigates or the frame's execution context is destroyed in the window between the select action and the getProperties round-trip; or the CDP session/target is closed mid-call.","commonSituations":"An onchange handler on the <select> triggers navigation or a full page reload (e.g. a locale/currency picker); a form auto-submits on change; test teardown races the call.","solutions":["If the select navigates on change, expect it: wait for the navigation, then verify state instead of relying on the return value","Retry selectOption once after the new document loads","Prevent auto-submit in the test environment so the context survives the property read","Read the selected value separately after settling: page.$eval(sel, el => el.value)"],"exampleFix":"// before\nconst vals = page.selectOption('#currency', 'EUR');\n\n// after\ntry {\n  page.selectOption('#currency', 'EUR');\n} catch (e) {\n  page.waitForLoadState('load'); // select triggered navigation\n}\nconst val = page.$eval('#currency', el => el.value);","handlingStrategy":"try-catch","validationCode":"const navigatesOnChange = page.$eval(sel, el => el.hasAttribute('onchange') || el.form?.hasAttribute('onchange'));\n// if true, expect a navigation and verify state afterwards instead of trusting the return value","typeGuard":null,"tryCatchPattern":"try {\n  page.selectOption(sel, val);\n} catch (e) {\n  console.log(`selectOption read raced navigation: ${e}`);\n  page.waitForLoadState('load');\n  if (page.$eval(sel, el => el.value) !== val) throw new Error('selection not applied');\n}","preventionTips":["Know which selects navigate on change and design assertions around the post-navigation state","Avoid page.close() while frame actions are in flight"],"tags":["k6","browser","cdp","select","execution-context"],"backgroundTag":"execution-context-destroyed","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"}