1、launch()方法是无痕模式启动浏览器
2、非无痕模式启动浏览器
let userDataDir = path.join(getDataDir(), 'userInsMainDir');
let launch = {
headless: false,
slowMo: 100,
ignoreDefaultArgs: ['--mute-audio'],
isMobile: true,
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148',
viewport: {
width: 414,
height: 800
},
}
// browser = await chromium.launch(launch)
// const context = await browser.newContext()
browser = await chromium.launchPersistentContext(userDataDir, launch)
const page = browser.pages()
return page[0]
纯记录