From cbe789b08d3cb04e52e9bb975ad79b1a1274675e Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 15 Sep 2022 16:40:18 +0200 Subject: [PATCH] temporarily fix #25 by waitUntil networkidle should wait for some element/attribute/event instead --- epic-games.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epic-games.js b/epic-games.js index f873180..0680e57 100644 --- a/epic-games.js +++ b/epic-games.js @@ -47,7 +47,7 @@ const page = context.pages().length ? context.pages()[0] : await context.newPage console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); try { - await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever + await page.goto(URL_CLAIM, { waitUntil: 'networkidle' }); // 'domcontentloaded' faster than default 'load' https://playwright.dev/docs/api/class-page#page-goto - changed to 'networkidle' temporarily due to race https://github.com/vogler/free-games-claimer/issues/25 // Accept cookies to get rid of banner to save space on screen. Will only appear for a fresh context, so we don't await, but let it time out if it does not exist and catch the exception. clickIfExists by checking selector's count > 0 did not work. page.click('button:has-text("Accept All Cookies")').catch(_ => {}); // _ => console.info('Cookies already accepted') while (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) { // TODO also check alternative for signed-in state