我的代码:
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
我要实现的目标:
在相应的输入字段中输入名字和姓氏,然后单击FILTER按钮。但是,当我通过单击“过滤器”按钮提交表单时,它给了我上面提到的错误。我不明白为什么...
答案 0 :(得分:2)
如果我正确理解,page.waitForNavigation()
会涉及URL更改,而过滤器按钮仅使用AJAX请求并修改DOM。您可以尝试使用page.waitForResponse()
和page.waitForSelector()
。
答案 1 :(得分:1)
我使用波纹管命令解决了这个问题。
PostId
将导航时间设置为10秒。
致谢