vegan @ vegan:〜/ hb-x / gateway $ gulp量角器[14:44:36] 使用gulpfile~ / hb-x / gateway / gulpfile.js [14:44:36] 启动'量角器'...直接使用ChromeDriver ... [启动器] 运行WebDriver的1个实例 - 用户未登录,因此尝试登录x-用户未登录,因此尝试登录xy-用户未登录,因此尝试登录
/家庭/素食主义者/ HB-X /网关/ node_modules /硒的webdriver / LIB / goog /../的webdriver / promise.js:2965 return fn.constructor.name ==='GeneratorFunction'; ^ TypeError:无法读取未定义的属性'constructor' at Object.promise.ControlFlow.goog.defineClass.goog.defineClass.promise.isGenerator (/家/素食主义者/ HB-X /网关/ node_modules /硒的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;
这个类叫它
'use strict';
var LogoutPageObject = require('./logoutControllerPageObject');
describe(
'Logout module', function () {
var logoutPageObject = new LogoutPageObject();
beforeEach(
function(){
console.log('Logout Test starting');
logoutPageObject.isLoggedIn();
这是来自promise.js,其中错误是lin 2965
promise.isGenerator = function(fn) {
return fn.constructor.name === 'GeneratorFunction';
};
我也回复了一些东西但是相同的
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;
};
可能是因为这个
this.isLoggedIn = commonPageObject.isLoggedIn();
我能为此做些什么?
答案 0 :(得分:1)
我改为调用函数
this.isLoggedIn = function(){
commonPageObject.isLoggedIn();
};
它有效。在我试图像变量一样调用之前。