automation_model 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/stable_browser.js +42 -6
- package/package.json +3 -2
package/bin/stable_browser.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import reg_parser from "regex-parser";
|
|
1
2
|
import { expect } from "@playwright/test";
|
|
2
3
|
class StableBrowser {
|
|
3
4
|
constructor(browser, page, logger) {
|
|
@@ -42,6 +43,10 @@ class StableBrowser {
|
|
|
42
43
|
return await this._checkUnique(scope.locator(selector.css));
|
|
43
44
|
}
|
|
44
45
|
if (selector.role) {
|
|
46
|
+
if (selector.role[1].nameReg) {
|
|
47
|
+
selector.role[1].name = reg_parser(selector.role[1].nameReg);
|
|
48
|
+
delete selector.role[1].nameReg;
|
|
49
|
+
}
|
|
45
50
|
return await this._checkUnique(scope.getByRole(selector.role[0], selector.role[1]));
|
|
46
51
|
}
|
|
47
52
|
if (selector.text) {
|
|
@@ -59,16 +64,47 @@ class StableBrowser {
|
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
async click(selector) {
|
|
62
|
-
|
|
67
|
+
for (let i = 0; i < selector.length; i++) {
|
|
68
|
+
try {
|
|
69
|
+
await (await this._locate(selector[i], this.page)).click();
|
|
70
|
+
return;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if (i === selector.length - 1) {
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
console.log("click failed, will try next selector");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
async fill(selector, value) {
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
for (let i = 0; i < selector.length; i++) {
|
|
81
|
+
try {
|
|
82
|
+
let element = await this._locate(selector[i], this.page);
|
|
83
|
+
await element.fill(value);
|
|
84
|
+
await element.dispatchEvent("change");
|
|
85
|
+
return;
|
|
86
|
+
} catch (e) {
|
|
87
|
+
if (i === selector.length - 1) {
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
console.log("click failed, will try next selector");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
68
93
|
}
|
|
69
94
|
async verifyElementExistInPage(selector) {
|
|
70
|
-
|
|
71
|
-
|
|
95
|
+
for (let i = 0; i < selector.length; i++) {
|
|
96
|
+
try {
|
|
97
|
+
const element = await this._locate(selector[0], this.page);
|
|
98
|
+
await expect(element).toHaveCount(1);
|
|
99
|
+
return;
|
|
100
|
+
} catch (e) {
|
|
101
|
+
if (i === selector.length - 1) {
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
console.log("click failed, will try next selector");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
72
108
|
//await expect(element !== undefined).toBeTruthy();
|
|
73
109
|
}
|
|
74
110
|
async waitForPageLoad() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "automation_model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "An automation infrastructure module to be use for generative AI automation projects.",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@playwright/test": "^1.35.0",
|
|
20
|
-
"playwright": "^1.33.0"
|
|
20
|
+
"playwright": "^1.33.0",
|
|
21
|
+
"regex-parser": "^2.2.11"
|
|
21
22
|
}
|
|
22
23
|
}
|