new(basic.gblib): Command CLICK BUTTON
This commit is contained in:
parent
e31cd4d819
commit
b87a0c397c
2 changed files with 20 additions and 0 deletions
|
@ -807,6 +807,14 @@ export class KeywordsExpressions {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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++] = [
|
keywords[i++] = [
|
||||||
/^\s*(click)(\s*)(.*)/gim,
|
/^\s*(click)(\s*)(.*)/gim,
|
||||||
($0, $1, $2, $3) => {
|
($0, $1, $2, $3) => {
|
||||||
|
|
|
@ -317,6 +317,18 @@ export class WebAutomationServices {
|
||||||
await this.debugStepWeb(pid, page);
|
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
|
* Returns the screenshot of page or element
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue