automation_model 1.0.27 → 1.0.29
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 +35 -2
- package/package.json +1 -1
package/bin/stable_browser.js
CHANGED
|
@@ -16,7 +16,7 @@ class StableBrowser {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
_fixUsingParams(text, _params) {
|
|
19
|
-
if (!_params) {
|
|
19
|
+
if (!_params || typeof text !== "string") {
|
|
20
20
|
return text;
|
|
21
21
|
}
|
|
22
22
|
for (let key in _params) {
|
|
@@ -119,7 +119,12 @@ class StableBrowser {
|
|
|
119
119
|
let element = await this._locate(selector, info, _params);
|
|
120
120
|
|
|
121
121
|
await this._screenShot(options);
|
|
122
|
-
|
|
122
|
+
try {
|
|
123
|
+
await element.click({ timeout: 5000 });
|
|
124
|
+
} catch (e) {
|
|
125
|
+
info.log.push("click failed, will try force click");
|
|
126
|
+
await element.click({ timeout: 10000, force: true });
|
|
127
|
+
}
|
|
123
128
|
return info;
|
|
124
129
|
} catch (e) {
|
|
125
130
|
this.logger.error("click failed " + JSON.stringify(info));
|
|
@@ -130,6 +135,34 @@ class StableBrowser {
|
|
|
130
135
|
this.logger.info("click failed, will try next selector");
|
|
131
136
|
}
|
|
132
137
|
}
|
|
138
|
+
|
|
139
|
+
async selectOptions(selector, values, _params = null, options = {}) {
|
|
140
|
+
const info = {};
|
|
141
|
+
info.log = [];
|
|
142
|
+
info.operation = "selectOptions";
|
|
143
|
+
info.selector = selector;
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
let element = await this._locate(selector, info, _params);
|
|
147
|
+
|
|
148
|
+
await this._screenShot(options);
|
|
149
|
+
try {
|
|
150
|
+
await element.selectOptions(values, { timeout: 5000 });
|
|
151
|
+
} catch (e) {
|
|
152
|
+
info.log.push("selectOptions failed, will try force");
|
|
153
|
+
await element.selectOptions(values, { timeout: 10000, force: true });
|
|
154
|
+
}
|
|
155
|
+
return info;
|
|
156
|
+
} catch (e) {
|
|
157
|
+
this.logger.error("selectOptions failed " + JSON.stringify(info));
|
|
158
|
+
Object.assign(e, { info: info });
|
|
159
|
+
await this._screenShot(options);
|
|
160
|
+
throw e;
|
|
161
|
+
|
|
162
|
+
this.logger.info("click failed, will try next selector");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
133
166
|
async fill(selector, value, _params = null, options = {}) {
|
|
134
167
|
const info = {};
|
|
135
168
|
info.log = [];
|