parent
25b35c5789
commit
59f6d42610
@ -30,6 +30,7 @@
|
||||
- [class: Page](#class-page)
|
||||
* [event: 'console'](#event-console)
|
||||
* [event: 'dialog'](#event-dialog)
|
||||
* [event: 'domcontentloaded'](#event-domcontentloaded)
|
||||
* [event: 'error'](#event-error)
|
||||
* [event: 'frameattached'](#event-frameattached)
|
||||
* [event: 'framedetached'](#event-framedetached)
|
||||
@ -434,6 +435,10 @@ page.evaluate(() => console.log('hello', 5, {foo: 'bar'}));
|
||||
|
||||
Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Puppeteer can respond to the dialog via [Dialog]'s [accept](#dialogacceptprompttext) or [dismiss](#dialogdismiss) methods.
|
||||
|
||||
#### event: 'domcontentloaded'
|
||||
|
||||
Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
|
||||
|
||||
#### event: 'error'
|
||||
- <[Error]>
|
||||
|
||||
|
@ -95,6 +95,7 @@ class Page extends EventEmitter {
|
||||
this._networkManager.on(NetworkManager.Events.RequestFailed, event => this.emit(Page.Events.RequestFailed, event));
|
||||
this._networkManager.on(NetworkManager.Events.RequestFinished, event => this.emit(Page.Events.RequestFinished, event));
|
||||
|
||||
client.on('Page.domContentEventFired', event => this.emit(Page.Events.DOMContentLoaded));
|
||||
client.on('Page.loadEventFired', event => this.emit(Page.Events.Load));
|
||||
client.on('Runtime.consoleAPICalled', event => this._onConsoleAPI(event));
|
||||
client.on('Page.javascriptDialogOpening', event => this._onDialog(event));
|
||||
@ -965,6 +966,7 @@ function convertPrintParameterToInches(parameter) {
|
||||
Page.Events = {
|
||||
Console: 'console',
|
||||
Dialog: 'dialog',
|
||||
DOMContentLoaded: 'domcontentloaded',
|
||||
Error: 'error',
|
||||
// Can't use just 'error' due to node.js special treatment of error events.
|
||||
// @see https://nodejs.org/api/events.html#events_error_events
|
||||
|
@ -969,6 +969,13 @@ describe('Page', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.DOMContentLoaded', function() {
|
||||
it('should fire when expected', async({page, server}) => {
|
||||
page.goto('about:blank');
|
||||
await waitForEvents(page, 'domcontentloaded', 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.metrics', function() {
|
||||
it('should get metrics from a page', async({page, server}) => {
|
||||
await page.goto('about:blank');
|
||||
|
Loading…
Reference in New Issue
Block a user