{"record":{"id":"1296a238ba53b2f1","repo":"grafana/k6","slug":"waiting-for-selector-q-did-not-result-in-any-node","errorCode":null,"errorMessage":"waiting for selector %q did not result in any nodes","messagePattern":"waiting for selector %q did not result in any nodes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":507,"sourceCode":"\n// waitForSelector will wait for the given selector to reach a defined state in\n// opts.\n//\n// It will auto retry on certain errors until the retryCount is below 0. The\n// retry workaround is needed since the underlying DOM can change when the\n// wait action is performed during a navigation.\nfunc (f *Frame) waitForSelector(selector string, opts *FrameWaitForSelectorOptions) (*ElementHandle, error) {\n\tf.log.Debugf(\"Frame:waitForSelector\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\thandle, err := f.waitFor(selector, opts, 20)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif handle == nil {\n\t\tif opts.State == DOMElementStateHidden || opts.State == DOMElementStateDetached {\n\t\t\treturn nil, nil //nolint:nilnil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"waiting for selector %q did not result in any nodes\", selector)\n\t}\n\n\t// We always return ElementHandles in the main execution context (aka \"DOM world\")\n\tf.executionContextMu.RLock()\n\tdefer f.executionContextMu.RUnlock()\n\n\tuec := f.executionContexts[utilityWorld]\n\n\t// An element should belong to the current main world execution context, and\n\t// not to the utility world context, otherwise, we should adopt it to the\n\t// current world's execution context. This is only valid when the handle\n\t// is from the current frame and not part of a nested frame.\n\tadopted := handle\n\tif uec != nil && uec == handle.execCtx {\n\t\twec := f.executionContexts[mainWorld]\n\t\tif wec == nil {\n\t\t\treturn nil, fmt.Errorf(\"waiting for selector %q: execution context %q not found\", selector, mainWorld)\n\t\t}","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L489-L525","documentation":"Returned by Frame.waitForSelector when the internal waitFor call succeeded but produced a nil handle: the wait condition ended (typically timeout with state 'attached' semantics or state 'detached' transitions) without matching any node. Contrary to the message wording, it usually means the selector never matched within the wait's parameters rather than an internal failure.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:499 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the selector actually matches elements in the frame","Increase the wait timeout","Check the state option: waiting for 'detached' or wrong state can yield no handle","Ensure you are waiting on the correct frame (iframe vs main)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-09-20T22:01:45.163Z","contentChangedAt":"2026-09-20T22:01:45.163Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}