import { CommonKeyword } from "./commonKeyword"; import { logger } from '../Logger/logger'; import { Wait } from './dewWait'; import { DewElement } from './element'; /** * Secondary Action class */ export class SecondaryAction { /** * To Select Secondary Option for the listing grid.This function will click on the first row in the listing table, * click on Secondary option and perform the action. * * ```js * SecondaryAction.clickSecondaryActions("Project_123","Export"); * ``` * * @param {string} entityName // Name of the Entity * @param {string} actionToPerform // Action to perform on the entityName */ static async clickSecondaryActions(entityName: string, actionToPerform: string) { try { await CommonKeyword.scrollPageToTop(); await DewElement.verifyIfISeeText(entityName); await CommonKeyword.clickElement(`.//dew-listing//button[@aria-label='Button Name']/span[contains(@class,'actions-menu')]`); await Wait.waitUntilVisibilityOfElement(`.//div[contains(@class,'actions-menu')]//a[contains(@class,'secondary')] | .//div[contains(@class,'actions-menu')]//span[contains(@class,'secondary')]`); await CommonKeyword.clickElement(`.//div[contains(@class,'actions-menu')]//a[contains(@class,'secondary')]//*[text()[normalize-space()='${actionToPerform}']] | .//div[contains(@class,'actions-menu')]//a[contains(@class,'secondary') and text()[normalize-space()='${actionToPerform}']] | .//div[contains(@class,'actions-menu')]//span[contains(@class,'secondary')]//*[text()[normalize-space()='${actionToPerform}']]`); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while performing secondary action`); throw error; } } /** * To Select Primary Option for the listing grid.This function will click on the first row in the listing table, * click on Primary option buton. * * ```js * SecondaryAction.clickPrimaryActions("Project_123","Submit"); * ``` * * @param {string} entityName // Name of the Entity * @param {string} actionToPerform // Action to perform on the entityName */ static async clickPrimaryActions(entityName: string, actionToPerform: string) { try { await CommonKeyword.scrollIntoView(`.//*[text()[normalize-space()='${entityName}']]`); await DewElement.verifyIfISeeText(entityName); await CommonKeyword.clickElement(`.//*[text()[normalize-space()='${actionToPerform}']]`); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while performing primary action`); throw error; } } }