feat: expose the page getter on Frame (#8657)

* feat: expose the page getter on Frame

Closes #8654

* test: add a test
This commit is contained in:
Alex Rudenko 2022-07-11 21:06:35 +02:00 committed by GitHub
parent dd27559090
commit af08c5c903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 0 deletions

View File

@ -80,6 +80,7 @@ console.log(text);
| [isDetached()](./puppeteer.frame.isdetached.md) | | | | [isDetached()](./puppeteer.frame.isdetached.md) | | |
| [isOOPFrame()](./puppeteer.frame.isoopframe.md) | | | | [isOOPFrame()](./puppeteer.frame.isoopframe.md) | | |
| [name()](./puppeteer.frame.name.md) | | | | [name()](./puppeteer.frame.name.md) | | |
| [page()](./puppeteer.frame.page.md) | | |
| [parentFrame()](./puppeteer.frame.parentframe.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. | | [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. | | [setContent(html, options)](./puppeteer.frame.setcontent.md) | | Set the content of the frame. |

View File

@ -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.

View File

@ -769,6 +769,13 @@ export class Frame {
); );
} }
/**
* @returns a page associated with the frame.
*/
page(): Page {
return this._frameManager.page();
}
/** /**
* @remarks * @remarks
* *

View File

@ -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 () { describe('Frame Management', function () {
itFailsFirefox('should handle nested frames', async () => { itFailsFirefox('should handle nested frames', async () => {
const {page, server} = getTestState(); const {page, server} = getTestState();