因此,我设法登录到网站并导航至下载页面,我试图通过单击此元素来下载xls文件,
<input type="image" name="AgencyTimesheets1$cmdXLS" id="AgencyTimesheets1_cmdXLS" title="Export to Excel" onmouseover=";imageChange( this ,'/Assets/img/excel_button_hot.png')" onmouseout=";imageChange( this ,'/Assets/img/excel_button.png')" src="/Assets/img/excel_button.png" style="border-width:0px;">
但是无论我等待多长时间(下载只需要5秒钟),我的下载目录/tmp/
都不会出现
点击元素后,我已经截取了屏幕截图,由于按钮在屏幕截图中以黄色突出显示,因此确实被单击了,该按钮保存在/tmp/
中
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: true,
userDataDir: "/tmp/"
});
const page = await browser.newPage();
// log in and navigate to download page etc...
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow',
downloadPath: '/tmp/'})
await page.click('#AgencyTimesheets1_cmdXLS');
await page.screenshot({ path: '/tmp/progress.png', fullPage: true });
await page.waitFor(10000);
await browser.close();
})();
我没有任何错误,下载目录中什么也没有