Reputation: 47
Hi i have written this code in login-page.js
i dont know why i am getting error
Failed: Cannot read property 'sendKeys' of undefined
I had called this page on login_spec.js
I am unable to continue this in protractor tests
Upvotes: 2
Views: 3110
Reputation: 31
Alternatively, you could do it like this:
//conf.js
module.exports = {
config: {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['epLogin.spec.js'],
capabilities: {
browserName: 'chrome'
}
},
params: {
login: {
email: 'default',
password: 'default'
}
}
}
//pageObject
this.login = function(email, password){
this.email.clear();
this.email.sendKeys(email);
this.password.clear();
this.password.sendKeys(password);
this.loginButton.click();
//basic login example
};
//spec.js
var loginpage = require ('/path'),
config = ('/conf.js'),
user;
beforeEach(function(){
var user = new loginpage();
});
describe('example', function(){
it('login', function(){
user.get(); //per picture above
user.login(config.params.login.email, config.params.login.password);
//assuming you've defined params & login function in ur PO
});
});
Upvotes: 0
Reputation: 473833
You should use this
instead of login_page
to reference the current page object:
this.login = function (username, password) {
this.userInput.sendKeys(username);
// ...
};
Upvotes: 2