grafana/k6 · error
missing required argument 'url'
Error message
missing required argument 'url'
What it means
Both page.waitForURL and frame.waitForURL route through mapWaitForURL, which requires a URL pattern as the first argument. It is validated with k6common.IsNullish before options are parsed and before parseStringOrRegex converts it to a glob-string or RegExp matcher. Calling waitForURL with no pattern fails fast with this error.
Source
Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:969
if err != nil {
return fmt.Errorf("page.route('%s'): %w", path, err)
}
return nil
}
return promise(vu, func() (any, error) {
return nil, p.Route(ppath, route, newRegExMatcher(ctx, vu, tq))
}), nil
}
}
func mapWaitForURL(vu moduleVU, target interface {
Timeout() time.Duration
WaitForURL(urlPattern string, opts *common.FrameWaitForURLOptions, rm common.RegExMatcher) error
}, url sobek.Value, opts sobek.Value,
) (*sobek.Promise, error) {
if k6common.IsNullish(url) {
return nil, errors.New("missing required argument 'url'")
}
popts := common.NewFrameWaitForURLOptions(target.Timeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing waitForURL options: %w", err)
}
purl := parseStringOrRegex(url, false)
tq, ctx, stop := newTaskQueue(vu)
return promise(vu, func() (result any, reason error) {
defer stop()
return nil, target.WaitForURL(purl, popts, newRegExMatcher(ctx, vu, tq))
}), nil
}
func mapWaitForNavigation(vu moduleVU, target interface {
Timeout() time.Duration
WaitForNavigation(*common.FrameWaitForNavigationOptions, common.RegExMatcher) (*common.Response, error)View on GitHub (pinned to 93accf6570)
Solutions
- Pass a glob string or RegExp: await page.waitForURL('**/dashboard') or await page.waitForURL(/.*dashboard$/)
- Pass options as the second argument only: await page.waitForURL('**/dashboard', { waitUntil: 'load', timeout: 5000 })
- Guard dynamic patterns: if (!pattern) throw new Error('waitForURL requires a pattern')
Example fix
// before
await page.waitForURL({ waitUntil: 'load' });
// after
await page.waitForURL('**/dashboard', { waitUntil: 'load' }); Defensive patterns
Strategy: validation
Validate before calling
if (url === undefined || url === null) {
throw new Error('waitForURL: a glob string or RegExp pattern is required');
}
await page.waitForURL(url, opts); Type guard
function isURLPattern(v) {
return typeof v === 'string' || v instanceof RegExp;
} Try / catch
try {
await page.waitForURL(pattern);
} catch (e) {
if (e.message.includes("missing required argument 'url'")) {
throw new Error('waitForURL called without a URL pattern');
}
throw e; // timeout or navigation errors bubble up
} Prevention
- Pass the pattern first and options second; the signature is waitForURL(pattern, opts)
- Empty string is a valid (nullish-free) pattern — pass an explicit RegExp or glob instead of '' when you mean 'any URL'
When it happens
Trigger: await page.waitForURL() with no arguments; await frame.waitForURL(null); passing only options: await page.waitForURL({ waitUntil: 'load' }); an empty string is NOT nullish and instead matches per glob semantics (tests use it explicitly).
Common situations: Porting Playwright's waitForURL and forgetting the URL; building the pattern from a variable that is undefined; assuming options can carry the URL.
Related errors
- missing required argument 'altText'
- missing required argument 'label'
- missing required argument 'placeholder'
- missing required argument 'role'
- missing required argument 'testId'
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/3a902cd02c139ddd.
Report an issue: GitHub.