log urlSlug, #25

This commit is contained in:
Ralf Vogler 2022-09-29 16:28:06 +02:00
parent e5ae4b6316
commit 69d771b38c

View file

@ -64,7 +64,7 @@ try {
// click on each banner with 'Free Now'. TODO just extract the URLs and go to them in the loop // click on each banner with 'Free Now'. TODO just extract the URLs and go to them in the loop
// This json contains all promotions: https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions // This json contains all promotions: https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions
// Could filter data.Catalog.searchStore.elements for .promotions.promotionalOffers being set and build URL with .catalogNs.mappings[0].pageSlug or .urlSlug if not set to some wrong id like it was the case for spirit-of-the-north-f58a66 // Could filter data.Catalog.searchStore.elements for .promotions.promotionalOffers being set and build URL with .catalogNs.mappings[0].pageSlug or .urlSlug if not set to some wrong id like it was the case for spirit-of-the-north-f58a66
const game_sel = 'span:text-is("Free Now")'; const game_sel = 'a:has(span:text-is("Free Now"))';
await page.waitForSelector(game_sel); await page.waitForSelector(game_sel);
// const games = await page.$$(game_sel); // 'Element is not attached to the DOM' after navigation; had `for (const game of games) { await game.click(); ... } // const games = await page.$$(game_sel); // 'Element is not attached to the DOM' after navigation; had `for (const game of games) { await game.click(); ... }
const n = run.n = await page.locator(game_sel).count(); const n = run.n = await page.locator(game_sel).count();
@ -72,6 +72,7 @@ try {
// fixes for https://github.com/vogler/free-games-claimer/issues/25 when URL of game is changed by JS: // fixes for https://github.com/vogler/free-games-claimer/issues/25 when URL of game is changed by JS:
// await page.waitForResponse(/freeGamesPromotions/); // not enough // await page.waitForResponse(/freeGamesPromotions/); // not enough
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
console.log('urlSlug', await page.locator(game_sel).nth(i).getAttribute('href'));
await page.waitForTimeout(3000); await page.waitForTimeout(3000);
await page.locator(game_sel).nth(i).click(); // navigates to page for game await page.locator(game_sel).nth(i).click(); // navigates to page for game
const btnText = await page.locator('//button[@data-testid="purchase-cta-button"][not(contains(.,"Loading"))]').first().innerText(); // barrier to block until page is loaded const btnText = await page.locator('//button[@data-testid="purchase-cta-button"][not(contains(.,"Loading"))]').first().innerText(); // barrier to block until page is loaded