| import { element, by } from '../e2elib/node_modules/protractor/built'; | 
| import { QLogType } from '../e2elib/lib/src/main/qlogtype.enum'; | 
| import { QUtils } from '../e2elib/lib/src/main/qutils.class'; | 
| import { WebLogin } from '../e2elib/lib/src/pageobjects/weblogin.component'; | 
| import { WebLogout } from '../e2elib/lib/src/pageobjects/weblogout.component'; | 
| import { QConsole } from '../e2elib/lib/src/helper/qconsole'; | 
|   | 
| export class AppBase { | 
|   /** | 
|    * Performs application login action. | 
|    * | 
|    * @returns Promise object indicating the completion of login action | 
|    */ | 
|   public async login(username?: string, clearViewCache: boolean = true): Promise<void> { | 
|     // Login | 
|     // S&OP Added username argument for PCS to login as different user | 
|     const webLogin = new WebLogin(); | 
|     try { | 
|       await webLogin.login(undefined, username); | 
|   | 
|       // S&OP added IF statement (some test require viewAutoSave true thus can pass false to skip setting this to false) | 
|       if (clearViewCache) { | 
|         await QConsole.viewAutoSave(false); | 
|         await QConsole.clearViewCache(); | 
|       } | 
|     } catch (err) { | 
|       expect(err).toBeLogged(QLogType.ERROR); | 
|       return; | 
|     } | 
|   } | 
|   | 
|   /** | 
|    * Performs application logout action. | 
|    * | 
|    * @returns Promise object indicating the completion of logout action | 
|    */ | 
|   public async logout(): Promise<void> { | 
|     // Logout | 
|     const webLogout = new WebLogout(); | 
|     await webLogout.logout(); | 
|   } | 
|   | 
|   /** | 
|    * Checks for any unexpected toast messages. | 
|    * | 
|    * @returns Promise object indicating the completion of check | 
|    */ | 
|   public async checkToastMessage(): Promise<void> { | 
|     await QUtils.checkToastMessage(); | 
|   } | 
|   | 
|   /** | 
|    * Turn off auto view save and clear view cache. For turning the feature ON, pass boolean when calling App.login method. | 
|    */ | 
|   public async disableAutoViewSave(): Promise<void> { | 
|     await QConsole.viewAutoSave(false); | 
|     await QConsole.clearViewCache(); | 
|   } | 
|   | 
|   /** | 
|    * Get application title. | 
|    * | 
|    * @returns Application title string | 
|    */ | 
|   public async getTitle(): Promise<string> { | 
|     const title = element(by.css('section.experience')).element(by.css('.title')); | 
|     return title.getText(); | 
|   } | 
| } |