{"record":{"id":"7a261c247cf3fb1b","repo":"grafana/k6","slug":"focusing-q-w","errorCode":null,"errorMessage":"focusing %q: %w","messagePattern":"focusing %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":969,"sourceCode":"\t}\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, opts.Strict,\n\t\tfill, []string{\"visible\", \"enabled\", \"editable\"},\n\t\topts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}\n\n\treturn nil\n}\n\n// Focus focuses on the first element that matches the selector.\nfunc (f *Frame) Focus(selector string, popts *FrameBaseOptions) error {\n\tf.log.Debugf(\"Frame:Focus\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.focus(selector, popts); err != nil {\n\t\treturn fmt.Errorf(\"focusing %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) focus(selector string, opts *FrameBaseOptions) error {\n\tfocus := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn nil, handle.focus(apiCtx, true)\n\t}\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, focus,\n\t\t[]string{}, false, withRetry, true, opts.Timeout,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L951-L987","documentation":"Returned by Frame.Focus when focusing the first matching element fails. Wrap-only: the underlying action error (element not attached within timeout, evaluation failure, CDP error) carries the real cause for the selector.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:961 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the selector matches an attached element","Increase the timeout","Retry after DOM changes; verify the element is focusable"],"exampleFix":null,"handlingStrategy":"retry","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"}