page.waitForNavigation -> page.waitForURL

This commit is contained in:
Ralf Vogler 2023-02-04 21:37:04 +01:00
parent eb17a49628
commit b9e9abe546
3 changed files with 6 additions and 8 deletions

View file

@ -56,7 +56,7 @@ try {
await page.fill('[name=password]', password);
await page.check('[name=rememberMe]');
await page.click('input[type="submit"]');
page.waitForNavigation({ url: '**/ap/signin**'}).then(async () => { // check for wrong credentials
page.waitForURL('**/ap/signin**').then(async () => { // check for wrong credentials
const error = await page.locator('.a-alert-content').first().innerText();
console.error(error);
notify(`prime-gaming: login: ${error}`);
@ -64,7 +64,7 @@ try {
process.exit(1);
});
// handle MFA, but don't await it
page.waitForNavigation({ url: '**/ap/mfa**'}).then(async () => {
page.waitForURL('**/ap/mfa**').then(async () => {
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
await page.check('[name=rememberDevice]');
const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
@ -80,7 +80,7 @@ try {
process.exit(1);
}
}
await page.waitForNavigation({ url: 'https://gaming.amazon.com/home?signedIn=true' });
await page.waitForURL('https://gaming.amazon.com/home?signedIn=true');
if (!cfg.debug) context.setDefaultTimeout(cfg.timeout);
}
const user = await page.locator('[data-a-target="user-dropdown-first-name-text"]').first().innerText();
@ -125,8 +125,7 @@ try {
const title = await (await card.$('.item-card-details__body__primary')).innerText();
console.log('Current free game:', title);
if (cfg.dryrun) continue;
await (await card.$('text=Claim')).click();
// await page.waitForNavigation();
await (await card.$('text=Claim')).click(); // goes to URL of game, no need to wait
await Promise.any([page.click('button:has-text("Claim now")'), page.click('button:has-text("Complete Claim")'), page.waitForSelector('div:has-text("Link game account")')]); // waits for navigation
const store_text = await (await page.$('[data-a-target="hero-header-subtitle"]')).innerText();
// Full game for PC [and MAC] on: gog.com, Origin, Legacy Games, EPIC GAMES, Battle.net