lighthouse-batch icon indicating copy to clipboard operation
lighthouse-batch copied to clipboard

How to disable the emulatedUserAgent?

Open ArielDing opened this issue 3 years ago • 4 comments

I use lighthouse-batch -s <url1,url2> --params "--chrome-flags="--screenEmulation.disable --screenEmulation.mobile=false --screenEmulation.width=1350 --screenEmulation.height=940 --no-emulatedUserAgent"" --html ./report.html but the device has always been emulation device.

image

ArielDing avatar Nov 24 '21 11:11 ArielDing

One workaround would be to create a configuration file for use with lighthouse. For example, a file called config.js could be created with (update for your requirements):

const config = {
  extends: "lighthouse:default",
  settings: {
    formFactor: "desktop",
    throttling: {
      rttMs: 40,
      throughputKbps: 10 * 1024,
      cpuSlowdownMultiplier: 1,
      requestLatencyMs: 0,
      downloadThroughputKbps: 0,
      uploadThroughputKbps: 0,
    },
    screenEmulation: {
      mobile: false,
      width: 1907,
      height: 1094,
      deviceScaleFactor: 1,
      disabled: false,
    },
    emulatedUserAgent:
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Safari/537.36 Chrome-Lighthouse",
  },
};

module.exports = config;

Then this would be called like this: lighthouse-batch -s <url1,url2> --params "--config-path=config.js" --html

More details on lighthouse configuration can be found here: https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md

calumy avatar Dec 02 '21 13:12 calumy

Thanks for your suggestion. I was sucessed with config file. But I have another question, how to run sites.txt for many tinmes with lighthouse-batch? for example, how to run "url" 5 times?

ArielDing avatar Jan 12 '22 07:01 ArielDing

You can create a file containing a list of URLs separated on new lines and then run a command like lighthouse-batch -f ./test_sites.txt to run a series of urls. To see more you can look at the all options section of the read me.

calumy avatar Jan 20 '22 22:01 calumy

You can create a file containing a list of URLs separated on new lines and then run a command like lighthouse-batch -f ./test_sites.txt to run a series of urls. To see more you can look at the all options section of the read me.

emmm...My sites.txt cotain 60 urls, but i need to run them 5 times to get the average score. Is there a way to solve it?

ArielDing avatar Feb 08 '22 07:02 ArielDing