playstation: handle non-base free games

This commit is contained in:
Omair 2023-08-01 14:00:19 -04:00
parent f08f334c8d
commit 5ea6487d2b

View file

@ -222,6 +222,7 @@ async function redeemFreeGames() {
const gameCard = page.locator(".content-grid").first(); const gameCard = page.locator(".content-grid").first();
await gameCard.waitFor(); await gameCard.waitFor();
const title = await gameCard.locator("h1").first().innerText(); const title = await gameCard.locator("h1").first().innerText();
const game_id = page const game_id = page
.url() .url()
.split("/") .split("/")
@ -233,14 +234,14 @@ async function redeemFreeGames() {
notify_games.push(notify_game); // status is updated below notify_games.push(notify_game); // status is updated below
// SELECTORS // SELECTORS
const inLibrary = gameCard const inLibrary = page
.locator('span:has-text("In library")') .locator('span:has-text("In library")')
.first(); .first();
const purchased = gameCard const purchased = page
.locator('span:has-text("Purchased")') .locator('span:has-text("Purchased")')
.first(); .first();
const addToLibrary = gameCard const addToLibrary = page // the base game may not be the free one, look for any edition
.locator('span:has-text("Add to Library")') .locator('button[data-track-click="ctaWithPrice:addToLibrary"]')
.nth(1); .nth(1);
await Promise.any([addToLibrary.waitFor(), purchased.waitFor(), inLibrary.waitFor()]); await Promise.any([addToLibrary.waitFor(), purchased.waitFor(), inLibrary.waitFor()]);