{"record":{"id":"dd02a4faa8205f09","repo":"grafana/k6","slug":"unexpected-select-element-type-t","errorCode":null,"errorMessage":"unexpected select element type %T","messagePattern":"unexpected select element type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":1736,"sourceCode":"\n\treturn v, nil\n}\n\nfunc (f *Frame) selectOption(selector string, values []any, opts *FrameSelectOptionOptions) ([]string, error) {\n\tselectOption := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\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}","sourceCodeStart":1718,"sourceCodeEnd":1754,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L1718-L1754","documentation":"Internal invariant in frame.selectOption: the value returned by the select action must be a jsHandle (a JSHandle for the <select> element); the Go type assertion failed. This is not caused by user input but by an unexpected CDP evaluation result.","triggerScenarios":"The internal evaluate that performs the selection returned a non-handle value (e.g. a primitive or null) — possible with Chromium/k6 version drift or an internal bug; the selection evaluation itself also returned something abnormal.","commonSituations":"Essentially never in healthy environments; appears when the browser binary and k6 module disagree on the evaluation protocol, or after a partially failed navigation leaves the action in a weird state.","solutions":["Retry the selectOption call once — a transient context race can produce it","Verify k6 and its bundled Chromium are a matched, current release","Reproduce with a minimal script and report to grafana/k6 issues if persistent","Work around via page.evaluate: el.value = 'x'; el.dispatchEvent(new Event('change'))"],"exampleFix":"// workaround\npage.evaluate(\"() => { const s = document.querySelector('#country'); s.value = 'DE'; s.dispatchEvent(new Event('change', { bubbles: true })); }\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  page.selectOption(sel, 'DE');\n} catch (e) {\n  if (String(e).includes('unexpected select element type')) {\n    page.evaluate(`() => { const s = document.querySelector('${sel}'); s.value = 'DE'; s.dispatchEvent(new Event('change', { bubbles: true })); }`);\n  } else { throw e; }\n}","preventionTips":["Keep k6/Chromium versions aligned","Report reproducible internal-invariant errors upstream with a minimal script"],"tags":["k6","browser","internal","type-assertion","select"],"backgroundTag":"type-assertion-failed","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"}