indent logging per game
This commit is contained in:
parent
777b00b3fb
commit
548ba67e10
1 changed files with 11 additions and 11 deletions
|
|
@ -26,7 +26,7 @@ const context = await chromium.launchPersistentContext(dirs.browser, {
|
|||
// channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
|
||||
headless: false,
|
||||
viewport: { width: SCREEN_WIDTH, height: SCREEN_HEIGHT },
|
||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO update if browser is updated!
|
||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO Windows UA enough to avoid 'device not supported'? update if browser is updated?
|
||||
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
||||
// recordVideo: { dir: 'data/videos/' }, // will record a .webm video for each page navigated
|
||||
args: [ // https://peter.sh/experiments/chromium-command-line-switches
|
||||
|
|
@ -43,7 +43,7 @@ await stealth(context);
|
|||
if (!debug) context.setDefaultTimeout(TIMEOUT);
|
||||
|
||||
const page = context.pages().length ? context.pages()[0] : await context.newPage(); // should always exist
|
||||
console.debug('userAgent:', await page.evaluate(() => navigator.userAgent));
|
||||
// console.debug('userAgent:', await page.evaluate(() => navigator.userAgent));
|
||||
|
||||
try {
|
||||
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // 'domcontentloaded' faster than default 'load' https://playwright.dev/docs/api/class-page#page-goto
|
||||
|
|
@ -88,7 +88,7 @@ try {
|
|||
|
||||
const title = await page.locator('h1 div').first().innerText();
|
||||
const title_url = page.url().split('/').pop();
|
||||
console.log('Current free game:', title, title_url);
|
||||
console.log('Current free game:', title);
|
||||
|
||||
if (btnText.toLowerCase() == 'in library') {
|
||||
console.log(' Already in library! Nothing to claim.');
|
||||
|
|
@ -96,7 +96,7 @@ try {
|
|||
console.log(' Not in library yet! Click GET.');
|
||||
await page.click('[data-testid="purchase-cta-button"]');
|
||||
|
||||
// click Continue if 'Device not supported. This product is not compatible with your current device.'
|
||||
// click Continue if 'Device not supported. This product is not compatible with your current device.' - avoidable by Windows userAgent?
|
||||
await Promise.any(['button:has-text("Continue")', '#webPurchaseContainer iframe'].map(s => page.waitForSelector(s))); // wait for Continue xor iframe
|
||||
if (await page.locator('button:has-text("Continue")').count() > 0) {
|
||||
// console.log(' Device not supported. This product is not compatible with your current device.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue