BES-26 | Test for incorrect login
This commit is contained in:
parent
672caa2392
commit
c15c1eb22f
@ -3,6 +3,7 @@ class Common {
|
|||||||
this.loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';
|
this.loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';
|
||||||
this.ecceIpsum = 'Snare hope zarathustra pious society. Ascetic ocean snare chaos endless war ultimate insofar right god spirit. Right free pinnacle philosophy overcome self philosophy. Right passion value dead truth faithful deceptions. Marvelous hatred derive superiority deceptions justice overcome oneself zarathustra gains.';
|
this.ecceIpsum = 'Snare hope zarathustra pious society. Ascetic ocean snare chaos endless war ultimate insofar right god spirit. Right free pinnacle philosophy overcome self philosophy. Right passion value dead truth faithful deceptions. Marvelous hatred derive superiority deceptions justice overcome oneself zarathustra gains.';
|
||||||
this.bestNotesLink = 'http://bestnotes.pythonanywhere.com/bestnotes/';
|
this.bestNotesLink = 'http://bestnotes.pythonanywhere.com/bestnotes/';
|
||||||
|
this.errorLoginMessage = 'Nieprawidłowy adres e-mail lub hasło. Spróbuj ponownie!';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,32 @@ const base = require('../base/base');
|
|||||||
class Login {
|
class Login {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.loginForm = '.login-form-2';
|
this.loginForm = '.login-form-2';
|
||||||
|
this.emailField = '#id_username';
|
||||||
|
this.passwordField = '#id_password';
|
||||||
|
this.loginButton = '.btnSubmit';
|
||||||
|
this.warringMessage = '.text-warning';
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoginFormDisplayed() {
|
isLoginFormDisplayed() {
|
||||||
base.waitForDisplayed(this.loginForm);
|
base.waitForDisplayed(this.loginForm);
|
||||||
return base.isDisplayed(this.loginForm);
|
return base.isDisplayed(this.loginForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fillCredentials(selector, text) {
|
||||||
|
base.fillIn(selector, text, 'Fill credentials');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
clickLoginButton() {
|
||||||
|
base.click(this.loginButton, 'Login button');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
getErrorMessage() {
|
||||||
|
base.waitForDisplayed(this.warringMessage);
|
||||||
|
return base.getAttribute(this.warringMessage, 'textContent', 'Error message text');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Login;
|
module.exports = Login;
|
@ -5,12 +5,35 @@ const common = require('../../base/common');
|
|||||||
const navigate = require('../../base/navigation');
|
const navigate = require('../../base/navigation');
|
||||||
const Login = require('../../components/login');
|
const Login = require('../../components/login');
|
||||||
|
|
||||||
describe('Login page in BestNotes', () => {
|
|
||||||
|
|
||||||
|
const testName = 'test';
|
||||||
|
describe('Login page in BestNotes', () => {
|
||||||
it('should be displayed', () => {
|
it('should be displayed', () => {
|
||||||
const login = new Login();
|
const login = new Login();
|
||||||
|
|
||||||
|
addStep('Redirect to Login Page');
|
||||||
navigate.toLoginPage();
|
navigate.toLoginPage();
|
||||||
|
|
||||||
|
addStep('Check if Login Form is displayed and URL ');
|
||||||
|
expect(browser.getUrl(), 'Post details URL should include post ID').to.equal(common.bestNotesLink + 'accounts/login/');
|
||||||
expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true;
|
expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('shouldnt logged user with incorrect credentials', () => {
|
||||||
|
const login = new Login();
|
||||||
|
|
||||||
|
addStep('Redirect to Login Page');
|
||||||
|
navigate.toLoginPage();
|
||||||
|
|
||||||
|
addStep('Check if Login Form is displayed');
|
||||||
|
expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true;
|
||||||
|
|
||||||
|
addStep('Fill credentials and try to login');
|
||||||
|
login.fillCredentials(login.emailField, testName);
|
||||||
|
login.fillCredentials(login.passwordField, testName);
|
||||||
|
login.clickLoginButton();
|
||||||
|
|
||||||
|
addStep('Check if the error message is displayed');
|
||||||
|
expect(login.getErrorMessage(), 'Message about wrong credentials should be displayed').to.equal(common.errorLoginMessage);
|
||||||
|
})
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user