automation_model 1.0.16 → 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 +37 -6
- package/package.json +1 -1
package/bin/stable_browser.js
CHANGED
|
@@ -64,16 +64,47 @@ class StableBrowser {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
async click(selector) {
|
|
67
|
-
|
|
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
|
+
}
|
|
68
78
|
}
|
|
69
79
|
async fill(selector, value) {
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
}
|
|
73
93
|
}
|
|
74
94
|
async verifyElementExistInPage(selector) {
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
|
|
77
108
|
//await expect(element !== undefined).toBeTruthy();
|
|
78
109
|
}
|
|
79
110
|
async waitForPageLoad() {
|