import Core from '../../lib/global/global'; import { fixture } from "../hooks/pageFixture"; export default class KeyboardActions { constructor() { } async clearAndFill(locator: string, value: 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.click(); await obj.fill(value); message = `'` + value + `' has been filled 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 clearAndFillPassword(locator: string, value: 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.click(); await obj.fill(value); message = `Password ***** has been entered 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 appendText(locator: string, value: 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.click(); await obj.type(value); message = `Text ` + value + ` has been appended 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,}); } } }