mirror of
https://github.com/astefanutti/decktape.git
synced 2025-01-07 14:58:31 +03:00
Migrate page events to Puppeteer API
This commit is contained in:
parent
12f7681a92
commit
b8fed571e3
26
decktape.js
26
decktape.js
@ -146,28 +146,14 @@ const options = parser.parse(process.argv.slice(2));
|
||||
const page = await browser.newPage();
|
||||
const printer = hummus.createWriter(options.filename);
|
||||
|
||||
page.onLoadStarted = _ => console.log('Loading page', options.url, '...');
|
||||
|
||||
page.onResourceTimeout = request => console.log('+- Request timeout:', JSON.stringify(request));
|
||||
|
||||
page.onResourceError = resource => {
|
||||
console.log('+- Unable to load resource from URL:', resource.url);
|
||||
console.log('|_ Error code:', resource.errorCode);
|
||||
console.log('|_ Description:', resource.errorString);
|
||||
};
|
||||
|
||||
page.onLoadFinished = status => console.log('Loading page finished with status:', status);
|
||||
|
||||
page.on('console', (...args) => console.log(args));
|
||||
|
||||
page.onError = (msg, trace) => {
|
||||
console.log('+-', msg);
|
||||
(trace || [])
|
||||
.map(t => `|_ ${t.file}: ${t.line}${t.function ? ` (in function "${t.function}")` : ''}`)
|
||||
.forEach(console.log)
|
||||
};
|
||||
page
|
||||
.on('console', console.log)
|
||||
.on('pageerror', error => console.log('\nPage error:', error.message))
|
||||
.on('requestfailed', request => console.log('Unable to load resource from URL:', request.url));
|
||||
|
||||
console.log('Loading page', options.url, '...');
|
||||
page.goto(options.url, { waitUntil: 'load', timeout: 60000 })
|
||||
.then(response => console.log('Loading page finished with status:', response.status))
|
||||
.then(removeCssPrintStyles)
|
||||
.then(delay(options.loadPause))
|
||||
.then(createPlugin)
|
||||
|
Loading…
Reference in New Issue
Block a user