{"record":{"id":"1e44d0a059147547","repo":"grafana/k6","slug":"counting-elements-w","errorCode":null,"errorMessage":"counting elements: %w","messagePattern":"counting elements: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":649,"sourceCode":"\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\nfunc (f *Frame) count(selector string) (int, error) {\n\tf.log.Debugf(\"Frame:count\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tdocument, err := f.document()\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"getting document: %w\", err)\n\t}\n\n\tc, err := document.count(f.ctx, selector)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"counting elements: %w\", err)\n\t}\n\n\treturn c, nil\n}\n\n// Check clicks the first element found that matches selector.\nfunc (f *Frame) Check(selector string, popts *FrameCheckOptions) error {\n\tf.log.Debugf(\"Frame:Check\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.check(selector, popts); err != nil {\n\t\treturn fmt.Errorf(\"checking %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L631-L667","documentation":"Returned by Frame.count when evaluating the injected count script on the document handle fails. The wrap adds operation context; the wrapped error is the evaluation failure (context destroyed, CDP error). The count itself cannot fail for 'no matches' — that returns 0.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:641 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after the page/frame stabilizes","Inspect the wrapped evaluation error","Ensure the frame is not navigating while counting"],"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"}