question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how an array of urls interacts with the puppeteerScript flag

See original GitHub issue

Hi!

I’ve been trying to set up a puppeteer-script to bypass authentication. However, I am having some trouble figuring out how the puppeteerScript flag interacts with the URL list I have. lighthouserc.json

      "puppeteerScript": "puppeteer-login-script.js",
      "url": [
        "http://127.0.0.1:8181/",
        "http://127.0.0.1:8181/about",
        "http://127.0.0.1:8181/contact",
        "http://127.0.0.1:8181/donate",
        "http://127.0.0.1:8181/get-started",
        "http://127.0.0.1:8181/community-library",
        "http://127.0.0.1:8181/privacy-policy",
        "http://127.0.0.1:8181/teach",
        "http://127.0.0.1:8181/terms",
        "http://127.0.0.1:8181/thanks"
      ]
    },

I can get it to work with one URL, but I think my config currently runs the Puppeteer script before each URL collection and keeps trying to log in even though I am already logged in. Is there a way I make it so that the lighthouserc config will only run the script on certain URLs. Or do I need to handle it in the puppeteer-login-script

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
patrickhulcecommented, Jul 1, 2020

A snippet in the docs near the description of puppeteerScript option would be great, or perhaps even a complete configuration example in the “Examples” section? A recipe feels like overkill here.

When using puppeteer, the browser is kept open across all URLs so if you’re keeping state in cookies then everything should be remembered between URLs. If you’re using anything other than cookies though, you might have trouble. There’s no real way to support sessionStorage because new tabs are created and other storage types are cleared by Lighthouse in between runs so you’ll need to use --collect.settings.disableStorageReset as well.

Basic flow with puppeteer script.

|- puppeteer launches browser
|- LHCI runs the puppeteerScript
|- LHCI runs Lighthouse on URL A, run 1
|- LHCI runs Lighthouse on URL A, run 2
|- LHCI runs Lighthouse on URL A, run n
|- LHCI runs the puppeteerScript
|- LHCI runs Lighthouse on URL B, run 1
|- LHCI runs Lighthouse on URL B, run 2
...
0reactions
patrickhulcecommented, Jul 2, 2020

it might be helpful to clarify that a general puppeteer script won’t work with the lighthouse config

This shouldn’t be the case. You can definitely use a custom config along with puppeteer. What gave you this impression?

I thought that a standard puppeteer script could just log into the website, and that the lighthouse config would just use that instance.

This is what happens 😃

I didn’t know that using the parameters and structure below was necessary.

Do you have suggestions on how to improve the documentation for this setting? AFAICT, it offers nearly that identical JSDoc of what the parameters and structure are so I’m not sure how to make it any clearer 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer documentation - DevDocs
Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol. The Puppeteer API is...
Read more >
Crawling multiple URLs in a loop using Puppeteer
I have an array of URLs to scrape data ...
Read more >
Web Performance Recipes With Puppeteer - Addy Osmani
This guide has recipes for automating Web Performance measurement with Puppeteer.
Read more >
How To Build a Concurrent Web Scraper with Puppeteer ...
In this tutorial, you will use Node.JS, Puppeteer, Docker, and Kubernetes to build a highly scalable scraper that can simultaneously extract ...
Read more >
Build a Link Previewer with Puppeteer & Serverless Functions
vue file, we're basically using a demoLinks array of links to render a list of LinkPreviewer components, which we pass to the targetURL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found