类型错误:无法读取未定义的属性“构造函数”

mar*_*ark 5 javascript selenium angularjs protractor

vegan@vegan:~/hb-x/gateway$ gulp量角器 [14:44:36] 使用 gulpfile ~/hb-x/gateway/gulpfile.js [14:44:36] 启动“量角器”...使用 ChromeDriver直接... [启动器] 运行 1 个 WebDriver 实例已启动 - 用户未登录,因此尝试登录 x- 用户未登录,因此尝试登录 xy- 用户未登录,因此尝试登录

/home/vegan/hb-x/gateway/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2965 返回 fn.constructor.name === 'GeneratorFunction'; ^ TypeError:无法读取 Object.promise.ControlFlow.goog.defineClass.goog.defineClass.promise.isGenerator 处未定义的属性“构造函数”(/home/vegan/hb-x/gateway/node_modules/selenium-webdriver/lib/goog /../webdriver/promise.js:2965:12)

这是我的课程,错误所在

'use strict';

var CommonPageObject = function() {

    this.baseUrl = "http://localhost:8080";

    this.product = element.all(by.css('[data-tab-item="product"]')).first();



    this.loginTextLocator = element(by.css('button.layout-align-xs-start-start'));
    this.loginPageHeader = element(by.css('header'));

    this.loginUsername = element(by.model('vm.model.username'));
    this.loginPassword = element(by.model('vm.model.password'));
    this.loginButton = element(by.css('[aria-label="login.button"]'));

    this.isLoggedIn = function () {
        this.get();

        var self = this;

        this.loginTextLocator.isPresent().then(function(isElementDisplayed){
            if(isElementDisplayed){
                console.log('- User not logged in, so trying to log in');

                self.ctaLogin('cta', 'M0ha44bOw-36SMm');
            }
            else{
                console.log('- User already logged in');
            }
        })
    };

    this.get = function() {
        browser.get(this.baseUrl);
    };

    this.ctaLogin = function(name,password) {

        this.get();//necessary?
        browser.driver.wait(protractor.until
            .loginPageHeader);

        this.setName(name);
        this.setPassword(password);

        this.loginButton.click();
    };

    this.setName = function(name) {browser.sleep(5000);console.log('x- User not logged in, so trying to log in');
        this.loginUsername.clear().sendKeys(name);

    };

    this.setPassword = function(password) {browser.sleep(5000);console.log('xy- User not logged in, so trying to log in');
        this.loginPassword.clear().sendKeys(password);

    };

};

module.exports = CommonPageObject;
Run Code Online (Sandbox Code Playgroud)

这个类称之为

'use strict';


var LogoutPageObject = require('./logoutControllerPageObject');

describe(
    'Logout module', function () {

        var logoutPageObject = new LogoutPageObject();

        beforeEach(
            function(){
                console.log('Logout Test starting');
                logoutPageObject.isLoggedIn();
Run Code Online (Sandbox Code Playgroud)

这是来自promise.js,错误是lin 2965

promise.isGenerator = function(fn) {
  return fn.constructor.name === 'GeneratorFunction';
};
Run Code Online (Sandbox Code Playgroud)

我也退货了一些东西,但还是一样

this.isLoggedIn = function () {
        this.get();

        var self = this;

        this.loginTextLocator.isPresent().then(function(isElementDisplayed){
            if(isElementDisplayed){
                console.log('- User not logged in, so trying to log in');

                self.ctaLogin('cta', 'M0ha44bOw-36SMm');
            }
            else{
                console.log('- User already logged in');
            }
        });
        return null;
    };
Run Code Online (Sandbox Code Playgroud)

大概是因为这个

this.isLoggedIn = commonPageObject.isLoggedIn();
Run Code Online (Sandbox Code Playgroud)

我能为此做什么?

mar*_*ark 4

我改成这个调用者函数

this.isLoggedIn = function(){
            commonPageObject.isLoggedIn();
       };
Run Code Online (Sandbox Code Playgroud)

它起作用了。在我尝试像变量一样调用之前。