Solvedlighthouse Question: How to test page behind authentication?

fdn
109

I found that authentication is cleared when requesting a page. It makes sense however when testing an app behind authentication it doesn't seem like there is a way to specify an authorization header or cookie to be used.

Reference issue: #592

Any tips on how I can test a page that is behind authentication?

UPDATE (LATEST METHOD): The best way to currently do this is to load your authenticated page in DevTools, uncheck the "Clear storage" checkbox, and run Lighthouse.

screen shot 2018-08-27 at 10 58 20 am

37 Answers

✔️Accepted Answer

Just a comment, if you're using basic authentication, you can run lighthouse this way:

lighthouse https://user:password@my.domain.com

Other Answers:

I can see room for a "setCookie" command being added to the driver, probably very similar to the url blocking PR

Oh I was talking about the DevTools panel in Chrome actually, but the CLI works too.

image

CLI

/path/to/chrome --remote-debugging-port=9222 # login to your app
lighthouse --port=9222 --disable-storage-reset https://url-to-your-app.com

Node

lighthouse('https://my-url.com', {port: 9222, disableStorageReset: true})
fdn
27

Sorry, I should have specified that this is from the CLI. I'm trying to automate the process as much as possible so manual authentication will be a problem. Assuming nothing works out of the box, I'll try hacking at the gather source files.

More Issues: