import { DewButton } from "../dewButton"; import { CommonKeyword } from '../commonKeyword'; import { TextField } from "../textfield"; import { DewElement } from "../element"; import { Wait } from "../dewWait"; /** * EProcMainSearch class */ export class EProcMainSearch { /** * To search for a catalog item * @param {String} item - name of item to search */ static async searchItem(item: any) { await searchItemAndWaitForSuggestion(item); await CommonKeyword.pressKey(`Enter`); } /** * To search and select an item as per categories * @param {String} item - name of item to search * @param {String} category - name of category to search an item in */ static async searchAndSelectItem(item: string, category = `Catalog Items`) { await searchItemAndWaitForSuggestion(item); await CommonKeyword.click(`//*[contains(@class,'search-menu')//strong[text()='${category}']`); } /** * To create request after unsuccesfull search * @param {String} item - name of item to search */ static async createRequest(item: string) { await searchItemAndWaitForSuggestion(item); await DewButton.click(`Create Request`); } /** * To create non-catalog item/service */ static async createRequestForNonCatalogItem() { await CommonKeyword.click(`//eproc-main-search/div[span[text()='Order Non-Catalog Item/Service']]/span[text()='Create Request']`); } } /** * To enter item and wait for suggestion * @param {String} item */ async function searchItemAndWaitForSuggestion(item: string) { await TextField.enterTextUsingLocator(`//eproc-main-search//input[@aria-label='Search And Select']`, item); await Wait.waitForDefaultTimeout(5); await DewElement.verifyIfISeeElement(`.search-menu`); }