Avoid crash if Cookie consent button is not visible

This commit is contained in:
drigtime 2022-08-26 18:32:44 +02:00
parent 90af31a210
commit b786402897

View file

@ -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);