因此,我正在尝试下载一个这样的pdf文件,该文件会在弹出窗口中打开。
在此处使用此代码获取弹出窗口并将其下载到“ ./”。
const popUp = await popUpPromise
await popUp.waitFor(5000)
// await popUp.waitForSelector('.content')
const pdf = await popUp.$$eval('html', e => e)
await console.log(pdf)
await popUp._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './'})
但是,不仅下载不正常,而且弹出的html返回空。
为了从弹出窗口下载pdf,一旦弹出窗口加载,你将需要模拟按ctrl-s的操作。它应该下载到你的“下载行为”设置中的指定文件夹中。尝试使用await page.type()
或await page.press()