grafana/k6 · error

missing required argument 'title'

Error message

missing required argument 'title'

What it means

FrameLocator.getByTitle(title, opts) requires a non-nullish first argument (internal/js/modules/k6/browser/browser/frame_locator_mapping.go:71). The title matches elements' title attribute inside the iframe and may be a string or RegExp. k6common.IsNullish rejects only undefined and null, so the error means the argument was omitted or explicitly nullish.

Solutions

  1. Pass the title (string or RegExp): `frameLocator('iframe#chart').getByTitle('Quarterly revenue')`
  2. Default dynamic values: `getByTitle(t ?? 'Info')`
  3. Pre-validate constants/data modules for required title strings

Example fix

// before
const tip = frameLocator('iframe#chart').getByTitle();

// after
const tip = frameLocator('iframe#chart').getByTitle('Revenue chart');
Defensive patterns

Strategy: validation

Validate before calling

const title = tips[tipKey];
if (title == null) throw new Error(`getByTitle: title is required, got ${title}`);
const el = frameLocator('iframe#chart').getByTitle(title);

Type guard

const isTextOrRegex = (v) => v != null && (typeof v === 'string' || v instanceof RegExp);

Prevention

When it happens

Trigger: `frameLocator('iframe#chart').getByTitle()` with no argument, passing `null`, or a title variable that resolved to undefined — for instance an object property that was renamed, or an unset __ENV variable. Not triggered by empty string.

Common situations: Tooltip / SVG title locators parameterized from shared constants files where a key is missing; refactor renames leaving stale references; data-driven rows without the title field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/261a8eb571bfdb2b. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/frame_locator_mapping.go:71

				return nil, errors.New("missing required argument 'testId'")
			}
			ptestID := parseStringOrRegex(testID, false)

			ml := mapLocator(vu, fl.GetByTestID(ptestID))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByText": func(text sobek.Value, opts sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(text) {
				return nil, errors.New("missing required argument 'text'")
			}
			ptext, popts := parseGetByBaseOptions(vu.Context(), text, true, opts)

			ml := mapLocator(vu, fl.GetByText(ptext, popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByTitle": func(title sobek.Value, opts sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(title) {
				return nil, errors.New("missing required argument 'title'")
			}
			ptitle, popts := parseGetByBaseOptions(vu.Context(), title, false, opts)

			ml := mapLocator(vu, fl.GetByTitle(ptitle, popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"locator": func(selector string, opts sobek.Value) mapping {
			return mapLocator(vu, fl.Locator(selector, parseLocatorOptions(rt, opts)))
		},
		"frameLocator": func(selector string) *sobek.Object {
			mfl := mapFrameLocator(vu, fl.FrameLocator(selector))
			return rt.ToValue(mfl).ToObject(rt)
		},
	}
}

View on GitHub (pinned to 01ffac6f24)