E/launcher - 无效的会话 ID。 运行ning 黄瓜量角器框架时出现错误。我该如何解决它和 运行 多个功能文件?

E/launcher - invalid session id. Getting the error when running cucumber protractor framework. How can i resolve it and run multiple feature files?

  1. 这里是量角器配置js文件
  2. 当 运行 多个规范文件
  3. 时出现错误
  4. 它给我的错误是无效的会话 ID
        const Reporter = require("../support/reporter");

        exports.config = {

           capabilities: {
              browserName: process.env.TEST_BROWSER_NAME || "chrome"
           },
           waitForAngularEnabled: true,
           useAllAngular2AppRoots: true,
           framework: "custom",
           frameworkPath: require.resolve("protractor-cucumber-framework"),
           specs: ["../features/*.feature"],

           onPrepare: function () {
             browser.ignoreSynchronization = true;
             browser.manage().window().maximize();
             require('babel-register');
           },

           cucumberOpts: {
              strict: true,
              format: 'json:./reports/json/cucumber_report.json',
              require: ["../stepDefinitions/*.js", "../support/*.js"],
              tags: "@CucumberScenario"
           },
           onComplete: function () {
              Reporter.createHTMLReport();
           }
        };

错误信息如下:

E/launcher - invalid session id
Build info: version: '3.141.59', revision: '******', time: '2018-11-14T08:25:53'
System info: host: '********', ip: '********', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231'
Driver info: driver.version: unknown


[11:40:32] E/launcher - WebDriverError: invalid session id
Build info: version: '3.141.59', revision: '*******', time: '2018-11-14T08:25:53'
System info: host: '*******', ip: '**********', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231'
Driver info: driver.version: unknown

我没有用过黄瓜,所以这个错误可能与我猜测的完全不同。你应该试试这个:

将以下内容添加到您的 package.json 脚本部分,然后 运行 npm run test 编译打字稿,然后修复更新 webdriver chrome 版本。如果您的代码在 javascript 中,请从预测试中删除 npm run tsc

 "scripts": {
    "debug": "node --inspect-brk ./node_modules/.bin/protractor protractor.conf.js",
    "pretest": "npm run tsc && npm run webdriver-update",
    "test": "./node_modules/protractor/bin/protractor protractor/compiled-js-files/protractor.conf.js",
    "e2e": "npm run tsc && ./node_modules/protractor/bin/protractor protractor/compiled-js-files/protractor.conf.js",
    "grid": "sh run-grid.sh && npm run tsc && npm run e2e",
    "tsc": "./node_modules/typescript/bin/tsc",
    "webdriver-update": "./node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0 --chrome --versions.chrome=78.0.3904.97",
    "lighthouse": "./node_modules/jest/bin/jest.js --verbose -t=lighthouse",
    "lighthouse-reports": "./node_modules/jest/bin/jest.js --verbose -t=lighthouse && node ./lighthouse/db.js"
  }

这将允许您下载 chrome 最后一次已知的正确配置(我知道)。您将需要继续维护它,以免使用过时的 chrome。出现此错误的原因是 webdriver-manager 更新采用了 chrome 版本的最新测试版,并且该版本不是用于自动化测试的。因此,当您 运行 您的测试时,不会创建会话。

也尝试在您的能力中添加以下内容:

capabilities: {
        'browserName': 'chrome',
        chromeOptions: {
            args: [ "--headless", "--disable-gpu", "--disable-dev-shm-usage", "--no-sandbox" , "--window-size=1440,960"]
        },
    }