{"record":{"id":"811c5a9b6acde7f0","repo":"grafana/k6","slug":"focusing-on-q-w","errorCode":null,"errorMessage":"focusing on %q: %w","messagePattern":"focusing on %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/locator.go","lineNumber":342,"sourceCode":"\n// Filter returns a new [Locator] after applying the options to the current one.\nfunc (l *Locator) Filter(opts *LocatorFilterOptions) *Locator {\n\treturn NewLocator(l.ctx, opts.LocatorOptions, l.selector, l.frame, l.log)\n}\n\n// First will return the first child of the element matching the locator's\n// selector.\nfunc (l *Locator) First() *Locator {\n\treturn NewLocator(l.ctx, nil, l.selector+\" >> nth=0\", l.frame, l.log)\n}\n\n// Focus on the element using locator's selector with strict mode on.\nfunc (l *Locator) Focus(opts *FrameBaseOptions) error {\n\tl.log.Debugf(\"Locator:Focus\", \"fid:%s furl:%q sel:%q opts:%+v\", l.frame.ID(), l.frame.URL(), l.selector, opts)\n\n\topts.Strict = true\n\tif err := l.frame.focus(l.selector, opts); err != nil {\n\t\treturn fmt.Errorf(\"focusing on %q: %w\", l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// GetAttribute of the element using locator's selector with strict mode on.\n// The second return value is true if the attribute exists, and false otherwise.\nfunc (l *Locator) GetAttribute(name string, opts *FrameBaseOptions) (string, bool, error) {\n\tl.log.Debugf(\n\t\t\"Locator:GetAttribute\", \"fid:%s furl:%q sel:%q name:%q opts:%+v\",\n\t\tl.frame.ID(), l.frame.URL(), l.selector, name, opts,\n\t)\n\n\topts.Strict = true\n\ts, ok, err := l.frame.getAttribute(l.selector, name, opts)\n\tif err != nil {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/locator.go#L324-L360","documentation":"Wrapped failure from Frame.focus while focusing the element matched by the locator's selector (strict mode forced). Fires when the selector matches nothing or multiple elements, the element is not focusable or is hidden, or the CDP focus call fails.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/locator.go:342 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a selector that uniquely matches a focusable element","Ensure the element is visible and not disabled before focusing","Retry after a short wait if the page is still rendering"],"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"}