Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (error) {
await browser.close();
errorHandler(error);
}
} else {
const browser = await puppeteer.launch({
headless,
args: sandbox ? undefined : ['--no-sandbox'],
});
const page = await browser.newPage();
try {
await page.emulate(devices[phone]);
} catch (error) {
console.log('可能错误: 1. 你输入的机型不存在 2.你输入的机型格式有误 3.暂不支持该机型');
console.log('支持的机型有:');
devices.forEach(function(item) {
console.log(item.name);
});
await browser.close();
errorHandler(error);
}
try {
let client;
if (customPath) {
const customPathFunction = require(customPath);
await customPathFunction(page, logInfo);
}
// If we want tu use a custom url, reach it before making metrics.
logInfo(`Testing ${url}...`);