import Core from '../../lib/global/global'; import { fixture } from "../hooks/pageFixture"; const core = Core.getInstance(); export function single_Click(locator: string) { core.Mouse.singleClick(locator) } export function double_Click(locator: string) { core.Mouse.singleClick(locator) } export default class MouseAction { constructor() { } async singleClick(locator: string) { const timestamp = new Date().toISOString(); const core = Core.getInstance(); let status = 'Success'; let message = 'Action completed successfully'; try { // Perform a click action const obj = await core.Element.get(locator); await obj.waitFor({ state: "visible" }); await obj.click(); message = `Click action has been performed successfully`; } catch (error) { status = 'Failed'; if (error instanceof Error) { message = error.message; } } finally { // Log the result fixture.logger.info(message) //ActionLogger.log({timestamp, locator, status, message,}); } } async doubleClick(locator: string) { const timestamp = new Date().toISOString(); const core = Core.getInstance(); let status = 'Success'; let message = 'Action completed successfully'; try { // Perform a Double click action const obj = await core.Element.get(locator); await obj.waitFor({ state: "visible" }); await obj.DoubleClick(); message = `Double Click action has been performed successfully`; } catch (error) { status = 'Failed'; if (error instanceof Error) { message = error.message; } } finally { // Log the result fixture.logger.info(message) //ActionLogger.log({timestamp, locator, status, message,}); } } async rightClick(locator: string) { const timestamp = new Date().toISOString(); const core = Core.getInstance(); let status = 'Success'; let message = 'Action completed successfully'; try { // Perform a Right click action const obj = await core.Element.get(locator); await obj.waitFor({ state: "visible" }); await obj.RightClick(); message = `Right Click action has been performed successfully`; } catch (error) { status = 'Failed'; if (error instanceof Error) { message = error.message; } } finally { // Log the result fixture.logger.info(message) //ActionLogger.log({timestamp, locator, status, message,}); } } async clickButtonAndWait(locator: string) { const timestamp = new Date().toISOString(); const core = Core.getInstance(); let status = 'Success'; let message = 'Action completed successfully'; try { // Perform a Click action and Wait till page loads const obj = await core.Element.get(locator); await obj.waitFor({ state: "visible" }); await obj.click(); message = `Click Button and Wait action has been performed successfully`; } catch (error) { status = 'Failed'; if (error instanceof Error) { message = error.message; } } finally { // Log the result fixture.logger.info(message) fixture.page.waitForLoadState(); fixture.logger.info("Waiting for 2 seconds") fixture.page.waitForTimeout(2000); //ActionLogger.log({timestamp, locator, status, message,}); } } }