diff --git a/lib/macaca-playwright.ts b/lib/macaca-playwright.ts index 32ebb78..e26372d 100644 --- a/lib/macaca-playwright.ts +++ b/lib/macaca-playwright.ts @@ -16,6 +16,7 @@ type TContextOptions = { userAgent?: string, recordVideo?: object, viewport?: object, + permissions?: string[], }; class Playwright extends DriverBase { @@ -49,6 +50,10 @@ class Playwright extends DriverBase { const newContextOptions: TContextOptions = { locale: this.args.locale, ignoreHTTPSErrors: true, + permissions: [ + 'clipboard-read', + 'clipboard-write', + ], }; if (this.args.userAgent) { diff --git a/lib/next-actions.js b/lib/next-actions.js index c89a036..0b22927 100644 --- a/lib/next-actions.js +++ b/lib/next-actions.js @@ -58,10 +58,22 @@ nextActions.pagePopup = async function({ func, args }) { logger.error('pagePopup or func is not found'); }; +nextActions.elementHandle = async function(elementId, { func, args }) { + const element = this.elements[elementId]; + if (!element) { + logger.error('Element is not found'); + return null; + } + if (element && element[func]) { + const result = await element[func].apply(element, args); + return result || ''; + } +}; + nextActions.elementStatus = async function(elementId) { const element = this.elements[elementId]; if (!element) { - logger.error('click Element is not found'); + logger.error('Element is not found'); return null; } return {