【发布时间】:2017-04-01 21:47:09
【问题描述】:
我有 3 个文件,即 conf.js、actionwords.js、project_test.js。 Actionwords.js 和 project_test.js 是从 hiptest 工具生成的文件。所以我需要使用这个结构来自动化测试用例。当我通过 cmd 运行时,我得到了错误。
我跑了:
protractor conf.js
消息: 失败:无法读取未定义的属性“theApplicationURL”
堆栈: TypeError:无法读取未定义的属性“theApplicationURL”
// conf.js
exports.config = {
framework: 'jasmine2',
directConnect: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs:['path to/project_test.js'],
capabilities: { 'browserName': 'chrome' }
};
//actionwords.js
var Actionwords = {
theApplicationURL: function () {
browser.get('localhost');
browser.driver.manage().window().maximize();
browser.sleep(5000);
},
};
//project_test.js
describe('Test', function () {
beforeEach(function () {
this.actionwords = Object.create(Actionwords);
});
it('Login_Test (uid:fe6d6670-a864-4d0f-a867-3faf9f51ff8d)', function () {
// Given the application URL
this.actionwords.theApplicationURL();
});
});
谁能帮我解决这个问题?
【问题讨论】:
-
将你的actionwords变成一个函数而不是对象并导出它,然后在project_test.js中使用require()
标签: javascript jquery automation jasmine protractor