Open badsyntax opened 3 years ago
@badsyntax I've run into this same problem (also see https://github.com/microsoft/playwright/issues/11108#issuecomment-1002423196). Would you mind showing me how you're doing this?
setup the user session by manually "injecting" auth state from the saved "state.json" file
I can set the cookies fine (using context.addCookies({})
), but I haven't found a straightforward API to set local storage similarly.
@paambaati - you can create a fixture file like this. In this example below I created a fixture that will pre-populate my localstorage with a specific value I've defined. This allows me to get passed SSO authentication in my app
@badsyntax - is it possible to use palywright to invoke lighthouse? Or are you using an additional npm package for this?
@cliffordfajardo i'm using https://www.npmjs.com/package/playwright-lighthouse and it's working pretty well
Closing as per above, please feel free to open a new issue if this does not cover your use case.
Yes, I agree that it would be very useful to have this feature.
Currently the only way is to manually load the cookies when opening the context. Does anyone know how to also load the localStorage?
Puppeteer has a recipe for running lighthouse on authenticated pages, but seems to rely on lighthouse taking a Puppeteer page as the 4th argument.
https://github.com/GoogleChrome/lighthouse/blob/main/docs/recipes/auth/README.md
I would love to have this feature. Waiting for it!
Vote for it
any update on this?
Feature request
Hi there.
It would be really handy to be able to populate a persistent context with auth state, similar to browser.newContext({ storageState: 'state.json' }).
I am generating auth-state (
state.json
) in my globalSetup, and I'm using a persistent context to allow lighthouse to run on authenticated routes, but I currently have to manually setup the user session by manually "injecting" auth state from the saved "state.json" file. It would be really convenient if I could do this instead: