|
| 1 | +/* global $ */ |
| 2 | +'use strict'; |
| 3 | + |
| 4 | +// page object |
| 5 | +var HomePage = function () { |
| 6 | + var self = this; |
| 7 | + |
| 8 | + self.url = ''; |
| 9 | + self.ele = _getAllElements(); |
| 10 | + self.load = load; |
| 11 | + |
| 12 | + //////// |
| 13 | + |
| 14 | + function _getAllElements () { |
| 15 | + var header = browser._.getHeader(); |
| 16 | + return { |
| 17 | + 'headerTitle': header.title, |
| 18 | + 'headerLoginBtn': header.loginBtn, |
| 19 | + 'mainTitle': $('.card > .title'), |
| 20 | + 'subTitle': $('.card > .subtitle'), |
| 21 | + 'getStartedBtn': $('.card > a') |
| 22 | + }; |
| 23 | + } |
| 24 | + |
| 25 | + function load () { |
| 26 | + browser._.gotoUrl(self.url); |
| 27 | + } |
| 28 | +}; |
| 29 | + |
| 30 | +module.exports = HomePage; |
| 31 | + |
| 32 | +// test scenarios |
| 33 | +describe('Home Page:', function () { |
| 34 | + var page; |
| 35 | + beforeEach(function () { |
| 36 | + page = new HomePage(); |
| 37 | + page.load(); |
| 38 | + }); |
| 39 | + |
| 40 | + afterEach(function () { |
| 41 | + browser._.takeScreenshotIfFail(); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should display correct header', function () { |
| 45 | + expect(page.ele.headerTitle.getText()).toEqual('Aio Angular App'); |
| 46 | + expect(page.ele.headerLoginBtn.isDisplayed()).toBe(true); |
| 47 | + }); |
| 48 | + |
| 49 | + it('should display correct tilte and sub title', function () { |
| 50 | + expect(page.ele.mainTitle.getText()).toEqual('Aio Angular App'); |
| 51 | + expect(page.ele.subTitle.getText()).toEqual( |
| 52 | + 'Awesome web app built on AngularJS & Material Design.'); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should go to login page if click get started', function () { |
| 56 | + page.ele.getStartedBtn.click(); |
| 57 | + expect(browser.getCurrentUrl()).toMatch(/login/); |
| 58 | + }); |
| 59 | + |
| 60 | +}); |
0 commit comments