1

我可以在 conf 文件中设置参数。但是当我运行并尝试在运行时覆盖它时它不起作用。它使用我在 conf 文件中提到的用户名登录。

我的配置文件-

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var log4js = require('log4js');
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  allScriptsTimeout: 10*60*1000,
  framework: 'jasmine2',

  onPrepare: function () 

    browser.manage().timeouts().implicitlyWait(11000);
    var width = 768;
    var height = 1366;
    browser.driver.manage().window().setSize(768, 1366);
    //browser.ignoreSynchronization = true

    jasmine.getEnv().addReporter(
      new Jasmine2HtmlReporter({
        savePath: __dirname+'/qualityreports/testresults/e2e',
        takeScreenshots: false,
        filePrefix: 'automationReport',
        consolidate: true,
        cleanDestination: false,
        consolidateAll: true

      })
    );
  },

  suites:{
    suiteone:['./test/e2e/login/**/*Spec.js',
      './test/e2e/main/**/mainSpec.js']
  },
  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      'args': []
    }
  },

  appenders: [
    {
      "type": "file",
      "filename": "./e2eTestLogs/logfile.log",
      "maxLogSize": 20480,
      "backups": 3,
      "category": "relative-logger"
    }
  ],

  resultJsonOutputFile:'./results.txt',

  params: {
    Login: {
      username: 'xyz',
      password: 'xyz'
    }
  },

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 40*60*1000
  }
};

我使用的命令:

gulp e2e-test --suite suiteone --params.Login.username=abc --params.Login.password=abc

任何人都可以在这里帮忙。我想了解在传递命令行参数时我在哪里做错了。

4

2 回答 2

0

试试这个

--params.Login.username "abc"

它在Protractor的文档中有所描述。

于 2017-01-28T19:47:48.697 回答
0

尝试在引用中传递值

--params.Login.username="abc"
于 2017-01-22T20:59:05.343 回答