BES-26 | Test for incorrect login

This commit is contained in:
Dawid Majsnerowski 2019-11-29 22:51:45 +01:00
parent 672caa2392
commit c15c1eb22f
3 changed files with 46 additions and 2 deletions

View File

@ -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.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.errorLoginMessage = 'Nieprawidłowy adres e-mail lub hasło. Spróbuj ponownie!';
}
}

View File

@ -4,12 +4,32 @@ const base = require('../base/base');
class Login {
constructor() {
this.loginForm = '.login-form-2';
this.emailField = '#id_username';
this.passwordField = '#id_password';
this.loginButton = '.btnSubmit';
this.warringMessage = '.text-warning';
}
isLoginFormDisplayed() {
base.waitForDisplayed(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;

View File

@ -5,12 +5,35 @@ const common = require('../../base/common');
const navigate = require('../../base/navigation');
const Login = require('../../components/login');
describe('Login page in BestNotes', () => {
const testName = 'test';
describe('Login page in BestNotes', () => {
it('should be displayed', () => {
const login = new Login();
addStep('Redirect to Login Page');
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;
})
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);
})
});