From 5e038e5f677f5e5084c4512abc1e3a6875570d82 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 30 May 2025 09:24:17 +0200 Subject: [PATCH] add a timeout for waitforfunction --- playwright/cdp.js | 4 ++-- puppeteer/cdp.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playwright/cdp.js b/playwright/cdp.js index 72267d3..d334ce7 100644 --- a/playwright/cdp.js +++ b/playwright/cdp.js @@ -49,14 +49,14 @@ for (var run = 0; run { const price = document.querySelector('#product-price'); return price.textContent.length > 0; - }); + }, {}, {timeout: 100}); // timeout 100ms // ensure the reviews are loaded. await page.waitForFunction(() => { const reviews = document.querySelectorAll('#product-reviews > div'); return reviews.length > 0; - }); + }, {}, {timeout: 100}); // timeout 100ms let res = {}; diff --git a/puppeteer/cdp.js b/puppeteer/cdp.js index a0b57f4..e93cd65 100644 --- a/puppeteer/cdp.js +++ b/puppeteer/cdp.js @@ -54,14 +54,14 @@ let metrics = []; await page.waitForFunction(() => { const price = document.querySelector('#product-price'); return price.textContent.length > 0; - }); + }, {timeout: 100}); // timeout 100ms // ensure the reviews are loaded. await page.waitForFunction(() => { const reviews = document.querySelectorAll('#product-reviews > div'); return reviews.length > 0; - }); + }, {timeout: 100}); // timeout 100ms let res = {};