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
/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)
This is the section where the error occurs
'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;
this part calls it
'use strict';
var LogoutPageObject = require('./logoutControllerPageObject');
describe(
'Logout module', function () {
var logoutPageObject = new LogoutPageObject();
beforeEach(
function(){
console.log('Logout Test starting');
logoutPageObject.isLoggedIn();
this code snippet is from promise.js which causes the error on line 2965
promise.isGenerator = function(fn) {
return fn.constructor.name === 'GeneratorFunction';
};
I tried adding a return statement but the issue persists
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;
};
The problem may be related to this line of code
this.isLoggedIn = commonPageObject.isLoggedIn();
What steps can I take to resolve this?