eg: set cookie instead of click 'Accept All Cookies'
This commit is contained in:
parent
094662aefc
commit
2012c7e2f2
1 changed files with 4 additions and 2 deletions
|
|
@ -54,10 +54,12 @@ const page = context.pages().length ? context.pages()[0] : await context.newPage
|
|||
// console.debug('userAgent:', await page.evaluate(() => navigator.userAgent));
|
||||
|
||||
try {
|
||||
await context.addCookies([{name: 'OptanonAlertBoxClosed', value: '2022-10-06T21:15:28.081Z', domain: '.epicgames.com', path: '/'}]);
|
||||
|
||||
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // 'domcontentloaded' faster than default 'load' https://playwright.dev/docs/api/class-page#page-goto
|
||||
|
||||
// Accept cookies to get rid of banner to save space on screen. Will only appear for a fresh context, so we don't await, but let it time out if it does not exist and catch the exception. clickIfExists by checking selector's count > 0 did not work.
|
||||
page.click('button:has-text("Accept All Cookies")').catch(_ => { }); // _ => console.info('Cookies already accepted')
|
||||
// Accept cookies to get rid of banner to save space on screen. Clicking this did not always work since the message was animated in too slowly.
|
||||
// page.click('button:has-text("Accept All Cookies")').catch(_ => { }); // not needed anymore since we set the cookie above
|
||||
|
||||
while (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) { // TODO also check alternative for signed-in state
|
||||
console.error("Not signed in anymore. Please login and then navigate to the 'Free Games' page. If using docker, open http://localhost:6080");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue