microsoft/playwright · error · Error
Inner "has" locator must belong to the same frame.
Error message
Inner "has" locator must belong to the same frame.
What it means
Error "Inner "has" locator must belong to the same frame." thrown in microsoft/playwright.
Source
Thrown at packages/playwright-core/src/client/locator.ts:67
export class Locator implements api.Locator {
_frame: Frame;
_selector: string;
_apiName = 'Locator';
constructor(frame: Frame, selector: string, options?: LocatorOptions) {
this._frame = frame;
this._selector = selector;
if (options?.hasText)
this._selector += ` >> internal:has-text=${escapeForTextSelector(options.hasText, false)}`;
if (options?.hasNotText)
this._selector += ` >> internal:has-not-text=${escapeForTextSelector(options.hasNotText, false)}`;
if (options?.has) {
const locator = options.has;
if (locator._frame !== frame)
throw new Error(`Inner "has" locator must belong to the same frame.`);
this._selector += ` >> internal:has=` + JSON.stringify(locator._selector);
}
if (options?.hasNot) {
const locator = options.hasNot;
if (locator._frame !== frame)
throw new Error(`Inner "hasNot" locator must belong to the same frame.`);
this._selector += ` >> internal:has-not=` + JSON.stringify(locator._selector);
}
if (options?.visible !== undefined)
this._selector += ` >> visible=${options.visible ? 'true' : 'false'}`;
if (inspect.custom)
(this as any)[inspect.custom] = () => this._inspect();
}
private async _withElement<R>(task: (handle: ElementHandle<SVGElement | HTMLElement>, timeout?: number) => Promise<R>, options: { title: string, internal?: boolean, timeout?: number, signal?: AbortSignal }): Promise<R> {View on GitHub (pinned to c8fc3bf8d3)
When it happens
Trigger: Thrown at packages/playwright-core/src/client/locator.ts:67 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/650747d3ba535c5e.
Report an issue: GitHub.