Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second browser window is opening. #82

Open
ZurabKV opened this issue May 24, 2024 · 4 comments
Open

Second browser window is opening. #82

ZurabKV opened this issue May 24, 2024 · 4 comments

Comments

@ZurabKV
Copy link

ZurabKV commented May 24, 2024

Hello.
We were trying to update version of playwright-lighthouse from 2.2.2 to 4.0.0.
Older version of the package ran lighthouse audit in the same browser window and it worked well. New version of lighthouse additionally openes new browser window when running function playAudit(). Is there a way to prevent this from happening and perform the audit in the initial browser window?

New browser window doesn't have necessary cookies (and maybe some other storage data?) which causes the page to open with errors.
I found a way to pass necessary cookies to the second browser:
return playAudit({

return playAudit({
  ...
  opts: {
    logLevel: 'debug',
    extraHeaders: {
      Cookie: 'cookie1=val1;cookie2=val2...'
    }
  }
  ...
}); 

And it did partially help to resolve the issue. Partially, because it passed all the cookies, apart from one. My guess is it is because that specific cookie contained = sybol inside its value, perhaps this somehow prevents the cookie to be added to the 2nd browser?

@gurjitmehta03
Copy link

@ZurabKV Facing the same issue

@veritoneadam
Copy link

veritoneadam commented Jul 25, 2024

Same issue, additional consequences.

I'm running a11y audits on a page generated from a form submission (POST). Because playAudit is re-loading the page itself, it does a GET to the url and loses the form context.

await page.route('https://example.com/form-endpoint', (route, request) => {
  const method = 'POST';
  const postData = 'key=value';
  route.continue({ method, postData });
});

await page.goto('https://example.com/form-endpoint'); // works ok
await playAudit({
  page,
  thresholds: {accessibility: 99},
  opts: {onlyCategories: ['accessibility']},
}); // does GET request & reloads the page

It's like running lighthouse in chrome in 'Navigation' mode instead of 'Snapshot'? Could this be fixed via #44 ?

@alphonse92
Copy link

Facing the same issue, this repo seems poor maintained

@mckeckers
Copy link

Same issue here. Sadly, this makes temporal testing impossible with Playwright which, for me, is the big selling point of LightHouse.
I had to revert back several versions to get this working.

"lighthouse": "^9.6.8",
"@lighthousejs/types": "^0.0.3",
"playwright-lighthouse": "^2.2.2",

As Playwright is now the most popular test framework, it would be good to see the Lighthouse plugin maintained for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants