{"record":{"id":"2e0ba625a0d2366f","repo":"grafana/k6","slug":"checking-is-q-in-viewport-w","errorCode":null,"errorMessage":"checking is %q in viewport: %w","messagePattern":"checking is %q in viewport: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/locator.go","lineNumber":270,"sourceCode":"\topts.Strict = true\n\tdisabled, err := l.frame.isDisabled(l.selector, opts)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"checking is %q disabled: %w\", l.selector, err)\n\t}\n\n\treturn disabled, nil\n}\n\n// IsInViewport returns true if the element matches the locator's selector and\n// intersects the viewport by at least the requested ratio. Otherwise, returns\n// false.\nfunc (l *Locator) IsInViewport(opts *FrameIsInViewportOptions) (bool, error) {\n\tl.log.Debugf(\"Locator:IsInViewport\", \"fid:%s furl:%q sel:%q opts:%+v\", l.frame.ID(), l.frame.URL(), l.selector, opts)\n\n\topts.Strict = true\n\tinViewport, err := l.frame.isInViewport(l.selector, opts)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"checking is %q in viewport: %w\", l.selector, err)\n\t}\n\n\treturn inViewport, nil\n}\n\n// IsVisible returns true if the element matches the locator's\n// selector and is visible. Otherwise, returns false.\nfunc (l *Locator) IsVisible() (bool, error) {\n\tl.log.Debugf(\"Locator:IsVisible\", \"fid:%s furl:%q sel:%q\", l.frame.ID(), l.frame.URL(), l.selector)\n\n\tvisible, err := l.frame.isVisible(l.selector, &FrameIsVisibleOptions{Strict: true})\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"checking is %q visible: %w\", l.selector, err)\n\t}\n\n\treturn visible, nil\n}\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/locator.go#L252-L288","documentation":"Wrapped failure from Frame.isInViewport while computing the viewport-intersection ratio of the element matched by the locator's selector (strict mode forced). Fires when the selector matches nothing or multiple elements, the element is detached, or the bounding-box/intersection evaluation via CDP fails.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/locator.go:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a unique selector or narrow with nth()/filter to satisfy strict mode","Ensure the element is attached and laid out before checking viewport intersection","Verify the page finished loading so viewport dimensions are final"],"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"}