feat: introduce page.browserContext() (#3655)
This commit is contained in:
parent
4346fa1978
commit
c90392bdf5
@ -96,6 +96,7 @@
|
||||
* [page.authenticate(credentials)](#pageauthenticatecredentials)
|
||||
* [page.bringToFront()](#pagebringtofront)
|
||||
* [page.browser()](#pagebrowser)
|
||||
* [page.browserContext()](#pagebrowsercontext)
|
||||
* [page.click(selector[, options])](#pageclickselector-options)
|
||||
* [page.close([options])](#pagecloseoptions)
|
||||
* [page.content()](#pagecontent)
|
||||
@ -1099,6 +1100,12 @@ Brings page to front (activates tab).
|
||||
|
||||
Get the browser the page belongs to.
|
||||
|
||||
#### page.browserContext()
|
||||
|
||||
- returns: <[BrowserContext]>
|
||||
|
||||
Get the browser context that the page belongs to.
|
||||
|
||||
#### page.click(selector[, options])
|
||||
- `selector` <[string]> A [selector] to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
|
||||
- `options` <[Object]>
|
||||
|
@ -172,6 +172,13 @@ class Page extends EventEmitter {
|
||||
return this._target.browser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Puppeteer.BrowserContext}
|
||||
*/
|
||||
browserContext() {
|
||||
return this._target.browserContext();
|
||||
}
|
||||
|
||||
_onTargetCrashed() {
|
||||
this.emit('error', new Error('Page crashed!'));
|
||||
}
|
||||
|
@ -918,4 +918,10 @@ module.exports.addTests = function({testRunner, expect, headless}) {
|
||||
expect(page.browser()).toBe(browser);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.browserContext', function() {
|
||||
it('should return the correct browser instance', async function({page, context, browser}) {
|
||||
expect(page.browserContext()).toBe(context);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user