lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

token store in sessionStorage

Open Fangtzu1024 opened this issue 3 years ago • 4 comments

I have a web app, which is built by react. the page is protected by a login page after login, a token is stored in sessionStorage, then jump to home page

I want to use puppeteer to login first, in a seprate tab, and at some point when lighthouse begin to load the url(another tab, would not inherit the tokens), and in the targetchange listener inject the token to sessionStorage. but failed with "Provide URL did not match initial navigation URL", How to make lighthouse wait for inject the token, or lighthouse does not open new tab?please help. Thanks

pic

Fangtzu1024 avatar May 30 '22 07:05 Fangtzu1024

Have you checked out https://github.com/GoogleChrome/lighthouse/blob/master/docs/authenticated-pages.md?

adamraine avatar May 31 '22 18:05 adamraine

Have you checked out https://github.com/GoogleChrome/lighthouse/blob/master/docs/authenticated-pages.md?

Yes, I use option1 Script the login with Puppeteer. after use puppeteer to login and token stores in sessionStorage, and then run lighthouse always at login page because lighthouse open another tab and can not inherit the tokens.

Have any other solutions? please help, thanks.

Fangtzu1024 avatar Jun 02 '22 03:06 Fangtzu1024

Please help~~~

Fangtzu1024 avatar Jun 10 '22 01:06 Fangtzu1024

Yes, I use option1 Script the login with Puppeteer. after use puppeteer to login and token stores in sessionStorage, and then run lighthouse always at login page because lighthouse open another tab and can not inherit the tokens.

I see, the login status is not shared between tabs because you are using sessionStorage. You have a couple options here:

  • Test the login interaction using a user flow. I would recommend this approach, as the next approach is experimental.
  • LH 10.0 will change how the standard lighthouse() API to accept a puppeteer page directly. You will either have to wait for 10.0 to be released or clone the master branch from this repo.

adamraine avatar Jun 10 '22 17:06 adamraine