import { logger } from '../Logger/logger'; import { CommonKeyword } from './commonKeyword'; import { TextField } from './textfield'; /** * Text Area class */ export class TextArea { /** * To enter text in TextArea filed using the Field Name * * ```js * * TextArea.enterText("Project Name","Project_123"); * ``` * * @param {String} fieldLbl //Field Name of TextArea * @param {String} valueToEnter // Value you want to enter into the text area * */ static async enterText(fieldLbl: string, valueToEnter: string) { try { const locator: string = `.//*[label[div[contains(.,'${fieldLbl}')]]]/following-sibling::*//textarea | .//*[label[div[contains(.,'${fieldLbl}')]]]/textarea | .//*[label[span[contains(.,'${fieldLbl}')]]]/textarea | .//*[label[div[contains(.,'${fieldLbl}')]]]/following-sibling::textarea`; await CommonKeyword.scrollIntoView(locator); await TextField.enterTextUsingLocator(locator, valueToEnter); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while entering text`); throw error; } } /** * To enter text in text Area using the placeholder attribute * * ``js * TextArea.enterTextUsingPlaceHolder("Enter Project Name","Project_123"); * ``` * * @param {String} placeholder // Text area placeholder * @param {String} valueToEnter //Value to enter into the textarea * */ static async enterTextWithPlaceHolder(placeholder: string, valueToEnter: string) { await TextField.enterTextUsingLocator(`.//textarea[@placeholder='${placeholder}']`, valueToEnter); } /** * To enter text in text area by passing locator * * ``js * TextArea.enterTextUsingLocator("//input[@id='emailID']","Project_123"); * ``` * * @param {String} locator located by xpath | CSS * @param {String} dataToFill //Value to enter into the textbox * */ static async enterTextUsingLocator(locator: string, dataToFill: string) { try { await TextField.enterTextUsingLocator(locator, dataToFill); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while entering text`); throw error; } } }