NodeJS使用puppeteer进行截图

const puppeteer = require('/home/ordinaryUser_2/automation/NodeJS/node/lib/node_global/lib/node_modules/puppeteer');
async function screen() {
const browser = await puppeteer.launch({
executablePath:process.env.CHROMEPATH,
headless: true
});
const page = await browser.newPage();
await page.setDefaultTimeout(3000);
await page.goto(process.env.MAILREPORTPATH);
await page.setViewport({
width: 1152,
height: 864
});
await page.screenshot({
path: process.env.SCREENSHOTPATH,
fullPage: true
});
await browser.close();
await Promise.reject(new Error('screen'));
}

下面是一个比较全的连接

https://guozh.net/puppeteer-screenshot/

posted @ 2019-11-29 17:07  煦色韶光  阅读(1687)  评论(0编辑  收藏  举报