mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: make screenshots work in puppeteer-web (#6936)
This commit is contained in:
parent
1c2479a6cd
commit
5f24f60819
@ -1740,13 +1740,16 @@ export class Page extends EventEmitter {
|
|||||||
options.encoding === 'base64'
|
options.encoding === 'base64'
|
||||||
? result.data
|
? result.data
|
||||||
: Buffer.from(result.data, 'base64');
|
: Buffer.from(result.data, 'base64');
|
||||||
if (!isNode && options.path) {
|
|
||||||
|
if (options.path) {
|
||||||
|
if (!isNode) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Screenshots can only be written to a file path in a Node environment.'
|
'Screenshots can only be written to a file path in a Node environment.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const fs = await helper.importFSModule();
|
const fs = await helper.importFSModule();
|
||||||
if (options.path) await fs.promises.writeFile(options.path, buffer);
|
await fs.promises.writeFile(options.path, buffer);
|
||||||
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
||||||
function processClip(
|
function processClip(
|
||||||
|
Loading…
Reference in New Issue
Block a user