Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 运行来自Puppeter的lighthouse报告时出错_Javascript_Puppeteer_Google Chrome Headless_Lighthouse - Fatal编程技术网

Javascript 运行来自Puppeter的lighthouse报告时出错

Javascript 运行来自Puppeter的lighthouse报告时出错,javascript,puppeteer,google-chrome-headless,lighthouse,Javascript,Puppeteer,Google Chrome Headless,Lighthouse,在自动化我的web应用程序的同时,我想运行lighthouse并为各种页面生成各种性能指标,例如一个启动前页面、一个登录后页面等。。。但我得到了以下错误 Error: connect ECONNREFUSED 127.0.0.1:9222 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) { errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall:

在自动化我的web应用程序的同时,我想运行lighthouse并为各种页面生成各种性能指标,例如一个启动前页面、一个登录后页面等。。。但我得到了以下错误

Error: connect ECONNREFUSED 127.0.0.1:9222
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9222,
  friendlyMessage: undefined
}
我的示例代码:

const puppeteer = require('puppeteer');
const select = require('puppeteer-select');
const devices = puppeteer.devices;
const lighthouse = require('lighthouse');
const reportGenerator = require('lighthouse/lighthouse-core/report/report-generator');
const inputFiles = require("./config/config");
const userNamePage = require('./mySitePages/userName.page');
const passwordPage = require('./mySitePages/password.page');
const chromeLauncher = require('chrome-launcher');
const config = require('./config/config');



(async () => {
    const launchOptions = {
      headless: false,
      executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
      args: ['--start-maximized', '--disable-web-security', '--disable-features=IsolateOrigins,site-per-process']
    };
    const browser = await puppeteer.launch(launchOptions);
    const url = `${config.application_url_1}`;
    const page = await browser.newPage();
    const options = {
        logLevel: 'info',
        disableDeviceEmulation: true,
        chromeFlags: ['--disable-mobile-emulation']
      };

    try {
        await page.goto(url);
        const {lhr}  = await lighthouse(page.url());
        console.log(`Lighthouse scores: ${Object.values(lhr.categories).map(c => c.score).join(', ')}`);
        await userNamePage.enterUserName(page, inputFiles.mySiteUserName)

    }
    catch (error) {
        console.error(error);
      }
      finally {
        await page.waitFor(10000);
        console.log("Closing the browser session")
        await browser.close();
      }
    })();   
原因是我在url中发送
page.url()
,因为我在不同的页面中会有不同的url,所以我会动态调用它们

你知道我错过了什么吗