/* 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'; const varDesc = `AutoDescription` + generateRandomNumber(); /** * Impersonation class */ export class DewImpersonation { /** * navigate to allow Impersonation */ static async navigateToAllowImpersonation() { try { // await Wait.waitForDefaultTimeout(5); await Wait.waitUntilVisibilityOfElement(`//dew-dropdown[contains(@class,'profile')]`); await DewElement.verifyIfISeeElement(`//dew-dropdown[contains(@class,'profile')]`); await CommonKeyword.clickElement(`//dew-dropdown[contains(@class,'profile')]`); 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(`//div[contains(@class,'pickerDiv')]/input[@aria-label='date']`); await DatePicker.selectInNextMonth(`//div[contains(@class,'pickerDiv')]/input[@aria-label='date']`); await TextField.enterTextUsingLocator(`//textarea[@formcontrolname='description']`, varDesc); await CommonKeyword.click(`//button[@aria-label='Save']`); } 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); }