{"record":{"id":"f2d31cc6b5002c5f","repo":"microsoft/playwright","slug":"locators-must-belong-to-the-same-frame","errorCode":null,"errorMessage":"Locators must belong to the same frame.","messagePattern":"Locators must belong to the same frame\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/locator.ts","lineNumber":180,"sourceCode":"    // VS Code extension uses this one, keep it for now.\n    return await this._frame._highlight(this._selector);\n  }\n\n  async highlight(options: { style?: string | Record<string, string | number> } = {}) {\n    const style = typeof options.style === 'object' ? cssObjectToString(options.style) : options.style;\n    await this._frame._highlight(this._selector, style);\n    return new DisposableStub(() => this.hideHighlight());\n  }\n\n  async hideHighlight() {\n    await this._frame._hideHighlight(this._selector);\n  }\n\n  locator(selectorOrLocator: string | Locator, options?: Omit<LocatorOptions, 'visible'>): Locator {\n    if (isString(selectorOrLocator))\n      return new Locator(this._frame, this._selector + ' >> ' + selectorOrLocator, options);\n    if (selectorOrLocator._frame !== this._frame)\n      throw new Error(`Locators must belong to the same frame.`);\n    return new Locator(this._frame, this._selector + ' >> internal:chain=' + JSON.stringify(selectorOrLocator._selector), options);\n  }\n\n  get(by: By): Locator {\n    return this.locator(resolveBy(by, testIdAttributeName()));\n  }\n\n  getByTestId(testId: string | RegExp): Locator {\n    return this.locator(getByTestIdSelector(testIdAttributeName(), testId));\n  }\n\n  getByAltText(text: string | RegExp, options?: { exact?: boolean }): Locator {\n    return this.locator(getByAltTextSelector(text, options));\n  }\n\n  getByLabel(text: string | RegExp, options?: { exact?: boolean }): Locator {\n    return this.locator(getByLabelSelector(text, options));\n  }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/locator.ts#L162-L198","documentation":"Error \"Locators must belong to the same frame.\" thrown in microsoft/playwright.","triggerScenarios":"Thrown at packages/playwright-core/src/client/locator.ts:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}