automation_model 1.0.5 → 1.0.6
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 +18 -18
- package/package.json +1 -1
package/bin/stable_browser.js
CHANGED
|
@@ -10,33 +10,33 @@ class StableBrowser {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
async _locate(selector, scope) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let currentScope = scope;
|
|
13
|
+
try {
|
|
14
|
+
if (Array.isArray(selector)) {
|
|
15
|
+
let currentScope = scope;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
).first();
|
|
23
|
-
}
|
|
17
|
+
for (let i = 0; i < selector.length; i++) {
|
|
18
|
+
currentScope = (
|
|
19
|
+
await this._locate(selector[i], currentScope)
|
|
20
|
+
).first();
|
|
24
21
|
}
|
|
22
|
+
return currentScope;
|
|
23
|
+
}
|
|
24
|
+
if (typeof selector === "object") {
|
|
25
25
|
if (selector.css) {
|
|
26
|
-
return await scope.locator(selector.css).first();
|
|
26
|
+
return (await scope.locator(selector.css)).first();
|
|
27
27
|
}
|
|
28
28
|
if (selector.role) {
|
|
29
|
-
return
|
|
30
|
-
.getByRole(selector.role[0], selector.role[1])
|
|
31
|
-
|
|
29
|
+
return (
|
|
30
|
+
await scope.getByRole(selector.role[0], selector.role[1])
|
|
31
|
+
).first();
|
|
32
32
|
}
|
|
33
33
|
if (selector.text) {
|
|
34
|
-
return await scope.getByText(selector.text)
|
|
34
|
+
return await scope.getByText(selector.text);
|
|
35
35
|
}
|
|
36
|
-
throw new Error(`Unknown locator type ${type}`);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.log("invalid locator object, will try to parse as text");
|
|
39
36
|
}
|
|
37
|
+
throw new Error(`Unknown locator type ${type}`);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.log("invalid locator object, will try to parse as text");
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (selector.startsWith("TEXT=")) {
|