【问题标题】:Puppeteer timeout of 3000ms exceeded when clicking a button that Filters results单击过滤结果的按钮时,超过 3000 毫秒的 Puppeteer 超时
【发布时间】:2020-08-16 23:49:19
【问题描述】:

我的代码:

const puppeteer = require("puppeteer");

(async () => {
  try {
    const browser = await puppeteer.launch();

    const page = await browser.newPage();
    await page.goto("https://www.genglobal.org/member-directory");

    await page.type("#edit-field-first-name-value", "Abbas");
    await page.type("#edit-field-last-name-value", "AL ASMAR");

    await page.click(".agree-button.eu-cookie-compliance-secondary-button");

    const [submitSearch] = await Promise.all([
      page.waitForNavigation(),
      page.click("#edit-submit-member-directory"),
    ]);

    await page.screenshot({ path: "screenshot.png" });

    await browser.close();
  } catch (error) {
    console.log(`this is the ${error}`);
  }
})();

错误:

this is the TimeoutError: Navigation timeout of 30000 ms exceeded

我想要达到的目标:

在相应的输入字段中输入名字和姓氏,然后单击过滤器按钮。但是,当我通过单击过滤器按钮提交表单时,它给了我上面提到的错误。我不明白为什么...

【问题讨论】:

    标签: javascript node.js web-scraping puppeteer browser-automation


    【解决方案1】:

    我使用以下命令解决了这个问题。

    page.setDefaultNavigationTimeout(100000);
    
    

    将导航时间设置为 10 秒。

    问候

    【讨论】:

      【解决方案2】:

      如果我理解正确,page.waitForNavigation() 涉及 URL 更改,而过滤器按钮仅使用 AJAX 请求并修改 DOM。你可以试试page.waitForResponse()page.waitForSelector()

      【讨论】:

        猜你喜欢
        • 2021-12-31
        • 2023-03-04
        • 2011-06-21
        • 1970-01-01
        • 1970-01-01
        • 2022-12-29
        • 1970-01-01
        • 2017-04-15
        • 2022-01-25
        相关资源
        最近更新 更多