From 9c5c309ef06cf294681e22edad077d1ebad87e3c Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Fri, 25 Aug 2017 12:17:15 +0100 Subject: [PATCH] Updated login page tests to check for username and password fields --- e2e/login.e2e-spec.ts | 12 +++++++++++- e2e/login.po.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/e2e/login.e2e-spec.ts b/e2e/login.e2e-spec.ts index da43980..7fc72be 100644 --- a/e2e/login.e2e-spec.ts +++ b/e2e/login.e2e-spec.ts @@ -5,10 +5,20 @@ describe('Login Page', () => { beforeEach(() => { page = new LoginPageObject(); + page.navigateTo(); }); it('should have a header saying login', () => { - page.navigateTo(); 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'); + }); }); diff --git a/e2e/login.po.ts b/e2e/login.po.ts index b4ddb0c..3df3a18 100644 --- a/e2e/login.po.ts +++ b/e2e/login.po.ts @@ -2,10 +2,19 @@ import { browser, element, by } from 'protractor'; export class LoginPageObject { navigateTo() { - return browser.get('/'); + return browser.get('/login'); } getLoginHeaderText() { 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'); } }