【发布时间】:2018-07-30 19:48:52
【问题描述】:
我有一个 puppeteer 项目,需要提交一个表单,然后等待下一页。问题是要进入下一页,网站会进行大约 3-4 次重定向,然后才会开始加载实际内容。
Puppeteer 似乎卡在了中间的某个地方。
我该如何解决这个问题?
这是我的代码:
await page.goto('<url>/Login.html', {'waitUntil': 'networkidle0', timeout: 60000});
await page.click(USERID_SLCT);
await page.keyboard.type(creds.userId);
await page.click(PWD_SLCT);
await page.keyboard.type(creds.pwd);
await page.click(LOGINBTN_SLCT);
await page.waitForNavigation({'waitUntil': 'networkidle0'});
await timeout(240000); // wait for the redirects to be finished
await page.waitForSelector(BTN_SLCT, {timeout: 240000}); // make sure the page is loaded <-- would fail here
await page.screenshot({path: './screenshots/mainpage.png'});
【问题讨论】:
-
您是如何决定
240000超时的? -
尝试了 30 秒、60 秒、120 秒、240 秒……没有任何帮助。通过常规浏览器访问此页面时 - 大约需要 3-5 秒。
标签: javascript node.js puppeteer google-chrome-headless