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

How to pass cookie to lighthouse as part of sitespeed.io #120

Open
dpeddaswamy opened this issue Oct 6, 2023 · 6 comments
Open

How to pass cookie to lighthouse as part of sitespeed.io #120

dpeddaswamy opened this issue Oct 6, 2023 · 6 comments

Comments

@dpeddaswamy
Copy link

Hi Team,
I am using docker sitespeed latest Plus 1 docker image to include sitespeed tests and accessibility tests using Lighthouse plugin. Test urls are saved in .txt file and passing cookie for sitespeed.io on command. But for lighthouse i am unable to send cookie from command. I am using below command.

docker run --rm -v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:29.7.0-plus1 TestPlans/APPURLs.txt -n 2 --browsertime.video false --axe.enable --config TestPlans/PageSummaryConfig.json --cookie Jsession=${COOKIE} --plugins.add analysisstorer --plugins.add /lighthouse/index.js --lighthouse.config TestPlans/lhconfig.js ----plugins.remove /gpsi/lib/index.js --outputFolder ./sitespeed-result

Sitespeed results are proper pages. But Cookie is not passing to Lighthouse and page is redirecting to login screen and getting accessibility metrics for that page which is not expected. Also Lighthouse is testing with mobile option. How to do emulation with desktop and network emulation is based on system network.

Could you please help me.

@soulgalore
Copy link
Member

Hi @dpeddaswamy Lighthouse use there own Chrome version so when we run we first use Browsretime and the Chrome version in the Docker container, then when everything is finished we use the Chrome version bundled with Lighthouse and run the Lighthouse test. To pass on cookies for Lighthouse checkout the Lighthouse documentation at https://github.com/GoogleChrome/lighthouse

@JoshuvaGeorge03
Copy link

I am also facing these issue...

can we able to re-use authenticated chrome instance for lighthouse testing? rather than again doing authentication for another one plugin...

can we able to do that @soulgalore , please advice... it would be really helpful

@soulgalore
Copy link
Member

sitespeed.io and Lighthouse is using different Chrome versions. sitespeed.io rolls with the current stable version of Chrome (that most of your users use). Lighthouse uses whatever that installed with Puppeteer. We use different session, so the only way to do it for Lighthouse is to pass on a cookie.

@JoshuvaGeorge03
Copy link

Thanks for the reply...

I can able to pass the cookies to lighthouse config too, but due to a known issue from lighthouse, we can't able to use cookies to authenticate, as it can be overriden and my webapp won't load at all... Please refer below issue for your reference.

GoogleChrome/lighthouse#6207 (comment)

so, if we can able to use already presented chrome instance, then authentication related issue can be solved altogether, and also lighthouse provides a way to use chrome debug instance(https://github.com/GoogleChrome/lighthouse/blob/main/docs/authenticated-pages.md#option-4-open-a-debug-instance-of-chrome-and-manually-log-in) too....

otherwise, I have to maintain another one pupeteer script to do login for lighthouse, this make integration bit harder, as I have to maintin authentication for sitespeed.io and lighthouse in a separate manner.

sorry, if it is something misleading, I would be really happy to find good solution on this to avoid separate maintenance of authentication, Please advice @soulgalore

@JoshuvaGeorge03
Copy link

JoshuvaGeorge03 commented Oct 24, 2023

Also, using this plugin, we can no way of authenticate using puppeteer, As there is no option to support this, Please advice on this

https://github.com/GoogleChrome/lighthouse/blob/main/docs/authenticated-pages.md

@soulgalore
Copy link
Member

Thinking the best solution would be to add Lighthouse user journeys or whatever they are calling it? I haven't looked into how that work yet.

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

3 participants