Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose the page getter on Frame #8657

Merged
merged 2 commits into from Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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