{"record":{"id":"c7d822755cdac996","repo":"grafana/k6","slug":"getting-document-w","errorCode":null,"errorMessage":"getting document: %w","messagePattern":"getting document: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":644,"sourceCode":"\tclick := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.click(p, opts.ToMouseClickOptions())\n\t}\n\tact := f.newPointerAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, click, &opts.ElementHandleBasePointerOptions,\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\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","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L626-L662","documentation":"Returned by Frame.count when Frame.document fails to provide the document element handle needed to run the count evaluation in the frame's main world. The wrap marks the dependency; the real cause (no execution context, navigation race, CDP error) is in the wrapped error.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:636 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the frame to load before counting","Retry after navigation settles","Verify the frame is attached"],"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"}