我在我的页面对象中定义了一个函数,该函数在我的spec文件中调用时会填写表单中的字段。但是,当我运行我的测试规范时,没有任何反应。任何人都可以看看我的代码,并给我一些关于错误的见解?
spec.js
var aboutYou = require('../page_objects/aboutYou.js')
describe('Credit Application', function() {
beforeEach(function(done) {
browser.get('http://localhost:5000');
});
describe('before form submission', function() {
it('should fill out the name fields', function() {
// Nothing Happens
aboutYou.fillFields;
// This sendKeys to the email field
aboutYou.emailAddress.sendKeys("example@ramen.com");
});
});
});
aboutYou.js
var AboutYou = function() {
this.firstName = browser.findElement(by.css(".section-aboutyou:not(.joint) input[formControlName=firstName]"));
this.lastName = element(by.css(".section-aboutyou:not(.joint) input[formControlName=lastName]"));
this.dateOfBirth = element(by.css(".section-aboutyou:not(.joint) input[formControlName=dateOfBirth]"));
this.homePhone = element(by.css(".section-aboutyou:not(.joint) input[formControlName=homePhone]"));
this.emailAddress = element(by.css(".section-aboutyou:not(.joint) input[formControlName=emailAddress]"));
this.fillFields = function() {
firstName.sendKeys("Randy");
lastName.sendKeys("Dinh");
};
};
module.exports = new AboutYou();
答案 0 :(得分:1)
您应该像这样调用fillField:
aboutYou.fillFields();
答案 1 :(得分:-1)
aboutYou.fillFields();应该做我的朋友的伎俩。