Skip to content

Commit

Permalink
feat: next elementHandle & 支持默认的剪贴板权限
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuineng committed Oct 26, 2023
1 parent 0ab5271 commit 61004ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/macaca-playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type TContextOptions = {
userAgent?: string,
recordVideo?: object,
viewport?: object,
permissions?: string[],
};

class Playwright extends DriverBase {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 13 additions & 1 deletion lib/next-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 61004ac

Please sign in to comment.