{"record":{"id":"e4bd1446e0c62274","repo":"microsoft/playwright","slug":"selecting-the-nth-frame-is-not-allowed-on-the-root","errorCode":null,"errorMessage":"Selecting the nth frame is not allowed on the root frame locator.","messagePattern":"Selecting the nth frame is not allowed on the root frame locator\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/locator.ts","lineNumber":511,"sourceCode":"  }\n\n  getByRole(role: string, options: ByRoleOptions = {}): Locator {\n    return this.locator(getByRoleSelector(role, options));\n  }\n\n  owner() {\n    return new Locator(this._frame, this._frameSelector);\n  }\n\n  frameLocator(selector: string): FrameLocator {\n    return new FrameLocator(this._frame, this._childSelector(selector));\n  }\n\n  private _nthSelector(nth: string): string {\n    if (selectorPiercesFrames(this._frameSelector))\n      throw new Error(`Selecting the nth frame is not allowed while piercing frames.`);\n    if (this._frameSelector === kNoPierceFramesSelector)\n      throw new Error(`Selecting the nth frame is not allowed on the root frame locator.`);\n    return this._frameSelector + ` >> nth=${nth}`;\n  }\n\n  first(): FrameLocator {\n    return new FrameLocator(this._frame, this._nthSelector('0'));\n  }\n\n  last(): FrameLocator {\n    return new FrameLocator(this._frame, this._nthSelector('-1'));\n  }\n\n  nth(index: number): FrameLocator {\n    return new FrameLocator(this._frame, this._nthSelector(String(index)));\n  }\n}\n\nlet _testIdAttributeName: string = 'data-testid';\n","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/locator.ts#L493-L529","documentation":"Error \"Selecting the nth frame is not allowed on the root frame locator.\" thrown in microsoft/playwright.","triggerScenarios":"Thrown at packages/playwright-core/src/client/locator.ts:511 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-12T18:17:37.767Z"}