运行UI测试时遇到以下错误。我是Javascript的新手所以我一直都在关注示例代码而且我不确定我哪里出错了。有人可以解释为什么我会收到此错误以及适当的解决方案是什么?
错误:
[13:00:19] E/launcher - fn is not a function
[13:00:19] E/launcher - TypeError: fn is not a function
主页对象:
Homepage.prototype = Object.create({}, {
checkInBtn: {
get: function () {
return element(by.css('div.checkin.booking-date input'));
}
}, datePickerDay: {
value: function (day) {
return element(by.cssContainingText('.ui-datepicker-calendar a', day));
}
}, selectCheckInDate: {
value: function (day) {
return this.checkInBtn.click().then(this.datePickerDay(day).click());
}
},
});
module.exports = Homepage;
Cucumber-Protractor Stepfile
this.When(/^I enter the trip information and search$/, function (table) {
var page = new homepage();
var checkOutDay = new Date(data["DepartureDate"]).getDate();
page.selectCheckInDate(checkInDay);
expect(page.checkInBtn.getText()).to.eventually.have.string(checkInDay);
});
答案 0 :(得分:0)
问题在于selectedCheckInDate
Homepage.prototype = Object.create({}, {
checkInBtn: {
get: function() {
return element(by.css('div.checkin.booking-date input'));
}
},
datePickerDay: {
value: function(day) {
return element(by.cssContainingText('.ui-datepicker-calendar a', day));
}
},
selectCheckInDate: {
value: function(day) {
var self = this;
this.checkInBtn.click().then(function() {
self.datePickerDay(day).click();
});
}
}
});
module.exports = Homepage;