grafana/k6 · error

waiting for URL

Error message

waiting for URL %q: %w

What it means

Returned by Frame.WaitForURL when waiting for navigation to a URL matching the pattern fails or times out (it delegates to WaitForNavigation with the URL set). The wrap names the pattern; the underlying timeout/error explains why the frame never reached a matching URL.

Solutions

  1. Verify the URL pattern matches the destination (glob/regex semantics)
  2. Increase the timeout
  3. Ensure the navigation actually happens (click/link triggered)
  4. For SPA hash changes, confirm a real navigation occurs
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2224 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/78d4a4b394c919af. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/frame.go:2232

	f.log.Debugf("Frame:WaitForTimeout", "fid:%s furl:%q timeout:%s", f.ID(), f.URL(), to)
	defer f.log.Debugf("Frame:WaitForTimeout:return", "fid:%s furl:%q timeout:%s", f.ID(), f.URL(), to)

	select {
	case <-f.ctx.Done():
	case <-time.After(to):
	}
}

// WaitForURL waits for the frame to navigate to a URL matching the given pattern.
// RegExMatcher should be non-nil to be able to test against a URL pattern.
func (f *Frame) WaitForURL(urlPattern string, opts *FrameWaitForURLOptions, rm RegExMatcher) error {
	f.log.Debugf("Frame:WaitForURL", "fid:%s furl:%q pattern:%s", f.ID(), f.URL(), urlPattern)
	defer f.log.Debugf("Frame:WaitForURL:return", "fid:%s furl:%q pattern:%s", f.ID(), f.URL(), urlPattern)

	matched, err := rm.Match(urlPattern, f.URL())
	if err != nil {
		return fmt.Errorf("waiting for URL %q: %w", urlPattern, err)
	}
	if matched {
		// Already at target URL, just wait for load state
		return f.WaitForLoadState(opts.WaitUntil.String(), &FrameWaitForLoadStateOptions{
			Timeout: opts.Timeout,
		})
	}

	// Wait for navigation to matching URL
	navOpts := &FrameWaitForNavigationOptions{
		URL:       urlPattern,
		Timeout:   opts.Timeout,
		WaitUntil: opts.WaitUntil,
	}
	_, err = f.WaitForNavigation(navOpts, rm)

	return err
}

View on GitHub (pinned to 3fcf5388d7)