@mablhq/mabl-cli 1.17.0 → 1.19.3
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/api/basicApiClient.js +7 -1
- package/api/featureSet.js +1 -4
- package/api/mablApiClient.js +3 -3
- package/browserLauncher/browserLauncherFactory.js +2 -3
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +11 -9
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +1 -11
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +18 -0
- package/browserLauncher/runnerType.js +0 -1
- package/commands/constants.js +3 -2
- package/commands/tests/testsUtil.js +11 -6
- package/commands/tests/tests_cmds/run.js +5 -0
- package/domUtil/index.js +1 -1
- package/domUtil/index.js.LICENSE.txt +5 -5
- package/execution/index.js +1 -1
- package/execution/index.js.LICENSE.txt +7 -5
- package/index.d.ts +0 -1
- package/mablscript/MablAction.js +1 -1
- package/mablscript/MablStep.js +21 -3
- package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
- package/mablscript/actions/ConditionAction.js +11 -3
- package/mablscript/actions/ExtractAction.js +16 -7
- package/mablscript/actions/FindAction.js +101 -69
- package/mablscript/actions/GenerateRandomStringAction.js +2 -1
- package/mablscript/actions/GetUrlAction.js +1 -1
- package/mablscript/actions/GetVariableValue.js +2 -2
- package/mablscript/diffing/diffingUtil.js +146 -0
- package/mablscript/importer.js +20 -2
- package/mablscript/steps/AccessibilityCheck.js +5 -5
- package/mablscript/steps/AssertStep.js +45 -31
- package/mablscript/steps/AssertStepOld.js +39 -21
- package/mablscript/steps/AwaitTabStep.js +7 -6
- package/mablscript/steps/ClickAndHoldStep.js +6 -6
- package/mablscript/steps/ClickStep.js +5 -5
- package/mablscript/steps/CreateVariableStep.js +2 -2
- package/mablscript/steps/DoubleClickStep.js +6 -6
- package/mablscript/steps/DownloadStep.js +3 -2
- package/mablscript/steps/EchoStep.js +3 -1
- package/mablscript/steps/ElseIfConditionStep.js +5 -2
- package/mablscript/steps/EnterTextStep.js +11 -8
- package/mablscript/steps/EvaluateFlowStep.js +40 -0
- package/mablscript/steps/HoverStep.js +5 -5
- package/mablscript/steps/IfConditionStep.js +6 -6
- package/mablscript/steps/ReleaseStep.js +7 -6
- package/mablscript/steps/RemoveCookieStep.js +2 -3
- package/mablscript/steps/SelectStep.js +5 -5
- package/mablscript/steps/SendHttpRequestStep.js +3 -3
- package/mablscript/steps/SendKeyStep.js +8 -8
- package/mablscript/steps/SetCookieStep.js +2 -4
- package/mablscript/steps/SetFilesStep.js +5 -5
- package/mablscript/steps/SetViewportStep.js +1 -1
- package/mablscript/steps/SwitchContextStep.js +3 -3
- package/mablscript/steps/VisitUrlStep.js +2 -1
- package/mablscript/steps/WaitStep.js +1 -4
- package/mablscript/steps/WaitUntilStep.js +3 -3
- package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
- package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
- package/mablscriptFind/index.js +1 -1
- package/mablscriptFind/index.js.LICENSE.txt +5 -5
- package/package.json +3 -3
- package/resources/mablFind.js +1 -1
- package/resources/pdf-viewer/index.js +1 -1
- package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
- package/util/actionabilityUtil.js +1 -24
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -134
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -332
- package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
|
@@ -168,6 +168,8 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
168
168
|
* code.
|
|
169
169
|
*/
|
|
170
170
|
|
|
171
|
+
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
172
|
+
|
|
171
173
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
172
174
|
|
|
173
175
|
/**
|
|
@@ -180,9 +182,9 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
180
182
|
*/
|
|
181
183
|
|
|
182
184
|
/**
|
|
183
|
-
* @license Complex.js v2.0.12
|
|
185
|
+
* @license Complex.js v2.0.15 12/05/2020
|
|
184
186
|
*
|
|
185
|
-
* Copyright (c)
|
|
187
|
+
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
186
188
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
187
189
|
**/
|
|
188
190
|
|
|
@@ -199,10 +201,10 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
199
201
|
*/
|
|
200
202
|
|
|
201
203
|
/**
|
|
202
|
-
* @license Fraction.js v4.
|
|
203
|
-
*
|
|
204
|
+
* @license Fraction.js v4.1.3 23/05/2021
|
|
205
|
+
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
|
|
204
206
|
*
|
|
205
|
-
* Copyright (c)
|
|
207
|
+
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
|
|
206
208
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
207
209
|
**/
|
|
208
210
|
|
package/index.d.ts
CHANGED
package/mablscript/MablAction.js
CHANGED
package/mablscript/MablStep.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.buildObjectString = exports.buildSourceRepresentationOfObject = exports.MablStep = void 0;
|
|
7
|
+
const domUtil_1 = require("../domUtil");
|
|
4
8
|
const MablAction_1 = require("./MablAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
|
|
6
9
|
const MablSymbol_1 = require("./MablSymbol");
|
|
7
|
-
const
|
|
10
|
+
const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
|
|
11
|
+
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
8
12
|
class MablStep extends MablAction_1.MablAction {
|
|
9
13
|
constructor(name, args, actions) {
|
|
10
14
|
super(name, args);
|
|
@@ -25,9 +29,15 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
25
29
|
setAnnotation(annotation) {
|
|
26
30
|
this.annotation = annotation;
|
|
27
31
|
}
|
|
32
|
+
getAnnotation() {
|
|
33
|
+
return this.annotation;
|
|
34
|
+
}
|
|
28
35
|
setDescription(description) {
|
|
29
36
|
this.description = description;
|
|
30
37
|
}
|
|
38
|
+
getDescription() {
|
|
39
|
+
return this.description;
|
|
40
|
+
}
|
|
31
41
|
setStepSourceIndexInFlow(index) {
|
|
32
42
|
this.stepSourceIndexInFlow = index;
|
|
33
43
|
}
|
|
@@ -102,7 +112,7 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
102
112
|
case 'number':
|
|
103
113
|
return `${key}: ${objectArgs[key]}`;
|
|
104
114
|
default:
|
|
105
|
-
return `${key}: "${objectArgs[key]}"`;
|
|
115
|
+
return `${key}: "${(0, domUtil_1.escapeMablscriptString)(objectArgs[key])}"`;
|
|
106
116
|
}
|
|
107
117
|
});
|
|
108
118
|
return `{${mablArgs.join(', ')}}`;
|
|
@@ -110,6 +120,14 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
110
120
|
toMablscript() {
|
|
111
121
|
return '';
|
|
112
122
|
}
|
|
123
|
+
toLineDiffFormat() {
|
|
124
|
+
const lineDiffProperties = {
|
|
125
|
+
annotation: this.annotation,
|
|
126
|
+
disabled: this.isDisabled(),
|
|
127
|
+
mablscript: this.toMablscript(),
|
|
128
|
+
};
|
|
129
|
+
return (0, fast_json_stable_stringify_1.default)(lineDiffProperties);
|
|
130
|
+
}
|
|
113
131
|
}
|
|
114
132
|
exports.MablStep = MablStep;
|
|
115
133
|
MablStep.mablScriptStepNames = ['mablStep'];
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AwaitPDFDownloadAction = void 0;
|
|
4
4
|
const AwaitDownloadAction_1 = require("./AwaitDownloadAction");
|
|
5
|
+
const domUtil_1 = require("../../domUtil");
|
|
5
6
|
class AwaitPDFDownloadAction extends AwaitDownloadAction_1.AwaitDownloadAction {
|
|
6
7
|
constructor(name, args) {
|
|
7
8
|
super(name, args);
|
|
8
9
|
this.pdfUUID = this.getActionArgs()[0].uuid;
|
|
9
10
|
}
|
|
10
11
|
toMablscript() {
|
|
11
|
-
return `await_pdf({uuid:
|
|
12
|
+
return `await_pdf(${(0, domUtil_1.buildStepArgumentString)({ uuid: this.pdfUUID })})`;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.AwaitPDFDownloadAction = AwaitPDFDownloadAction;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConditionAction = void 0;
|
|
4
|
+
const domUtil_1 = require("../../domUtil");
|
|
4
5
|
const MablAction_1 = require("../MablAction");
|
|
5
6
|
const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
|
|
6
7
|
class ConditionAction extends MablAction_1.MablAction {
|
|
@@ -48,9 +49,16 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
generateEvaluateConditionMablscript() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
let value = '';
|
|
53
|
+
if (this.conditionValueAttribute !== undefined) {
|
|
54
|
+
if (!(0, MablAction_1.argumentIsMablVariable)(this.conditionValueAttribute)) {
|
|
55
|
+
value = `, "${(0, domUtil_1.escapeMablscriptString)(this.conditionValueAttribute)}"`;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
value = `, ${this.subVariable(this.conditionValueAttribute)}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return `${this.name}("${this.conditionAttribute}"${value})`;
|
|
54
62
|
}
|
|
55
63
|
toMablscript() {
|
|
56
64
|
return `${this.generateEvaluateConditionMablscript()}`;
|
|
@@ -6,21 +6,26 @@ const ExtractDescriptor_1 = require("../types/ExtractDescriptor");
|
|
|
6
6
|
class ExtractAction extends MablAction_1.MablAction {
|
|
7
7
|
constructor(name, args) {
|
|
8
8
|
super(name, args);
|
|
9
|
+
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_INNER_TEXT) {
|
|
10
|
+
this.name = 'extract_attribute';
|
|
11
|
+
this.extractionAttribute = 'innerText';
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
this.extractionAttribute = this.getActionArgs()[0];
|
|
15
|
+
}
|
|
9
16
|
this.extractionType = this.name;
|
|
10
|
-
this.extractionAttribute = this.getActionArgs()[0];
|
|
11
17
|
this.extractDescriptor = this.getExtractDescriptor();
|
|
12
18
|
}
|
|
13
19
|
getExtractDescriptor() {
|
|
14
|
-
|
|
15
|
-
if (!attributeName) {
|
|
20
|
+
if (!this.extractionAttribute) {
|
|
16
21
|
throw new Error(`Attribute name is required for extract attribute action.`);
|
|
17
22
|
}
|
|
18
|
-
if (typeof
|
|
19
|
-
throw new Error(`Invalid attribute provided for extract attribute extractor: ${
|
|
23
|
+
if (typeof this.extractionAttribute !== 'string') {
|
|
24
|
+
throw new Error(`Invalid attribute provided for extract attribute extractor: ${this.extractionAttribute}`);
|
|
20
25
|
}
|
|
21
26
|
return {
|
|
22
27
|
extractType: ExtractDescriptor_1.ExtractType.fromString(this.name),
|
|
23
|
-
attributeName,
|
|
28
|
+
attributeName: this.extractionAttribute,
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
31
|
toMablscript() {
|
|
@@ -31,7 +36,11 @@ class ExtractAction extends MablAction_1.MablAction {
|
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
exports.ExtractAction = ExtractAction;
|
|
34
|
-
ExtractAction.mablScriptStepNames = [
|
|
39
|
+
ExtractAction.mablScriptStepNames = [
|
|
40
|
+
'extract_attribute',
|
|
41
|
+
'extract_email_attribute',
|
|
42
|
+
'extract_inner_text',
|
|
43
|
+
];
|
|
35
44
|
ExtractAction.mablscriptToYamlType = {
|
|
36
45
|
extract_attribute: 'ElementAttribute',
|
|
37
46
|
extract_email_attribute: 'EmailAttribute',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalize = exports.isElementSelector = exports.FindAction = exports.findTypesToFormattedType = void 0;
|
|
4
|
+
const domUtil_1 = require("../../domUtil");
|
|
4
5
|
const mablscriptFind_1 = require("../../mablscriptFind");
|
|
5
6
|
const MablAction_1 = require("../MablAction");
|
|
6
|
-
const MablStep_1 = require("../MablStep");
|
|
7
7
|
exports.findTypesToFormattedType = {
|
|
8
8
|
find_all: 'FindAll',
|
|
9
9
|
find_any: 'FindFirst',
|
|
@@ -12,6 +12,7 @@ exports.findTypesToFormattedType = {
|
|
|
12
12
|
find_one: 'FindOne',
|
|
13
13
|
find_email: 'FindEmail',
|
|
14
14
|
find_tab: 'FindTab',
|
|
15
|
+
find_last: 'FindLast',
|
|
15
16
|
};
|
|
16
17
|
const formattedFindTypeToMablscript = {};
|
|
17
18
|
Object.entries(exports.findTypesToFormattedType).forEach(([findType, field]) => (formattedFindTypeToMablscript[field] = findType));
|
|
@@ -19,14 +20,14 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
19
20
|
constructor(name, args) {
|
|
20
21
|
super(name, args);
|
|
21
22
|
const actionName = this.getActionName();
|
|
22
|
-
if (!(0,
|
|
23
|
+
if (!(0, domUtil_1.isFindType)(actionName)) {
|
|
23
24
|
throw new Error(`Unknown find type for action: ${actionName}`);
|
|
24
25
|
}
|
|
25
|
-
const findType =
|
|
26
|
-
const [selectors, options] = this.getActionArgs();
|
|
26
|
+
const findType = domUtil_1.FindType.fromString(actionName);
|
|
27
27
|
this.isValid = true;
|
|
28
28
|
switch (findType) {
|
|
29
|
-
case
|
|
29
|
+
case domUtil_1.FindType.FIND_ONE: {
|
|
30
|
+
const [selectors, options] = this.getActionArgs();
|
|
30
31
|
if (!isElementSelector(selectors)) {
|
|
31
32
|
this.isValid = false;
|
|
32
33
|
}
|
|
@@ -41,24 +42,35 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
41
42
|
findType,
|
|
42
43
|
findTarget,
|
|
43
44
|
};
|
|
44
|
-
if ((0,
|
|
45
|
+
if ((0, domUtil_1.isFindOptions)(options)) {
|
|
45
46
|
this.findDescriptor.findOptions = options;
|
|
46
47
|
}
|
|
47
48
|
break;
|
|
48
|
-
|
|
49
|
-
case
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
|
|
49
|
+
}
|
|
50
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
51
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
52
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
53
|
+
case domUtil_1.FindType.FIND_ALL: {
|
|
54
|
+
const [primarySelector, foundSelector, findOptions] = this.getActionArgs();
|
|
55
|
+
if (!(0, domUtil_1.isCssSelector)(primarySelector) &&
|
|
56
|
+
!(0, domUtil_1.isXPathSelector)(primarySelector)) {
|
|
53
57
|
this.isValid = false;
|
|
54
58
|
}
|
|
55
59
|
this.findDescriptor = {
|
|
56
60
|
findType,
|
|
57
|
-
findTarget:
|
|
61
|
+
findTarget: primarySelector,
|
|
62
|
+
foundElementSelectors: foundSelector,
|
|
63
|
+
primarySelectors: {
|
|
64
|
+
...primarySelector,
|
|
65
|
+
uuid: primarySelector.uuid,
|
|
66
|
+
},
|
|
67
|
+
hints: findOptions === null || findOptions === void 0 ? void 0 : findOptions.hints,
|
|
58
68
|
};
|
|
59
69
|
break;
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
}
|
|
71
|
+
case domUtil_1.FindType.FIND_COOKIE: {
|
|
72
|
+
const [selectors] = this.getActionArgs();
|
|
73
|
+
if (!(0, domUtil_1.isCookieSelector)(selectors)) {
|
|
62
74
|
this.isValid = false;
|
|
63
75
|
}
|
|
64
76
|
this.findDescriptor = {
|
|
@@ -66,8 +78,10 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
66
78
|
findTarget: selectors,
|
|
67
79
|
};
|
|
68
80
|
break;
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
}
|
|
82
|
+
case domUtil_1.FindType.FIND_EMAIL:
|
|
83
|
+
const [selectors] = this.getActionArgs();
|
|
84
|
+
if (!(0, domUtil_1.isEmailSelector)(selectors)) {
|
|
71
85
|
this.isValid = false;
|
|
72
86
|
}
|
|
73
87
|
this.findDescriptor = {
|
|
@@ -75,14 +89,16 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
75
89
|
findTarget: selectors,
|
|
76
90
|
};
|
|
77
91
|
break;
|
|
78
|
-
case
|
|
79
|
-
|
|
92
|
+
case domUtil_1.FindType.FIND_TAB: {
|
|
93
|
+
const [selectors] = this.getActionArgs();
|
|
94
|
+
if (selectors !== 'initial' && !(0, domUtil_1.isTabSelector)(selectors)) {
|
|
80
95
|
this.isValid = false;
|
|
81
96
|
}
|
|
82
97
|
this.findDescriptor = {
|
|
83
98
|
findType,
|
|
84
99
|
findTarget: selectors,
|
|
85
100
|
};
|
|
101
|
+
}
|
|
86
102
|
}
|
|
87
103
|
Object.freeze(this.findDescriptor);
|
|
88
104
|
}
|
|
@@ -119,14 +135,14 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
119
135
|
const result = {};
|
|
120
136
|
const find = this.toDescriptor();
|
|
121
137
|
switch (find.findType) {
|
|
122
|
-
case
|
|
123
|
-
case
|
|
124
|
-
case
|
|
125
|
-
case
|
|
138
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
139
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
140
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
141
|
+
case domUtil_1.FindType.FIND_ALL:
|
|
126
142
|
result.find_type = find.findType;
|
|
127
143
|
result.selector = find.findTarget;
|
|
128
144
|
break;
|
|
129
|
-
case
|
|
145
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
130
146
|
result.selector = find.findTarget.selector;
|
|
131
147
|
if ((_a = find.findTarget.auxiliaryDescriptors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
132
148
|
result.selectorAncestors = find.findTarget.auxiliaryDescriptors.map((descriptor) => descriptor.selector);
|
|
@@ -139,62 +155,86 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
139
155
|
}
|
|
140
156
|
getSelIdeTarget() {
|
|
141
157
|
switch (this.findDescriptor.findType) {
|
|
142
|
-
case
|
|
143
|
-
case
|
|
144
|
-
case
|
|
145
|
-
case
|
|
146
|
-
if ((0,
|
|
158
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
159
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
160
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
161
|
+
case domUtil_1.FindType.FIND_ALL:
|
|
162
|
+
if ((0, domUtil_1.isCssSelector)(this.findDescriptor.findTarget)) {
|
|
147
163
|
return `css=${this.findDescriptor.findTarget.css_query}`;
|
|
148
164
|
}
|
|
149
165
|
return `xpath=${this.findDescriptor.findTarget.xpath}`;
|
|
150
|
-
case
|
|
166
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
151
167
|
return `xpath=${this.findDescriptor.findTarget.selector.xpath}`;
|
|
152
168
|
default:
|
|
153
169
|
throw new Error(`Error generating SeleniumIDE target for ${this.getActionName()}: Unimplemented find type ${this.findDescriptor.findType}`);
|
|
154
170
|
}
|
|
155
171
|
}
|
|
156
172
|
toMablscript() {
|
|
157
|
-
return this.
|
|
173
|
+
return this.generateFindMablscript();
|
|
158
174
|
}
|
|
159
|
-
|
|
175
|
+
generateFindMablscript() {
|
|
160
176
|
var _a;
|
|
177
|
+
let action = this.findDescriptor.findType;
|
|
178
|
+
let args = '';
|
|
161
179
|
switch (this.findDescriptor.findType) {
|
|
162
|
-
case
|
|
180
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
163
181
|
const find = this.findDescriptor;
|
|
164
|
-
const action = find.findType;
|
|
165
182
|
const selectors = ((_a = find.findTarget.auxiliaryDescriptors) === null || _a === void 0 ? void 0 : _a.length)
|
|
166
183
|
? '[' +
|
|
167
|
-
[
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
]
|
|
171
|
-
.map(mablscriptFind_1.buildElementSelectorString)
|
|
184
|
+
[find.findTarget, ...find.findTarget.auxiliaryDescriptors]
|
|
185
|
+
.map(mablscriptFind_1.buildFindDescriptorString)
|
|
186
|
+
.filter(Boolean)
|
|
172
187
|
.join(', ') +
|
|
173
188
|
']'
|
|
174
|
-
: (0, mablscriptFind_1.
|
|
189
|
+
: (0, mablscriptFind_1.buildFindDescriptorString)(find.findTarget);
|
|
175
190
|
const options = buildFindOptionsString(find.findOptions);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
case
|
|
180
|
-
case
|
|
181
|
-
case
|
|
182
|
-
case mablscriptFind_1.FindType.FIND_ALL:
|
|
183
|
-
case mablscriptFind_1.FindType.FIND_COOKIE:
|
|
184
|
-
case mablscriptFind_1.FindType.FIND_EMAIL: {
|
|
191
|
+
args = [selectors, options].filter(Boolean).join(', ');
|
|
192
|
+
break;
|
|
193
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
194
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
195
|
+
case domUtil_1.FindType.FIND_ALL:
|
|
196
|
+
case domUtil_1.FindType.FIND_FIRST: {
|
|
185
197
|
const find = this.findDescriptor;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
const selector = (0, mablscriptFind_1.buildElementSelectorString)(find.findTarget);
|
|
199
|
+
let foundElementSelectors;
|
|
200
|
+
if (find.foundElementSelectors) {
|
|
201
|
+
if (Array.isArray(find.foundElementSelectors)) {
|
|
202
|
+
foundElementSelectors = find.foundElementSelectors
|
|
203
|
+
.map((selector) => (0, mablscriptFind_1.buildFindDescriptorString)({ selector }))
|
|
204
|
+
.join(', ');
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
foundElementSelectors = (0, mablscriptFind_1.buildFindDescriptorString)({
|
|
208
|
+
selector: find.foundElementSelectors,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
foundElementSelectors = '{selector_type: "element"}';
|
|
214
|
+
}
|
|
215
|
+
args = [selector, foundElementSelectors].join(', ');
|
|
216
|
+
if (find.hints) {
|
|
217
|
+
args += `, ${(0, mablscriptFind_1.buildFindHintsString)(find.hints)}`;
|
|
193
218
|
}
|
|
194
|
-
|
|
219
|
+
if (find.findType === domUtil_1.FindType.FIND_ANY) {
|
|
220
|
+
action = domUtil_1.FindType.FIND_FIRST;
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case domUtil_1.FindType.FIND_COOKIE:
|
|
225
|
+
args = (0, mablscriptFind_1.buildCookieSelectorString)(this.findDescriptor.findTarget);
|
|
226
|
+
break;
|
|
227
|
+
case domUtil_1.FindType.FIND_EMAIL: {
|
|
228
|
+
args = (0, mablscriptFind_1.buildEmailSelectorString)(this.findDescriptor.findTarget);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case domUtil_1.FindType.FIND_TAB:
|
|
232
|
+
args = (0, mablscriptFind_1.buildTabSelectorString)(this.findDescriptor.findTarget);
|
|
233
|
+
break;
|
|
195
234
|
default:
|
|
196
235
|
throw new Error(`Error generating mablscript: Unexpected find type in ${JSON.stringify(this.findDescriptor)}`);
|
|
197
236
|
}
|
|
237
|
+
return `${action}(${args})`;
|
|
198
238
|
}
|
|
199
239
|
isValidDescriptor() {
|
|
200
240
|
return this.isValid;
|
|
@@ -225,29 +265,21 @@ function buildFindOptionsString(findOptions) {
|
|
|
225
265
|
if (!findOptions) {
|
|
226
266
|
return '';
|
|
227
267
|
}
|
|
228
|
-
|
|
229
|
-
if (findOptions.hints) {
|
|
230
|
-
findOptionsFinal += `hints: {${(0, MablStep_1.buildObjectString)(findOptions.hints).join(', ')}}`;
|
|
231
|
-
}
|
|
232
|
-
if (findOptions.waitUntil) {
|
|
233
|
-
findOptionsFinal += `waitUntil: {${(0, MablStep_1.buildObjectString)(findOptions.waitUntil)}}`;
|
|
234
|
-
}
|
|
235
|
-
findOptionsFinal += '}';
|
|
236
|
-
return findOptionsFinal;
|
|
268
|
+
return JSON.stringify(findOptions);
|
|
237
269
|
}
|
|
238
270
|
function isElementSelector(maybeSelectors) {
|
|
239
271
|
const [target, ancestor] = Array.isArray(maybeSelectors)
|
|
240
272
|
? [...maybeSelectors]
|
|
241
273
|
: [maybeSelectors];
|
|
242
|
-
const validTarget = (0,
|
|
274
|
+
const validTarget = (0, domUtil_1.isStandardSelector)(target) || (0, domUtil_1.isNormalizedFindDescriptor)(target);
|
|
243
275
|
const validAncestor = !ancestor ||
|
|
244
|
-
(0,
|
|
245
|
-
(0,
|
|
276
|
+
(0, domUtil_1.isStandardSelector)(ancestor) ||
|
|
277
|
+
(0, domUtil_1.isNormalizedFindDescriptor)(ancestor);
|
|
246
278
|
return !!(validTarget && validAncestor);
|
|
247
279
|
}
|
|
248
280
|
exports.isElementSelector = isElementSelector;
|
|
249
281
|
function normalize(maybeFindDescriptor) {
|
|
250
|
-
if ((0,
|
|
282
|
+
if ((0, domUtil_1.isNormalizedFindDescriptor)(maybeFindDescriptor)) {
|
|
251
283
|
return { ...maybeFindDescriptor };
|
|
252
284
|
}
|
|
253
285
|
return { selector: maybeFindDescriptor };
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GenerateRandomStringAction = void 0;
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
|
+
const domUtil_1 = require("../../domUtil");
|
|
5
6
|
class GenerateRandomStringAction extends MablAction_1.MablAction {
|
|
6
7
|
constructor(name, args) {
|
|
7
8
|
super(name, args);
|
|
8
9
|
this.generateString = this.getActionArgs()[0];
|
|
9
10
|
}
|
|
10
11
|
toMablscript() {
|
|
11
|
-
return `generate_random_string(\"${this.generateString}\")`;
|
|
12
|
+
return `generate_random_string(\"${(0, domUtil_1.escapeMablscriptString)(this.generateString)}\")`;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.GenerateRandomStringAction = GenerateRandomStringAction;
|
|
@@ -13,7 +13,7 @@ class GetUrlAction extends MablAction_1.MablAction {
|
|
|
13
13
|
toDescriptor() {
|
|
14
14
|
return (0, GetCurrentLocationDescriptor_1.newGetCurrentLocationDescriptor)();
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
generateFindMablscript() {
|
|
17
17
|
return 'get_current_location()';
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetVariableValue = void 0;
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
|
-
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
6
5
|
const MablSymbol_1 = require("../MablSymbol");
|
|
6
|
+
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
7
7
|
class GetVariableValue extends MablAction_1.MablAction {
|
|
8
8
|
constructor(name, args) {
|
|
9
9
|
super(name, args);
|
|
@@ -19,7 +19,7 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
19
19
|
toDescriptor() {
|
|
20
20
|
return (0, GetVariableDescriptor_1.newGetVariableDescriptor)(this.variable);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
generateFindMablscript() {
|
|
23
23
|
return `get_variable_value(${this.variable.name})`;
|
|
24
24
|
}
|
|
25
25
|
}
|