量角器页面对象错误
Protractor page objects error
我正在为页面对象模式构建 angularjs 量角器端到端测试。我在将脚本转换为页面对象时遇到问题。
这是我的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
这可能是个愚蠢的问题。但是,我找不到错误,因为这是我的第一次测试。 :)
看起来像你 copy-paste 来自这里的代码
https://github.com/angular/protractor/blob/f9c8a37f7dbec1dccec2dde0bd6884ad7ae3f5c7/docs/tutorial.md
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
这里是 protractor
尝试获取资源并检查 - 它是否有标题。
这个函数return判断真假来做测试。在你的例子中,函数 return undefined
,它等于 false,测试失败,你得到错误信息。
我正在为页面对象模式构建 angularjs 量角器端到端测试。我在将脚本转换为页面对象时遇到问题。
这是我的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
这可能是个愚蠢的问题。但是,我找不到错误,因为这是我的第一次测试。 :)
看起来像你 copy-paste 来自这里的代码 https://github.com/angular/protractor/blob/f9c8a37f7dbec1dccec2dde0bd6884ad7ae3f5c7/docs/tutorial.md
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
这里是 protractor
尝试获取资源并检查 - 它是否有标题。
这个函数return判断真假来做测试。在你的例子中,函数 return undefined
,它等于 false,测试失败,你得到错误信息。