量角器 3.0.0 和黄瓜自动化测试
protractor 3.0.0 and cucumber automated testing
我目前正在使用量角器、黄瓜和 chai/chai-as-promised 进行自动化测试。我当前的代码使用量角器 1.8.0,我想将其更新到最新版本。问题是最新版本的量角器不支持黄瓜。
要使用 cucumber 作为框架,量角器 (http://angular.github.io/protractor/#/frameworks) points you to using protractor-cucumber-framework (https://github.com/mattfritz/protractor-cucumber-framework)。我已经尝试将它与我当前的代码和一些较小的示例项目集成,但没有成功让它们工作。我得到的主要错误是:
Error: Step timed out after 5000 milliseconds at Timer.listOnTimeout
(timers.js:92:15)
我已经尝试按照 cucumber 的建议全局更改默认超时时间:// features/support/env.js
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
但我的设置似乎遗漏了一些东西。
那么,有人知道可以向我展示新 protractor/cucumber 框架的正确设置的好示例吗?如果没有,有谁知道显示如何全局更改默认超时的示例?
你应该添加
this.setDefaultTimeout(60000);
到您的 step_def
文件之一。例如:
module.exports = function () {
this.setDefaultTimeout(60000);
this.After(function (callback) { ... }
}
或者你应该添加 //features/support/env.js 到
cucumberOpts:{require: ['//features/support/env.js']}
与您的 stepDefinition 文件排列
感谢@Ivan,
cucumber-protractor-framework
和 typescript
:
在protractor.conf.js
cucumberOpts: {
compiler: "ts:ts-node/register",
require: [
'./src/env.ts', //<- added
'./src/**/*.steps.ts'
]
},
在src/env.ts:
import {setDefaultTimeout} from 'cucumber';
setDefaultTimeout(9001);
我目前正在使用量角器、黄瓜和 chai/chai-as-promised 进行自动化测试。我当前的代码使用量角器 1.8.0,我想将其更新到最新版本。问题是最新版本的量角器不支持黄瓜。
要使用 cucumber 作为框架,量角器 (http://angular.github.io/protractor/#/frameworks) points you to using protractor-cucumber-framework (https://github.com/mattfritz/protractor-cucumber-framework)。我已经尝试将它与我当前的代码和一些较小的示例项目集成,但没有成功让它们工作。我得到的主要错误是:
Error: Step timed out after 5000 milliseconds at Timer.listOnTimeout (timers.js:92:15)
我已经尝试按照 cucumber 的建议全局更改默认超时时间:// features/support/env.js
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
但我的设置似乎遗漏了一些东西。
那么,有人知道可以向我展示新 protractor/cucumber 框架的正确设置的好示例吗?如果没有,有谁知道显示如何全局更改默认超时的示例?
你应该添加
this.setDefaultTimeout(60000);
到您的 step_def
文件之一。例如:
module.exports = function () {
this.setDefaultTimeout(60000);
this.After(function (callback) { ... }
}
或者你应该添加 //features/support/env.js 到
cucumberOpts:{require: ['//features/support/env.js']}
与您的 stepDefinition 文件排列
感谢@Ivan,
cucumber-protractor-framework
和 typescript
:
在protractor.conf.js
cucumberOpts: {
compiler: "ts:ts-node/register",
require: [
'./src/env.ts', //<- added
'./src/**/*.steps.ts'
]
},
在src/env.ts:
import {setDefaultTimeout} from 'cucumber';
setDefaultTimeout(9001);