Piy*_*joo 2 javascript node.js protractor
这是我的config.js文件 -
//server config information
var serverConfig=require('./serverConfig.js').serverConfig;
var $browser= serverConfig.$browser;
//got the browser name
process.argv.forEach(function (val, index) {
  if(val==='-browser'){
    $browser=process.argv[index+1];
  }
});
// !!! update the server config
serverConfig.$browser=  $browser;
 //config
 //browser.driver.manage().timeouts().setScriptTimeout(TIME_OUT);
// The main suite of Protractor tests.
exports.config = {
  seleniumServerJar: '../../selenium/selenium-server-standalone-2.37.0.jar',
  chromeDriver: '../../selenium/chromedriver.exe',
  seleniumAddress: serverConfig.SELENIUMN_ADDRESS,
  // Spec patterns are relative to this directory.
     specs: [
'../e2e/Regression/CreateOperatorViewFromViewManagement.js' 
    ],
  capabilities: {
    'browserName': $browser
  },
  onPrepare:'../prepareStartup.js',
  //When the angular bootstrap not from the <html></html>
  rootElement: 'body>div',
  baseUrl: serverConfig.BASE_URL 
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
  }
};
Run Code Online (Sandbox Code Playgroud)
当我尝试使用此config.js文件执行测试时出现此错误 -
C:\TRUNK\tests\func\gui\protractor\config\protractorConfig.js:60
  jasmineNodeOpts: {
  ^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at ConfigParser.addFileConfig (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js:139:20)
    at Object.init (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\launcher.js:59:7)
    at Object.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\cli.js:118:23)
    at Module._compile (module.js:456:26)
Run Code Online (Sandbox Code Playgroud)
当我执行量角器--help我得到以下选项 -
Options:
  --help                                             Print Protractor help menu
  --version                                          Print Protractor version
  --browser, --capabilities.browserName              Browsername, e.g. chrome or firefox
  --seleniumAddress                                  A running seleium address to use
  --seleniumServerJar                                Location of the standalone selenium jar file
  --seleniumPort                                     Optional port for the selenium standalone ser
  --baseUrl                                          URL to prepend to all relative paths
  --rootElement                                      Element housing ng-app, if not html or body
  --specs                                            Comma-separated list of files to test
  --exclude                                          Comma-separated list of files to exclude
  --verbose, --jasmineNodeOpts.isVerbose             Print full spec names
  --stackTrace, --jasmineNodeOpts.includeStackTrace  Print stack trace on error
  --params                                           Param object to be passed to the tests
  --framework                                        Test framework to use. jasmine or mocha.
Run Code Online (Sandbox Code Playgroud)
请提出我在配置文件中犯的错误,或者我需要配置更多的东西.
你最后忘记了一个逗号baseUrl: serverConfig.BASE_URL;)
它应该是:
baseUrl: serverConfig.BASE_URL,
Run Code Online (Sandbox Code Playgroud)