/* eslint-disable linebreak-style */ /* eslint-disable max-len */ /* eslint-disable no-irregular-whitespace */ import 'codeceptjs'; // const DatePicker = require("./datePicker"); import { DewRadioButton } from "./dewRadioButton"; import { DatePicker } from "./datePicker"; import { lmt } from '../Helpers/readI18NProp'; import { logger } from '../Logger/logger'; import { CommonKeyword } from './commonKeyword'; import { Wait } from './dewWait'; import { DewElement } from './element'; import { TextField } from './textfield'; import { ReadLocators } from "../readLocators"; const locators:any = ReadLocators.readJson(); const varDesc = `AutoDescription` + generateRandomNumber(); /** * Impersonation class */ export class DewImpersonation { /** * navigate to allow Impersonation */ static async navigateToAllowImpersonation() { try { // await Wait.waitForDefaultTimeout(5); await Wait.waitUntilVisibilityOfElement(locators.dewNavigateToAllowImpersonation); await DewElement.verifyIfISeeElement(locators.dewNavigateToAllowImpersonation); await CommonKeyword.clickElement(locators.dewNavigateToAllowImpersonation); await Wait.waitUntilVisibilityOfElement(`//div[contains(@class,'dropdown-item') and text()[normalize-space()='${await lmt.getLabel(`AllowImpersonation`)}']]`); await CommonKeyword.clickElement(`//div[contains(@class,'dropdown-item') and text()[normalize-space()='${await lmt.getLabel(`AllowImpersonation`)}']]`); /* await Wait.waitUntilVisibilityOfElement(`//h1[@title='${await lmt.getLabel(`Manage_you_Impersonation_Authorizations`)}']`, 50); await DewElement.verifyIfISeeElement(`//h1[@title='${await lmt.getLabel(`Manage_you_Impersonation_Authorizations`)}']`); */ } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while navigating to allow impersonation page`); throw error; } } /** * Impersonation function * @param {*} radioBtnLabel */ static async authorizeImpersonation(radioBtnLabel: string) { try { await this.navigateToAllowImpersonation(); /* await CommonKeyword.clickElement(`//a[contains(@class,'nav-link')]/*[text()[normalize-space()='${await lmt.getLabel(`AllowImpersonation`)}']]`); await DewElement.verifyIfISeeElement(`//a[contains(@class,'nav-link active')]/*[text()[normalize-space()='${await lmt.getLabel(`AllowImpersonation`)}']]`); */ await DewRadioButton.selectRadioButton(radioBtnLabel); // await Wait.waitForDefaultTimeout(2); await Wait.waitUntilVisibilityOfElement(locators.dewAuthorizeImpersonationDate); await DatePicker.selectInNextMonth(locators.dewAuthorizeImpersonationDate); await TextField.enterTextUsingLocator(locators.dewRadioButtonXpath, varDesc); await CommonKeyword.click(locators.dewSaveButtonXpath); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while authorizing impersonation `); throw error; } } } /** * To generate random number * @return {String} */ function generateRandomNumber() { return Math.floor(Math.random() * 9000); }