import 'codeceptjs'; import { CommonKeyword } from "../components/commonKeyword"; import { logger } from "../Logger/logger"; import { lmt } from '../Helpers/readI18NProp'; import { DewElement } from './element'; import { TextField } from './textfield'; import { DewFileUpload } from './dewFileUpload'; import { ReadLocators } from "../readLocators"; const locators:any = ReadLocators.readJson(); /** * Profile related class */ export class ManageProfile { /** * Function is use to Navigate To Manage Profile page * * ```js * ManageProfile.navigateToManageProfile(); * ``` */ static async navigateToManageProfile() { try { await CommonKeyword.clickElement(locators.dewNavigateToAllowImpersonation); await CommonKeyword.clickElement(`//div[contains(@class,'dropdown-item') and text()[normalize-space()='${await lmt.getLabel(`Manage Profile`)}']]`); await DewElement.verifyIfISeeElement(locators.manageUserProfileXpath); // I.seeElement(locators.manageUserProfileXpath); await CommonKeyword.clickLabel(await lmt.getLabel(`User Details`)); } catch (error) { logger.info(`Issue while performing operation in DDCC: Error while navigating to Manage Profile`); throw error; } } /** * Function is use to upload Profile Picture in Manage Profile Page * * ```js * ManageProfile.uploadProfilePicture(); * ``` */ static async uploadProfilePicture() { try { await CommonKeyword.clickElement(locators.manageProfileUploadPictureXpath); await DewElement.verifyIfISeeText(await lmt.getLabel(`Upload Image`)); // I.see(await lmt.getLabel(`Upload_Image`)); await DewFileUpload.uploadFile(locators.manageProfileUploadImage, locators.manageProfileImageXpath); await CommonKeyword.clickElement(locators.setProfilePictureXpath); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while uploading profile picture`); throw error; } } /** * Function is use to verify whether Profile Picture in uploaded in Manage Profile page * * ```js * * ManageProfile.verifyUploadedProfilePicture(); * ``` */ static async verifyUploadedProfilePicture() { await DewElement.verifyIfISeeElement(locators.verifyUploadedProfilePictureXpath); // I.seeElement(locators.verifyUploadedProfilePictureXpath); } /** * Function is use to reset Profile Picture in Manage Profile page * * ```js * * ManageProfile.resetProfilePicture(); * ``` */ static async resetProfilePicture() { await CommonKeyword.clickElement(locators.resetProfilePictureXpath); await DewElement.verifyIfISeeElement(locators.manageResetProfilePictureXpath); } /** * Function is use to change password for the user * * ```js * * ManageProfile.changePassword(); * ``` */ static async changePassword() { try { this.navigateToManageProfile(); await CommonKeyword.clickElement(locators.changePasswordXpath); await TextField.enterTextUsingLocator(locators.currentPasswordXpath, `YoDeHaCoPoBiBaIoAiWiYeQe8&7`); await TextField.enterTextUsingLocator(locators.newPasswordXpath, `YoDeHaCoPoBiBaIoAiWiYeQe8&71`); await TextField.enterTextUsingLocator(locators.confirmPasswordXpath, `YoDeHaCoPoBiBaIoAiWiYeQe8&71`); await CommonKeyword.clickElement(locators.manageProfileSavePasswordXpath); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while changing password`); throw error; } } /** * Function is use to verify password is updated * * ```js * * ManageProfile.verifyIfPasswordUpdated(); * ``` */ static async verifyIfPasswordUpdated() { await DewElement.verifyIfISeeText(await lmt.getLabel(`Password Updated`)); // I.see(await lmt.getLabel(`Password_Updated`)); } /** * Function is use to change pin for user * * ```js * * ManageProfile.changePin(); * ``` */ static async changePin() { try { await CommonKeyword.clickElement(locators.changePinXpath); logger.info(`Qw` + generateRandomNumber()); const pin = `Qw` + generateRandomNumber(); await TextField.enterTextUsingLocator(locators.newMobilePinXpath, pin); await TextField.enterTextUsingLocator(locators.confirmMobilePinXpath, pin); await CommonKeyword.clickElement(locators.manageProfileSavePasswordXpath); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while changing pin`); throw error; } } /** * Function is use to verify if pin is updated * * ```js * * ManageProfile.verifyIfPinUpdated(); * ``` */ static async verifyIfPinUpdated() { await DewElement.verifyIfISeeText(await lmt.getLabel(`Pin Updated`)); // I.see(await lmt.getLabel(`Pin_Updated`)); } } /** * Generates random series of numbers * @return {number} */ function generateRandomNumber() { return Math.floor(Math.random() * 9000); }