量角器无法启动webdriver会话

时间:2017-10-27 14:41:49

标签: angularjs node.js selenium protractor

请帮忙!

你好

我无法进行量角器测试,认为chrome会弹出一个空白页面

在错误消息中显示无法启动webdriver

✗ protractor config.js --troubleshoot true
[16:32:54] D/launcher - Running with --troubleshoot
[16:32:54] D/launcher - Protractor version: 5.2.0
[16:32:54] D/launcher - Your base url for tests is http://localhost:9000
(node:977) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[16:32:54] I/launcher - Running 1 instances of WebDriver
[16:32:54] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[16:32:54] E/runner - Unable to start a WebDriver session.
(node:977) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): WebDriverError: Cannot define class using reflection
(node:977) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[16:32:54] E/launcher - Error: WebDriverError: Cannot define class using reflection
    at Object.checkLegacyResponse (/home/lzt/.nvm/versions/node/v8.1.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/home/lzt/.nvm/versions/node/v8.1.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/home/lzt/.nvm/versions/node/v8.1.1/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
[16:32:54] E/launcher - Process exited with error code 100

错误报告

  • 节点版本:8.1.1
  • 量角器版本:5.2.0
  • Angular Version:1
  • 浏览器:chrom
  • 操作系统和版本ubuntu
  • 您的量角器配置文件

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const protractor_1 = require("protractor");
exports.config = {
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    SELENIUM_PROMISE_MANAGER: false,
    baseUrl: 'http://localhost:9000',
    capabilities: {
        browserName: 'chrome'
    },
    jasmineNodeOpts: {
        defaultTimeoutInterval: 25000
    },
    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    specs: [
        '../../features/login/login.feature'
    ],
    onPrepare: () => {
        protractor_1.browser.ignoreSynchronization = true;
        protractor_1.browser.manage().window().setSize(1600, 1000);
    },
    cucumberOpts: {
        compiler: "ts:ts-node/register",
        strict: true,
        format: ['pretty'],
        require: [
            '../../features/**/*.ts'
            // '../../stepdefinitions/loginPage.ts',
            // '../../support/*.ts'
        ]
    }
};

  

3 个答案:

答案 0 :(得分:0)

您是否在测试运行前更新了webdriver-manager? 我们试着webdriver-manager update

您是否尝试在节点v6上运行该程序?

https://github.com/angular/protractor#compatibility

答案 1 :(得分:0)

  • 通过从代码中删除seleniumAddress: 'http://127.0.0.1:4444/wd/hub',来尝试投放。

  • 安装 LTS 版本的nodejs,而不是安装最新版本。

答案 2 :(得分:0)

您必须运行本地量角器安装。

npm install protractor --save-dev

将其添加到package.json:

"scripts": { "update-webdriver": "webdriver-manager update", "protractor": "protractor config.js", },

并运行:

npm run update-webdriver npm run protractor