feat: introduce page.browserContext() (#3655)
This commit is contained in:
parent
4346fa1978
commit
c90392bdf5
@ -96,6 +96,7 @@
|
|||||||
* [page.authenticate(credentials)](#pageauthenticatecredentials)
|
* [page.authenticate(credentials)](#pageauthenticatecredentials)
|
||||||
* [page.bringToFront()](#pagebringtofront)
|
* [page.bringToFront()](#pagebringtofront)
|
||||||
* [page.browser()](#pagebrowser)
|
* [page.browser()](#pagebrowser)
|
||||||
|
* [page.browserContext()](#pagebrowsercontext)
|
||||||
* [page.click(selector[, options])](#pageclickselector-options)
|
* [page.click(selector[, options])](#pageclickselector-options)
|
||||||
* [page.close([options])](#pagecloseoptions)
|
* [page.close([options])](#pagecloseoptions)
|
||||||
* [page.content()](#pagecontent)
|
* [page.content()](#pagecontent)
|
||||||
@ -1099,6 +1100,12 @@ Brings page to front (activates tab).
|
|||||||
|
|
||||||
Get the browser the page belongs to.
|
Get the browser the page belongs to.
|
||||||
|
|
||||||
|
#### page.browserContext()
|
||||||
|
|
||||||
|
- returns: <[BrowserContext]>
|
||||||
|
|
||||||
|
Get the browser context that the page belongs to.
|
||||||
|
|
||||||
#### page.click(selector[, options])
|
#### 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.
|
- `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]>
|
- `options` <[Object]>
|
||||||
|
@ -172,6 +172,13 @@ class Page extends EventEmitter {
|
|||||||
return this._target.browser();
|
return this._target.browser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {!Puppeteer.BrowserContext}
|
||||||
|
*/
|
||||||
|
browserContext() {
|
||||||
|
return this._target.browserContext();
|
||||||
|
}
|
||||||
|
|
||||||
_onTargetCrashed() {
|
_onTargetCrashed() {
|
||||||
this.emit('error', new Error('Page crashed!'));
|
this.emit('error', new Error('Page crashed!'));
|
||||||
}
|
}
|
||||||
|
@ -918,4 +918,10 @@ module.exports.addTests = function({testRunner, expect, headless}) {
|
|||||||
expect(page.browser()).toBe(browser);
|
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