Skip to content

Commit

Permalink
Edit login page test to use page objects
Browse files Browse the repository at this point in the history
  • Loading branch information
gin committed Jun 26, 2020
1 parent 922a866 commit 0770b0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions test/page-objects/login.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
username: '#username',
password: '#password',
btnSubmit: 'form button[type="submit"]',
banner: '#flash',
}
19 changes: 10 additions & 9 deletions test/specs/login.spec.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
const login = require('../page-objects/login.page.js');

describe('the-internet.herokuapp.com login form', () => {
it('should deny access with wrong creds', () => {
browser.url('http://the-internet.herokuapp.com/login');
$('#username').setValue('test Wrong Name');
$('#password').setValue('test Wrong Password');
$('form button[type="submit"]').click();
$(login.username).setValue('test Wrong Name');
$(login.password).setValue('test Wrong Password');
$(login.btnSubmit).click();

expect($('#flash')).toHaveTextContaining('Your username is invalid!');
expect($(login.banner)).toHaveTextContaining('Your username is invalid!');

});
it('should accept access with correct creds', () => {
browser.url('http://the-internet.herokuapp.com/login');
$('#username').setValue('tomsmith');
$('#password').setValue('SuperSecretPassword!');
$('form button[type="submit"]').click();
$(login.username).setValue('tomsmith');
$(login.password).setValue('SuperSecretPassword!');
$(login.btnSubmit).click();

expect($('#flash')).toHaveTextContaining('You logged into a secure area!');
expect($(login.banner)).toHaveTextContaining('You logged into a secure area!');
});
});

0 comments on commit 0770b0c

Please sign in to comment.