我有一个木偶项目,需要提交一个表格,然后等待下一页。问题是,为了转到下一个页面,网站会进行大约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'});发布于 2019-07-12 20:53:56
我遇到过类似的问题,并通过等待所需页面中的特定选择器来解决它。
await page.waitForSelector('#manage-trips', { visible: true, timeout: 0 });https://stackoverflow.com/questions/51601292
复制相似问题