Skip to content

Commit

Permalink
new(basic.gblib): Command CLICK BUTTON
Browse files Browse the repository at this point in the history
  • Loading branch information
phpussente committed May 4, 2023
1 parent e31cd4d commit b87a0c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/basic.gblib/services/KeywordsExpressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ export class KeywordsExpressions {
return `await wa.linkByText ({pid: pid, handle: page, ${params}})`;
}
];

keywords[i++] = [
/^\s*(click button)(\s*)(.*)/gim,
($0, $1, $2, $3) => {
const params = this.getParams($3, ['text', 'index']);
return `await wa.clickButton ({pid: pid, handle: page, ${params}})`;
}
];

keywords[i++] = [
/^\s*(click)(\s*)(.*)/gim,
Expand Down
12 changes: 12 additions & 0 deletions packages/basic.gblib/services/WebAutomationServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,18 @@ export class WebAutomationServices {
await els[index - 1].click();
await this.debugStepWeb(pid, page);
}

public async clickButton({ pid, handle, text, index }) {
const page = WebAutomationServices.getPageByHandle(handle);
GBLog.info(`BASIC: Web Automation CLICK BUTTON: ${text} ${index}.`);
if (!index) {
index = 1;
}
const els = await page.$x(`//button[contains(.,'${text}')]`);
await els[index - 1].click();
await this.debugStepWeb(pid, page);
}


/**
* Returns the screenshot of page or element
Expand Down

0 comments on commit b87a0c3

Please sign in to comment.