Skip to content

Commit

Permalink
feat: expose the page getter on Frame (#8657)
Browse files Browse the repository at this point in the history
* feat: expose the page getter on Frame

Closes #8654

* test: add a test
  • Loading branch information
OrKoN committed Jul 11, 2022
1 parent dd27559 commit af08c5c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/puppeteer.frame.md
Expand Up @@ -80,6 +80,7 @@ console.log(text);
| [isDetached()](./puppeteer.frame.isdetached.md) | | |
| [isOOPFrame()](./puppeteer.frame.isoopframe.md) | | |
| [name()](./puppeteer.frame.name.md) | | |
| [page()](./puppeteer.frame.page.md) | | |
| [parentFrame()](./puppeteer.frame.parentframe.md) | | |
| [select(selector, values)](./puppeteer.frame.select.md) | | Triggers a <code>change</code> and <code>input</code> event once all the provided options have been selected. |
| [setContent(html, options)](./puppeteer.frame.setcontent.md) | | Set the content of the frame. |
Expand Down
19 changes: 19 additions & 0 deletions docs/api/puppeteer.frame.page.md
@@ -0,0 +1,19 @@
---
sidebar_label: Frame.page
---

# Frame.page() method

**Signature:**

```typescript
class Frame {
page(): Page;
}
```

**Returns:**

[Page](./puppeteer.page.md)

a page associated with the frame.
7 changes: 7 additions & 0 deletions src/common/FrameManager.ts
Expand Up @@ -769,6 +769,13 @@ export class Frame {
);
}

/**
* @returns a page associated with the frame.
*/
page(): Page {
return this._frameManager.page();
}

/**
* @remarks
*
Expand Down
9 changes: 9 additions & 0 deletions test/src/frame.spec.ts
Expand Up @@ -116,6 +116,15 @@ describe('Frame specs', function () {
});
});

describe('Frame.page', function () {
it('should retrieve the page from a frame', async () => {
const {page, server} = getTestState();
await page.goto(server.EMPTY_PAGE);
const mainFrame = page.mainFrame();
expect(mainFrame.page()).toEqual(page);
});
});

describe('Frame Management', function () {
itFailsFirefox('should handle nested frames', async () => {
const {page, server} = getTestState();
Expand Down

0 comments on commit af08c5c

Please sign in to comment.