automation_model 1.0.43 → 1.0.45
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 +25 -0
- package/package.json +1 -1
package/bin/stable_browser.js
CHANGED
|
@@ -242,6 +242,30 @@ class StableBrowser {
|
|
|
242
242
|
// .filter((line) => line.trim() !== "")
|
|
243
243
|
// .join("\n");
|
|
244
244
|
}
|
|
245
|
+
async containsPattern(selector, pattern, text, _params = null, options = {}) {
|
|
246
|
+
const info = {};
|
|
247
|
+
info.log = [];
|
|
248
|
+
info.operation = "containsPattern";
|
|
249
|
+
info.selector = selector;
|
|
250
|
+
info.value = text;
|
|
251
|
+
info.pattern = pattern;
|
|
252
|
+
try {
|
|
253
|
+
let foundText = await this.getText(selector, _params, options, info);
|
|
254
|
+
let escapedText = text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
255
|
+
pattern = pattern.replace("{text}", escapedText);
|
|
256
|
+
let regex = new RegExp(pattern);
|
|
257
|
+
if (!regex.test(foundText)) {
|
|
258
|
+
info.foundText = foundText;
|
|
259
|
+
throw new Error("element doesn't contain text " + text);
|
|
260
|
+
}
|
|
261
|
+
return info;
|
|
262
|
+
} catch (e) {
|
|
263
|
+
this.logger.error("verify element contains text failed " + JSON.stringify(info));
|
|
264
|
+
Object.assign(e, { info: info });
|
|
265
|
+
await this._screenShot(options);
|
|
266
|
+
throw e;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
245
269
|
|
|
246
270
|
async containsText(selector, text, _params = null, options = {}) {
|
|
247
271
|
const info = {};
|
|
@@ -303,4 +327,5 @@ class StableBrowser {
|
|
|
303
327
|
await this._screenShot(options);
|
|
304
328
|
}
|
|
305
329
|
}
|
|
330
|
+
|
|
306
331
|
export { StableBrowser };
|