简体   繁体   中英

Protractor: TypeError: fn is not a function

I'm encountering the following error when I run my UI tests. I'm new to Javascript so I've been mostly following example code and I'm not sure where I've gone wrong. Could someone explain why I'm getting this error and what an appropriate fix would be?

Error:

[13:00:19] E/launcher - fn is not a function
[13:00:19] E/launcher - TypeError: fn is not a function

Homepage object:

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);
        });

The problem is with the 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM