From 0b737807cf2c7d2094fabf1407103b12e12bb6fd Mon Sep 17 00:00:00 2001 From: Omair Date: Tue, 1 Aug 2023 14:39:54 -0400 Subject: [PATCH] playstation: use better locator for sign in button --- playstation-plus.js | 6 +++--- util.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playstation-plus.js b/playstation-plus.js index 31d15a1..f0ff6a0 100644 --- a/playstation-plus.js +++ b/playstation-plus.js @@ -64,10 +64,10 @@ async function main() { } async function performLogin() { - // the page gets stuck sometimes and requires a reload - await retryOnError(() => page.goto(URL_CLAIM, { timeout: 20_000, waitUntil: "networkidle" })); + // the page gets stuck sometimes and requires a reload + await retryOnError(() => page.goto(URL_CLAIM, { timeout: 20_000, waitUntil: "domcontentloaded" })); - const signInLocator = page.locator('span:has-text("Sign in")').first(); + const signInLocator = page.locator('button[data-track-click="web:select-sign-in-button"]').first(); const profileIconLocator = page.locator(".profile-icon").first(); const mainPageBaseUrl = "https://playstation.com"; diff --git a/util.js b/util.js index 81e6bd9..d20cbe3 100644 --- a/util.js +++ b/util.js @@ -34,7 +34,7 @@ export const retryOnError = (promiseFn, maxRetries = 1) => { resolve(result); } catch (error) { if (remainingRetries > 0) { - console.log(`Retrying... ${remainingRetries} retries left.`); + console.log(`Retrying... ${remainingRetries - 1} retries left.`); executePromise(remainingRetries - 1); // Retry the Promise with one less retry } else { reject(error); // No more retries left, reject with the last error