import { DewElement } from './element'; import { CommonKeyword } from './commonKeyword'; /** * DewButton class */ export class DewButton { /** * To click button with name provided in param * * ```js * * DewButton.click("Save") * ``` * * @param {string} buttonName * */ static async click(buttonName: string) { await CommonKeyword.clickElement(`.//dew-btn/button[div/span[text()[normalize-space()='${buttonName}']] and not(@disabled)]`); } /** * Returns true if button is enabled, else false * * ```js * * DewButton.verifyIfButtonEnabled("Save") * ``` * * @param {string} buttonName * */ static async verifyIfButtonEnabled(buttonName: string) { const enabledBtn = await DewElement.grabNumberOfVisibleElements(`.//dew-btn/button[div/span[text()[normalize-space()='${buttonName}']] and not(@disabled)]`); if (enabledBtn > 0) { return true; } else { return false; } } }