没有黄瓜量角器运行的结果

时间:2017-07-16 12:40:22

标签: protractor cucumber cucumberjs gulp-protractor

我正在使用量角器和黄瓜, 首先,没有黄瓜我成功运行测试,但很快我通过npm添加了黄瓜支持,我得到了未定义测试的结果,见下文:

1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
[15:04:58] I/launcher - 0 instance(s) of WebDriver still running
[15:04:58] I/launcher - chrome #01 passed
Process finished with exit code 0

表示chromeDriver启动并在几秒钟后关闭, 我在两个项目上尝试过,一个是在git上: https://github.com/eis95/CucumberProtractorExample

所以你可以看到我如何定义配置以及packages.js文件, 包文件:

{
  "name": "uiautomation-v2.0",
  "version": "0.0.0",
  "description": "UIAutomationV2.0",
  "main": "app.js",
  "author": {
    "name": "Eyal.Cohen"
  },
  "devDependencies": {
    "cucumber": "^2.3.1",
    "protractor-cucumber-framework": "^3.1.2"
  },
  "dependencies": {
    "@types/jasmine": "^2.5.53",
    "protractor": "latest"
  }
}


And the conf.js file:

    
        exports.config = {
    
          specs: ['features/**/*.feature'],
          //seleniumServerJar:'./node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar',
          //chromeDriver: './node_modules/protractor/selenium/chromedriver_2.21',
          seleniumAddress: 'http://localhost:4444/wd/hub',
    
          capabilities: {
            'browserName': 'chrome'
          },
    
          framework: 'custom',
          frameworkPath: require.resolve('protractor-cucumber-framework'),
    
          cucumberOpts: {
            tags: [],
            require: ['features/step_definitions/newGameSteps.js'], //'features/specSetup.js','features/**/step_definitions/**/*Steps.js'
            format: 'pretty'
          }
        };

规格:

    
        exports.config = {
    
          specs: ['features/**/*.feature'],
          //seleniumServerJar:'./node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar',
          //chromeDriver: './node_modules/protractor/selenium/chromedriver_2.21',
          seleniumAddress: 'http://localhost:4444/wd/hub',
    
          capabilities: {
            'browserName': 'chrome'
          },
    
          framework: 'custom',
          frameworkPath: require.resolve('protractor-cucumber-framework'),
    
          cucumberOpts: {
            tags: [],
            require: ['features/step_definitions/newGameSteps.js'], //'features/specSetup.js','features/**/step_definitions/**/*Steps.js'
            format: 'pretty'
          }
        };

});

感谢您的帮助 感谢

1 个答案:

答案 0 :(得分:0)

根据您提供的信息,出现了问题:

  • 您的包裹说您使用的是CucumberJS ^ 0.10.3
  • 您的步骤实施表明您使用的是CucumberJS 2.x

所以请在提供的信息中修复它;-)。

话虽如此,您描述/传递承诺的问题可能与您需要在返回callbackpromises之间选择的事实有关,请参阅下面的代码示例。< / p>

在步骤之间传递值永远不明智,您应该将值保持在相同的范围内。

// With callbacks
Then(/^Submit Button is disabled$/, function(done) {
  var searchButton = element(by.buttonText('Search'));
  return expect(searchButton.isEnabled()).to.eventually.equal(false).and.notify(done);
});

// With Promises
Then(/^Submit Button is disabled$/, function() {
  var searchButton = element(by.buttonText('Search'));
  return expect(searchButton.isEnabled()).to.eventually.equal(false);
});