How to fix waitForFunction TimeoutError of puppeteer All In One
How to fix waitForFunction TimeoutError of puppeteer All In One
page.waitForFunction
超时错误
error ❌
TimeoutError: Waiting failed: 30000ms exceeded
const selector = '.foo';
await page.waitForFunction((selector) => !!document.querySelector(selector));
solution ✅
const selector = '.foo';
await page.waitForFunction(
selector => !!document.querySelector(selector),
{},
selector
);
demos
https://github.com/web-full-stack/cyclic-express-server
https://cyclic-express-server.cyclic.cloud/api/tesla
waitForFunction
class Page {
waitForFunction<
Params extends unknown[],
Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
>(
pageFunction: Func | string,
options?: FrameWaitForFunctionOptions,
...args: Params
): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
}
https://pptr.dev/api/puppeteer.page.waitforfunction
waitForSelector
class Page {
waitForSelector<Selector extends string>(
selector: Selector,
options?: WaitForSelectorOptions
): Promise<ElementHandle<NodeFor<Selector>> | null>;
}
https://pptr.dev/api/puppeteer.page.waitforselector
refs
https://github.com/puppeteer/puppeteer/issues/9578#issuecomment-1705527672
©xgqfrms 2012-2021
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
未经授权禁止转载,违者必究!