{"record":{"id":"b608003d1cc050a9","repo":"grafana/k6","slug":"setting-emulated-vision-deficiency-q-w","errorCode":null,"errorMessage":"setting emulated vision deficiency %q: %w","messagePattern":"setting emulated vision deficiency %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":1110,"sourceCode":"func (p *Page) EmulateVisionDeficiency(typ string) error {\n\tp.logger.Debugf(\"Page:EmulateVisionDeficiency\", \"sid:%v typ:%s\", p.sessionID(), typ)\n\n\tvalidTypes := map[string]emulation.SetEmulatedVisionDeficiencyType{\n\t\t\"achromatopsia\": emulation.SetEmulatedVisionDeficiencyTypeAchromatopsia,\n\t\t\"blurredVision\": emulation.SetEmulatedVisionDeficiencyTypeBlurredVision,\n\t\t\"deuteranopia\":  emulation.SetEmulatedVisionDeficiencyTypeDeuteranopia,\n\t\t\"none\":          emulation.SetEmulatedVisionDeficiencyTypeNone,\n\t\t\"protanopia\":    emulation.SetEmulatedVisionDeficiencyTypeProtanopia,\n\t\t\"tritanopia\":    emulation.SetEmulatedVisionDeficiencyTypeTritanopia,\n\t}\n\tt, ok := validTypes[typ]\n\tif !ok {\n\t\treturn fmt.Errorf(\"unsupported vision deficiency: %s\", typ)\n\t}\n\n\taction := emulation.SetEmulatedVisionDeficiency(t)\n\tif err := action.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {\n\t\treturn fmt.Errorf(\"setting emulated vision deficiency %q: %w\", typ, err)\n\t}\n\n\tapplySlowMo(p.ctx)\n\n\treturn nil\n}\n\n// Evaluate runs JS code within the execution context of the main frame of the page.\nfunc (p *Page) Evaluate(pageFunc string, args ...any) (any, error) {\n\tp.logger.Debugf(\"Page:Evaluate\", \"sid:%v\", p.sessionID())\n\n\treturn p.MainFrame().Evaluate(pageFunc, args...)\n}\n\n// EvaluateHandle runs JS code within the execution context of the main frame of the page.\nfunc (p *Page) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error) {\n\tp.logger.Debugf(\"Page:EvaluateHandle\", \"sid:%v\", p.sessionID())\n","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L1092-L1128","documentation":"Failure of the CDP emulation.setEmulatedVisionDeficiency command after the type was validated against the supported set. Indicates the browser rejected the command at the protocol level — closed session/target or canceled context — not an invalid input string.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:1105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the page session is alive when emulating a vision deficiency","Apply emulation before closing or navigating the page","Retry the call if it raced with browser startup/teardown"],"exampleFix":null,"handlingStrategy":"try-catch","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"}