运行量角器时出错... node_modules / q / q.js:155

时间:2016-02-16 15:01:57

标签: selenium-webdriver protractor

运行量角器测试时,我遇到以下错误,使用最新的节点版本 - v5.4.1和npm版本 - 3.5.3。我只在构建服务器(Red Hat Enterprise Linux Server 7.1)上遇到此问题,但在本地计算机上却没有。

我在服务器上使用本地npm和节点安装,这是通过maven-front-end工具插件完成的。

> [plm@siplmapp01 INT static]$ node_modules/grunt-cli/bin/grunt e2e-test
> >> Local Npm module "grunt-contrib-qunit" not found. Is it installed?
> 
> Running "protractor_webdriver:modules" (protractor_webdriver) task
> Starting Selenium server
> Shutting down Selenium server: http://localhost:4444
> Shut down Selenium server: http://localhost:4444 (OKOK)
> Restarting Selenium server
> Restarted Selenium server: http://127.0.0.1:4444
> 
> Running "protractor:modules" (protractor) task
> [launcher] Process exited with error code 1
> 
> /data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/q/q.js:155
>                 throw e;
>                       ^
> SyntaxError: Unexpected token )
>     at goog.loadModuleFromSource_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1123:19)
>     at Object.goog.loadModule (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1085:46)
>     at /data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/webdriver/promise.js:1:6
>     at Object.Context.closure.goog.retrieveAndExecModule_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/_base.js:135:8)
>     at <anonymous>:1:6
>     at Context.closure.closure.vm.createContext.CLOSURE_IMPORT_SCRIPT (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/_base.js:104:12)
>     at Object.goog.importScript_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:879:9)
>     at Object.goog.importModule_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:900:14)
>     at Object.goog.writeScripts_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1323:16)
>     at Object.goog.require (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:663:14)
> >> /data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/q/q.js:155
> >>                 throw e;
> >>                       ^
> >> SyntaxError: Unexpected token )
> >>     at goog.loadModuleFromSource_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1123:19)
> >>     at Object.goog.loadModule (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1085:46)
> >>     at /data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/webdriver/promise.js:1:6
> >>     at Object.Context.closure.goog.retrieveAndExecModule_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/_base.js:135:8)
> >>     at <anonymous>:1:6
> >>     at Context.closure.closure.vm.createContext.CLOSURE_IMPORT_SCRIPT (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/_base.js:104:12)
> >>     at Object.goog.importScript_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:879:9)
> >>     at Object.goog.importModule_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:900:14)
> >>     at Object.goog.writeScripts_ (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:1323:16)
> >>     at Object.goog.require (/data/apps/bamboo/atlassian-bamboo-5.9.7/xml-data/build-dir/PA-PUT-JOB1/src/main/resources/static/node_modules/selenium-webdriver/lib/goog/base.js:663:14)
> Warning: Tests failed, protractor exited with code: 8 Use --force to continue.
> 
> Aborted due to warnings.

量角器配置

var AllureReporter = require('jasmine-allure-reporter');
//var HTMLReporter = require('protractor-jasmine2-screenshot-reporter');

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
//Specs to run individual tests.
    specs: ['../tests/unit/sandbox-spec.js'],
// To run tests as part of the suites.
    suites: {
        intro: ['../tests/unit/login-spec.js','../tests/unit/plm02TabChecks-spec.js','../tests/unit/sandbox-spec.js'],
        e2e: ['../tests/unit/checkBaseline-spec.js','../tests/unit/plm02-spec.js'],
        smoke: ['../tests/e2e/smoke-tests/baselineSchedule-spec.js','../tests/e2e/smoke-tests/validateBaseline-spec.js'],
        sandbox: ['../tests/e2e/smoke-tests/validateBaseline-spec.js']
    },

    capabilities: {
        'browserName': 'phantomjs',
        //For Server
        //'phantomjs.binary.path':'node_modules/phantomjs-prebuilt/bin/phantomjs'

        // For Local Use
        'phantomjs.binary.path':'C:/Users/taaupsa1/Downloads/phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin/phantomjs.exe'
    },

    framework:'jasmine2',
    onPrepare: function() {
        // implicit and page load timeouts
        browser.manage().timeouts().pageLoadTimeout(40000);
        browser.manage().timeouts().implicitlyWait(25000);
        browser.manage().window().setSize(1600, 1000);
// for non-angular page
    browser.ignoreSynchronization = true;

    //        jasmine.getEnv().addReporter(new HTMLReporter({
    //            dest: '../screenshots',
    //            filename: 'my-report.html'
    //        }));

    jasmine.getEnv().addReporter(new AllureReporter({
      allureReport: {
        resultsDir: 'allure-results'
      }
    }));
    }
};

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

这已经解决了,我在我的服务器上安装了一个全局节点,这是一个0.10.x版本,比3.0更好的Protractor版本与低于2.x.x的节点版本不兼容。将其升级到最新版本解决了问题