From 2e8a731573f1f6c2b222cc1b21dcd3f1c3954346 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 13 Jul 2023 10:56:12 +0200 Subject: [PATCH] pg: update selectors for internal/external games, fixes #164 --- prime-gaming.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prime-gaming.js b/prime-gaming.js index 878ba50..695951e 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -97,12 +97,13 @@ try { await page.click('button[data-type="Game"]'); await page.keyboard.press('End'); // scroll to bottom to show all games await page.waitForLoadState('networkidle'); // wait for all games to be loaded + await page.waitForTimeout(2000); // TODO networkidle wasn't enough to load all already collected games const games = page.locator('div[data-a-target="offer-list-FGWP_FULL"]'); await games.waitFor(); console.log('Number of already claimed games (total):', await games.locator('p:has-text("Collected")').count()); // can't use .all() since the list of elements via locator will change after click while we iterate over it - const internal = await games.locator('[data-a-target="claim-prime-offer-card"]:has-text("Claim")').elementHandles(); - const external = games.locator('[data-a-target="learn-more-card"]:has(p:text-is("Claim"))'); // using .elementHandles() here would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode) + const internal = await games.locator('.item-card__action:has([data-a-target="FGWPOffer"])').elementHandles(); + const external = games.locator('.item-card__action:has([data-a-target="ExternalOfferClaim"])'); // using .elementHandles() here would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode) console.log('Number of free unclaimed games (Prime Gaming):', internal.length); // claim games in internal store for (const card of internal) {