{"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":1734,"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":1716,"sourceCodeEnd":1752,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame.go#L1716-L1752","documentation":"Once selectOption succeeds, k6 calls Runtime.getProperties on the returned array handle to enumerate the chosen <option> elements. If that CDP call fails (session closed, context destroyed, protocol error), you get 'getProperties: <cause>'. The selection itself worked; only reading back the result failed.","triggerScenarios":"Navigation or frame detach between the selectOption click completing and the getProperties readback; CDP session dropped (browser crash, page closed by the site); debugger attached interfering with the protocol.","commonSituations":"onchange handlers that submit the form / reload the page immediately after selection — the readback races the navigation; tests that close the page in a helper right after selecting.","solutions":["Prevent the submit/reload during selection (e.g. event.preventDefault in an addInitScript, or select a value that does not trigger navigation) if you only need the return value.","Delay page.close() until after selectOption returns.","If you do not need the selected values, ignore the error path by wrapping the call and treating this specific failure as success-after-verify (re-read values with evaluate later)."],"exampleFix":"// before\nawait page.selectOption('#country', 'JP'); // onchange submits form -> readback races\n\n// after\nawait page.evaluate(() => {\n  document.querySelector('#country').addEventListener('change', e => e.preventDefault());\n});\nawait page.selectOption('#country', 'JP');","handlingStrategy":"try-catch","validationCode":"await frame.evaluate(() => {\n  document.querySelector('#sel')?.addEventListener('change', e => e.preventDefault());\n});","typeGuard":null,"tryCatchPattern":"try { return await page.selectOption(sel, v); }\ncatch (e) {\n  if (/getProperties/.test(e.message)) {\n    return page.evaluate(() => [...document.querySelector(sel).selectedOptions].map(o => o.value));\n  }\n  throw e;\n}","preventionTips":["Prevent form submit/reload on change when you only need the return value","Do not close the page immediately after selecting","Read selected values via evaluate when the page navigates on change"],"tags":["browser","select","cdp","race-condition","navigation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}