Updated login page tests to check for username and password fields

This commit is contained in:
Tom Bloor 2017-08-25 12:17:15 +01:00
parent 2d0633a393
commit 9c5c309ef0
2 changed files with 21 additions and 2 deletions

View file

@ -5,10 +5,20 @@ describe('Login Page', () => {
beforeEach(() => { beforeEach(() => {
page = new LoginPageObject(); page = new LoginPageObject();
page.navigateTo();
}); });
it('should have a header saying login', () => { it('should have a header saying login', () => {
page.navigateTo();
expect(page.getLoginHeaderText()).toEqual('Login'); expect(page.getLoginHeaderText()).toEqual('Login');
}); });
it('should have a username box of type text', () => {
expect(page.isUsernameFieldPresent()).toBeTruthy();
expect(page.getUsernameFieldType()).toBe('text');
});
it('should have a password box of type password', () => {
expect(page.isPasswordFieldPresent()).toBeTruthy();
expect(page.getPasswordFieldType()).toBe('password');
});
}); });

View file

@ -2,10 +2,19 @@ import { browser, element, by } from 'protractor';
export class LoginPageObject { export class LoginPageObject {
navigateTo() { navigateTo() {
return browser.get('/'); return browser.get('/login');
} }
getLoginHeaderText() { getLoginHeaderText() {
return element(by.css('app-root h1')).getText(); return element(by.css('app-root h1')).getText();
} }
getUsernameField() { return element(by.id('username')); }
getPasswordField() { return element(by.id('password')); }
isUsernameFieldPresent() { return this.getUsernameField().isPresent(); }
isPasswordFieldPresent() { return this.getPasswordField().isPresent(); }
getUsernameFieldType() { return this.getUsernameField().getAttribute('type'); }
getPasswordFieldType() { return this.getPasswordField().getAttribute('type'); }
} }