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'));
}
下面是一个比较全的连接