From b7864028974410448fcec78f3808b8d52b1d42c3 Mon Sep 17 00:00:00 2001 From: drigtime Date: Fri, 26 Aug 2022 18:32:44 +0200 Subject: [PATCH] Avoid crash if Cookie consent button is not visible --- prime-gaming.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prime-gaming.js b/prime-gaming.js index 4999449..082490b 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -39,7 +39,8 @@ const page = context.pages()[0]; console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); const clickIfExists = async selector => { - if (await page.locator(selector).count() > 0) + const cookieConsent = await page.locator(selector) + if (await cookieConsent.count() > 0 && await cookieConsent.isVisible()) await page.click(selector); }; @@ -132,8 +133,8 @@ try { await page.goto(URL_CLAIM, {waitUntil: 'domcontentloaded'}); await page.click('button[data-type="Game"]'); } while (n); - const p = path.resolve(dirs.screenshots, 'prime-gaming', `${datetime()}.png`); - // await page.screenshot({ path: p, fullPage: true }); + const p = path.resolve(dirs.screenshots, 'prime-gaming', `${sanitizeFilename(datetime())}.png`); + await page.screenshot({ path: p, fullPage: true }); await page.locator(games_sel).screenshot({ path: p }); } catch(error) { console.error(error);