【发布时间】:2016-11-02 06:58:02
【问题描述】:
我正在为页面对象模式构建我的 angularjs 量角器 e2e 测试。我在将脚本转换为页面对象时遇到了麻烦。
这是我的conf.js
// conf.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['employee.js']
}
这是我的employee.js
// spec.js
var EmpPageObject = require('./EmpPageObject.js');
describe('Protractor Demo App', function() {
it('should have a title', function() {
var empPageObject = new EmpPageObject();
empPageObject.get();
empPageObject.setName('mee');
empPageObject.setPassword('123');
});
});
这是我的EmpPageObject.js
var EmpPageObject = function() {
var nameInput = element(by.model('login.user_name'));
var passwordInput = element(by.model('login.password'));
var addButton = element(by.css('.btn'));
this.get = function() {
browser.get('http://');
};
this.setName = function(name) {
nameInput.sendKeys(name);
};
this.setPassword = function(password) {
passwordInput.sendKeys(password);
};
addButton.click();
};
但是,我的脚本未能给出以下错误。
Failures:
1) Protractor Demo App should have a title
Message:
Failed: EmpPageObject is not defined
这可能是一个愚蠢的问题。但是,我找不到错误,因为这是我的第一次测试。 :)
【问题讨论】:
标签: javascript angularjs jasmine pageobjects