title: TypeError: Cannot read property 'constructor' of undefined
body: <blockquote>
    <p>vegan@vegan:~/hb-x/gateway$ gulp protractor [14:44:36]
    Using gulpfile ~/hb-x/gateway/gulpfile.js [14:44:36]
    Starting 'protractor'... Using ChromeDriver directly... [launcher]
    Running 1 instances of WebDriver Started
    - User not logged in, so trying to log in x- User not logged in, so trying to log in xy- User not logged in, so trying to log in</p>
    
    <p>/home/vegan/hb-x/gateway/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2965
    return fn.constructor.name === 'GeneratorFunction';
               ^ TypeError: Cannot read property 'constructor' of undefined
        at 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)</p>
  </blockquote>
  
  <p>This is my class where error is</p>
  
  <pre><code>'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;
  </code></pre>
  
  <p>this class calls it</p>
  
  <pre><code>'use strict';
  
  
  var LogoutPageObject = require('./logoutControllerPageObject');
  
  describe(
      'Logout module', function () {
  
          var logoutPageObject = new LogoutPageObject();
  
          beforeEach(
              function(){
                  console.log('Logout Test starting');
                  logoutPageObject.isLoggedIn();
  </code></pre>
  
  <p>this is from promise.js where the error is lin 2965</p>
  
  <pre><code>promise.isGenerator = function(fn) {
    return fn.constructor.name === 'GeneratorFunction';
  };
  </code></pre>
  
  <p>I also made return something but sitll same</p>
  
  <pre><code>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;
      };
  </code></pre>
  
  <p>it is probably because of this</p>
  
  <pre><code>this.isLoggedIn = commonPageObject.isLoggedIn();
  </code></pre>
  
  <p>what can i do for this?</p>