@mablhq/mabl-cli 1.62.1 → 2.1.0
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 +10 -10
- package/api/mablApiClient.js +39 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +6 -6
- package/cli.js +1 -0
- package/commands/app-files/app-files.js +5 -0
- package/commands/app-files/app-files_cmds/create.js +98 -0
- package/commands/app-files/app-files_cmds/delete.js +31 -0
- package/commands/app-files/app-files_cmds/download.js +50 -0
- package/commands/app-files/app-files_cmds/list.js +72 -0
- package/commands/config/config_cmds/install.js +92 -0
- package/commands/constants.js +9 -2
- package/commands/tests/testsUtil.js +9 -1
- package/commands/tests/tests_cmds/run-mobile.js +218 -0
- package/commands/tests/tests_cmds/run.js +1 -1
- package/core/util.js +36 -2
- package/env/defaultEnv.js +2 -1
- package/env/dev.js +2 -1
- package/env/env.js +3 -1
- package/env/local.js +2 -1
- package/env/prod.js +2 -1
- package/execution/index.js +13 -1
- package/execution/runAppiumServer.js +133 -0
- package/http/MablHttpAgent.js +1 -4
- package/http/RequestFilteringHttpAgent.js +3 -3
- package/http/axiosProxyConfig.js +10 -7
- package/http/httpUtil.js +10 -6
- package/index.js +3 -2
- package/mablApi/index.js +1 -1
- package/mablscript/MablAction.js +6 -2
- package/mablscript/MablStep.js +41 -5
- package/mablscript/MablStepV2.js +57 -0
- package/mablscript/MablSymbol.js +6 -2
- package/mablscript/actions/AwaitDownloadAction.js +1 -1
- package/mablscript/actions/ConditionAction.js +1 -1
- package/mablscript/actions/CountAction.js +1 -1
- package/mablscript/actions/ExtractAction.js +12 -7
- package/mablscript/actions/FindAction.js +6 -6
- package/mablscript/actions/GenerateEmailAddressAction.js +1 -1
- package/mablscript/actions/GenerateRandomStringAction.js +1 -1
- package/mablscript/actions/GetUrlAction.js +1 -1
- package/mablscript/actions/GetVariableValue.js +1 -1
- package/mablscript/actions/JavaScriptAction.js +25 -14
- package/mablscript/importer.js +99 -16
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +53 -0
- package/mablscript/mobile/steps/EnterTextStep.js +41 -0
- package/mablscript/mobile/steps/NavigateBackStep.js +20 -0
- package/mablscript/mobile/steps/NavigateHomeStep.js +21 -0
- package/mablscript/mobile/steps/ScrollStep.js +37 -0
- package/mablscript/mobile/steps/SetOrientationStep.js +20 -0
- package/mablscript/mobile/steps/TapStep.js +37 -0
- package/mablscript/mobile/steps/actions/MobileFindAction.js +23 -0
- package/mablscript/mobile/steps/stepUtil.js +74 -0
- package/mablscript/mobile/tests/StepTestsUtil.js +20 -0
- package/mablscript/mobile/tests/TestMobileFindDescriptors.js +215 -0
- package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +298 -0
- package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +79 -0
- package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +167 -0
- package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +121 -0
- package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +32 -0
- package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +57 -0
- package/mablscript/steps/AccessibilityCheck.js +20 -9
- package/mablscript/steps/AssertStep.js +54 -39
- package/mablscript/steps/AssertStepOld.js +35 -4
- package/mablscript/steps/AwaitTabStep.js +5 -2
- package/mablscript/steps/AwaitUploadsStep.js +6 -4
- package/mablscript/steps/ClearCookiesStep.js +6 -4
- package/mablscript/steps/ClickAndHoldStep.js +10 -3
- package/mablscript/steps/ClickStep.js +10 -3
- package/mablscript/steps/CreateVariableStep.js +25 -8
- package/mablscript/steps/DoubleClickStep.js +10 -3
- package/mablscript/steps/DownloadStep.js +4 -2
- package/mablscript/steps/EchoStep.js +8 -5
- package/mablscript/steps/ElseIfConditionStep.js +14 -4
- package/mablscript/steps/ElseStep.js +8 -5
- package/mablscript/steps/EndStep.js +8 -5
- package/mablscript/steps/EnterAuthCodeStep.js +10 -3
- package/mablscript/steps/EnterTextStep.js +8 -2
- package/mablscript/steps/EvaluateFlowStep.js +5 -2
- package/mablscript/steps/EvaluateJavaScriptStep.js +15 -4
- package/mablscript/steps/HoverStep.js +10 -3
- package/mablscript/steps/IfConditionStep.js +25 -12
- package/mablscript/steps/NavigateStep.js +5 -2
- package/mablscript/steps/OpenEmailStep.js +5 -2
- package/mablscript/steps/ReleaseStep.js +10 -3
- package/mablscript/steps/RemoveCookieStep.js +5 -2
- package/mablscript/steps/RightClickStep.js +10 -3
- package/mablscript/steps/SelectStep.js +9 -3
- package/mablscript/steps/SendHttpRequestStep.js +8 -4
- package/mablscript/steps/SendKeyStep.js +10 -3
- package/mablscript/steps/SetCookieStep.js +5 -2
- package/mablscript/steps/SetFilesStep.js +9 -3
- package/mablscript/steps/SetViewportStep.js +5 -3
- package/mablscript/steps/SwitchContextStep.js +14 -3
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +5 -2
- package/mablscript/steps/WaitStep.js +8 -4
- package/mablscript/steps/WaitUntilStep.js +6 -3
- package/mablscript/types/GetVariableDescriptor.js +8 -3
- package/mablscript/types/mobile/CreateVariableMobileStepDescriptor.js +9 -0
- package/mablscript/types/mobile/EnterTextStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateBackStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateHomeStepDescriptor.js +2 -0
- package/mablscript/types/mobile/ScrollStepDescriptor.js +2 -0
- package/mablscript/types/mobile/SetOrientationStepDescriptor.js +8 -0
- package/mablscript/types/mobile/StepWithMobileFindDescriptor.js +2 -0
- package/mablscript/types/mobile/TapStepDescriptor.js +8 -0
- package/mablscriptFind/index.js +1 -1
- package/observers/ObserverBase.js +9 -0
- package/observers/mockObserver.js +3 -3
- package/package.json +11 -6
- package/resources/webdriver.js +21 -0
- package/upload/index.js +5 -0
- package/util/FileCache.js +180 -0
- package/util/Lazy.js +90 -0
- package/util/MobileAppFileCache.js +102 -0
- package/util/RichPromise.js +3 -1
- package/util/javaScriptStepMigration.js +1 -0
- package/webdriver/index.js +41 -0
package/mablscript/MablAction.js
CHANGED
|
@@ -4,9 +4,10 @@ exports.convertObjectToMablscriptArgs = exports.distinctStrings = exports.parseA
|
|
|
4
4
|
const domUtil_1 = require("../domUtil");
|
|
5
5
|
const MablSymbol_1 = require("./MablSymbol");
|
|
6
6
|
class MablAction {
|
|
7
|
-
constructor(name, args) {
|
|
7
|
+
constructor(name, actionCode, args) {
|
|
8
8
|
this.name = name;
|
|
9
9
|
this.args = args;
|
|
10
|
+
this.actionCode = actionCode;
|
|
10
11
|
}
|
|
11
12
|
getActionArgs() {
|
|
12
13
|
return this.args ? this.args : [];
|
|
@@ -17,6 +18,9 @@ class MablAction {
|
|
|
17
18
|
getActionSourceIndexInStep() {
|
|
18
19
|
return this.actionSourceIndexInStep;
|
|
19
20
|
}
|
|
21
|
+
getActionCode() {
|
|
22
|
+
return this.actionCode;
|
|
23
|
+
}
|
|
20
24
|
subVariable(argument) {
|
|
21
25
|
if (argumentIsMablVariable(argument)) {
|
|
22
26
|
const matches = argument.match(MablSymbol_1.SINGLE_VARIABLE_PATTERN_REGEX);
|
|
@@ -34,7 +38,7 @@ class MablAction {
|
|
|
34
38
|
}
|
|
35
39
|
static findUniqueVariableReferencesInValue(value) {
|
|
36
40
|
const variableReferences = [];
|
|
37
|
-
if (
|
|
41
|
+
if ((0, MablSymbol_1.isMablSymbolObject)(value)) {
|
|
38
42
|
return [value.name];
|
|
39
43
|
}
|
|
40
44
|
else if (typeof value === 'string') {
|
package/mablscript/MablStep.js
CHANGED
|
@@ -3,16 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.buildObjectString = exports.buildSourceRepresentationOfObject = exports.MablStep = void 0;
|
|
6
|
+
exports.isMablStepV1 = exports.buildObjectString = exports.buildSourceRepresentationOfObject = exports.MablStep = void 0;
|
|
7
7
|
const domUtil_1 = require("../domUtil");
|
|
8
8
|
const MablAction_1 = require("./MablAction");
|
|
9
9
|
const MablSymbol_1 = require("./MablSymbol");
|
|
10
10
|
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
11
11
|
class MablStep extends MablAction_1.MablAction {
|
|
12
|
-
constructor(name, args, actions) {
|
|
13
|
-
super(name, args);
|
|
12
|
+
constructor(name, args, actions, actionCode) {
|
|
13
|
+
super(name, actionCode, args);
|
|
14
|
+
this.stepVersion = 1;
|
|
14
15
|
this.actions = actions;
|
|
15
16
|
}
|
|
17
|
+
getStepVersion() {
|
|
18
|
+
return this.stepVersion;
|
|
19
|
+
}
|
|
20
|
+
setStepId(id) {
|
|
21
|
+
this.id = id;
|
|
22
|
+
}
|
|
23
|
+
stepId() {
|
|
24
|
+
return this.id;
|
|
25
|
+
}
|
|
16
26
|
canContinueOnFailure() {
|
|
17
27
|
return false;
|
|
18
28
|
}
|
|
@@ -51,7 +61,7 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
51
61
|
return (((_a = this.annotation) === null || _a === void 0 ? void 0 : _a.description) || this.description || this.getStepName());
|
|
52
62
|
}
|
|
53
63
|
substituteMablscriptVariable(argument) {
|
|
54
|
-
if (
|
|
64
|
+
if ((0, MablSymbol_1.isMablSymbolObject)(argument)) {
|
|
55
65
|
return argument.name;
|
|
56
66
|
}
|
|
57
67
|
if ((0, MablAction_1.argumentIsMablVariable)(argument)) {
|
|
@@ -90,7 +100,11 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
90
100
|
const formatted = {};
|
|
91
101
|
formatted[this.getStepName()] =
|
|
92
102
|
this.annotationsAsYml();
|
|
93
|
-
|
|
103
|
+
const { actionCode, ...stepDescriptor } = this.toStepDescriptor(fullLocatorsOn);
|
|
104
|
+
Object.assign(formatted[this.getStepName()], stepDescriptor);
|
|
105
|
+
if (this.stepId()) {
|
|
106
|
+
formatted[this.getStepName()].id = this.stepId();
|
|
107
|
+
}
|
|
94
108
|
return formatted;
|
|
95
109
|
}
|
|
96
110
|
toMablscript() {
|
|
@@ -104,6 +118,20 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
104
118
|
};
|
|
105
119
|
return (0, fast_json_stable_stringify_1.default)(lineDiffProperties);
|
|
106
120
|
}
|
|
121
|
+
static cloneAndRemoveUndefinedEntriesFromObject(obj) {
|
|
122
|
+
const clone = {};
|
|
123
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
124
|
+
if (value !== undefined) {
|
|
125
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
126
|
+
clone[key] = value;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
clone[key] = MablStep.cloneAndRemoveUndefinedEntriesFromObject(value);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return clone;
|
|
134
|
+
}
|
|
107
135
|
}
|
|
108
136
|
exports.MablStep = MablStep;
|
|
109
137
|
MablStep.mablScriptStepNames = ['mablStep'];
|
|
@@ -150,3 +178,11 @@ function buildObjectString(objectString) {
|
|
|
150
178
|
return final;
|
|
151
179
|
}
|
|
152
180
|
exports.buildObjectString = buildObjectString;
|
|
181
|
+
function isMablStepV1(value) {
|
|
182
|
+
if (value === undefined || value === null) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const mablStep = value;
|
|
186
|
+
return !!mablStep.getStepVersion && mablStep.getStepVersion() === 1;
|
|
187
|
+
}
|
|
188
|
+
exports.isMablStepV1 = isMablStepV1;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMablStepV2 = exports.MablStepV2 = void 0;
|
|
4
|
+
const MablStep_1 = require("./MablStep");
|
|
5
|
+
class MablStepV2 extends MablStep_1.MablStep {
|
|
6
|
+
constructor(name, descriptor, actionCode) {
|
|
7
|
+
super(name, [], [], actionCode);
|
|
8
|
+
this.stepVersion = 2;
|
|
9
|
+
this.descriptor = descriptor;
|
|
10
|
+
}
|
|
11
|
+
stepId() {
|
|
12
|
+
return this.descriptor.id;
|
|
13
|
+
}
|
|
14
|
+
setStepId(id) {
|
|
15
|
+
this.descriptor.id = id;
|
|
16
|
+
}
|
|
17
|
+
static fromYaml(stepName, stepDescriptor, actionCode) {
|
|
18
|
+
return new MablStepV2(stepName, stepDescriptor, actionCode);
|
|
19
|
+
}
|
|
20
|
+
getStepName() {
|
|
21
|
+
return this.name;
|
|
22
|
+
}
|
|
23
|
+
toStepDescriptor() {
|
|
24
|
+
return this.descriptor;
|
|
25
|
+
}
|
|
26
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
27
|
+
return {
|
|
28
|
+
[this.getStepName()]: this.descriptor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
stepDescription() {
|
|
32
|
+
throw new Error('Step description not implemented');
|
|
33
|
+
}
|
|
34
|
+
isDisabled() {
|
|
35
|
+
return !!this.descriptor.disabled;
|
|
36
|
+
}
|
|
37
|
+
setDisabled(disabled) {
|
|
38
|
+
this.descriptor.disabled = disabled;
|
|
39
|
+
}
|
|
40
|
+
getDescriptionForLogging() {
|
|
41
|
+
var _a;
|
|
42
|
+
return (((_a = this.annotation) === null || _a === void 0 ? void 0 : _a.description) ||
|
|
43
|
+
this.stepDescription() ||
|
|
44
|
+
this.getStepName());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MablStepV2 = MablStepV2;
|
|
48
|
+
MablStepV2.mablScriptStepNames = [];
|
|
49
|
+
MablStepV2.yamlMablScriptNames = ['MablStepV2'];
|
|
50
|
+
function isMablStepV2(value) {
|
|
51
|
+
if (value === undefined || value === null) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const mablStep = value;
|
|
55
|
+
return !!mablStep.getStepVersion && mablStep.getStepVersion() === 2;
|
|
56
|
+
}
|
|
57
|
+
exports.isMablStepV2 = isMablStepV2;
|
package/mablscript/MablSymbol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatSymbol = exports.MablSymbol = exports.SINGLE_VARIABLE_PATTERN_REGEX = exports.VARIABLE_PATTERN_REGEX = void 0;
|
|
3
|
+
exports.isMablSymbolObject = exports.formatSymbol = exports.MablSymbol = exports.SINGLE_VARIABLE_PATTERN_REGEX = exports.VARIABLE_PATTERN_REGEX = void 0;
|
|
4
4
|
exports.VARIABLE_PATTERN_REGEX = /{{@([_.a-zA-Z0-9]+)}}/g;
|
|
5
5
|
exports.SINGLE_VARIABLE_PATTERN_REGEX = /^{{@([_.a-zA-Z0-9]+)}}$/;
|
|
6
6
|
class MablSymbol {
|
|
@@ -23,9 +23,13 @@ class MablSymbol {
|
|
|
23
23
|
}
|
|
24
24
|
exports.MablSymbol = MablSymbol;
|
|
25
25
|
function formatSymbol(symbol) {
|
|
26
|
-
if (symbol
|
|
26
|
+
if (isMablSymbolObject(symbol)) {
|
|
27
27
|
return '{{@' + symbol.name + '}}';
|
|
28
28
|
}
|
|
29
29
|
return '{{@' + symbol + '}}';
|
|
30
30
|
}
|
|
31
31
|
exports.formatSymbol = formatSymbol;
|
|
32
|
+
function isMablSymbolObject(value) {
|
|
33
|
+
return !!((value === null || value === void 0 ? void 0 : value.name) && (value === null || value === void 0 ? void 0 : value.tokens));
|
|
34
|
+
}
|
|
35
|
+
exports.isMablSymbolObject = isMablSymbolObject;
|
|
@@ -4,7 +4,7 @@ exports.AwaitDownloadAction = void 0;
|
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
class AwaitDownloadAction extends MablAction_1.MablAction {
|
|
6
6
|
constructor(name, args) {
|
|
7
|
-
super(name, args);
|
|
7
|
+
super(name, 'await_download', args);
|
|
8
8
|
}
|
|
9
9
|
toMablscript() {
|
|
10
10
|
return 'await_download()';
|
|
@@ -6,7 +6,7 @@ const MablAction_1 = require("../MablAction");
|
|
|
6
6
|
const ConditionDescriptor_1 = require("../types/ConditionDescriptor");
|
|
7
7
|
class ConditionAction extends MablAction_1.MablAction {
|
|
8
8
|
constructor(name, args) {
|
|
9
|
-
super(name, args);
|
|
9
|
+
super(name, name, args);
|
|
10
10
|
this.conditionAttribute = '';
|
|
11
11
|
this.conditionValueAttribute = '';
|
|
12
12
|
this.setConditionAttributes();
|
|
@@ -4,7 +4,7 @@ exports.CountAction = void 0;
|
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
class CountAction extends MablAction_1.MablAction {
|
|
6
6
|
constructor(name, args) {
|
|
7
|
-
super(name, args);
|
|
7
|
+
super(name, 'count', args);
|
|
8
8
|
this.countDescriptor = { count: true };
|
|
9
9
|
}
|
|
10
10
|
toMablscript() {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractAction = exports.CSS_EXTRACTION_VALUE = exports.EXTRACTION_TYPE_KEY = void 0;
|
|
3
|
+
exports.ExtractAction = exports.ExtractTypeName = exports.CSS_EXTRACTION_VALUE = exports.EXTRACTION_TYPE_KEY = void 0;
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
const ExtractDescriptor_1 = require("../types/ExtractDescriptor");
|
|
6
6
|
exports.EXTRACTION_TYPE_KEY = 'extraction_type';
|
|
7
7
|
exports.CSS_EXTRACTION_VALUE = 'css';
|
|
8
|
+
var ExtractTypeName;
|
|
9
|
+
(function (ExtractTypeName) {
|
|
10
|
+
ExtractTypeName["CssProperty"] = "CssProperty";
|
|
11
|
+
ExtractTypeName["ElementAttribute"] = "ElementAttribute";
|
|
12
|
+
ExtractTypeName["EmailAttribute"] = "EmailAttribute";
|
|
13
|
+
})(ExtractTypeName = exports.ExtractTypeName || (exports.ExtractTypeName = {}));
|
|
8
14
|
class ExtractAction extends MablAction_1.MablAction {
|
|
9
15
|
constructor(name, args) {
|
|
10
|
-
super(name, args);
|
|
16
|
+
super(name, name, args);
|
|
11
17
|
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_INNER_TEXT) {
|
|
12
18
|
this.name = ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE;
|
|
13
19
|
this.extractionAttribute = 'innerText';
|
|
@@ -18,8 +24,7 @@ class ExtractAction extends MablAction_1.MablAction {
|
|
|
18
24
|
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE && this.args.length > 1) {
|
|
19
25
|
const extractionOptions = this.args[1];
|
|
20
26
|
const metaExtractionType = extractionOptions.extraction_type;
|
|
21
|
-
if (metaExtractionType
|
|
22
|
-
metaExtractionType.toLowerCase() === exports.CSS_EXTRACTION_VALUE) {
|
|
27
|
+
if ((metaExtractionType === null || metaExtractionType === void 0 ? void 0 : metaExtractionType.toLowerCase()) === exports.CSS_EXTRACTION_VALUE) {
|
|
23
28
|
this.extractionType = ExtractDescriptor_1.ExtractType.EXTRACT_CSS_PROPERTIES.toString();
|
|
24
29
|
}
|
|
25
30
|
else {
|
|
@@ -60,7 +65,7 @@ ExtractAction.mablScriptStepNames = [
|
|
|
60
65
|
'extract_inner_text',
|
|
61
66
|
];
|
|
62
67
|
ExtractAction.mablscriptToYamlType = {
|
|
63
|
-
extract_attribute:
|
|
64
|
-
extract_css_property:
|
|
65
|
-
extract_email_attribute:
|
|
68
|
+
extract_attribute: ExtractTypeName.ElementAttribute,
|
|
69
|
+
extract_css_property: ExtractTypeName.CssProperty,
|
|
70
|
+
extract_email_attribute: ExtractTypeName.EmailAttribute,
|
|
66
71
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeEmail = exports.isEmailSelectorOrDescriptor = exports.normalize = exports.isElementSelector = exports.FindAction = exports.findTypesToFormattedType = void 0;
|
|
3
|
+
exports.normalizeEmail = exports.isEmailSelectorOrDescriptor = exports.normalize = exports.isElementSelector = exports.FindAction = exports.formattedFindTypeToMablscript = exports.findTypesToFormattedType = void 0;
|
|
4
4
|
const domUtil_1 = require("../../domUtil");
|
|
5
5
|
const mablscriptFind_1 = require("../../mablscriptFind");
|
|
6
6
|
const MablAction_1 = require("../MablAction");
|
|
@@ -14,11 +14,11 @@ exports.findTypesToFormattedType = {
|
|
|
14
14
|
find_tab: 'FindTab',
|
|
15
15
|
find_last: 'FindLast',
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
Object.entries(exports.findTypesToFormattedType).forEach(([findType, field]) => (formattedFindTypeToMablscript[field] = findType));
|
|
17
|
+
exports.formattedFindTypeToMablscript = {};
|
|
18
|
+
Object.entries(exports.findTypesToFormattedType).forEach(([findType, field]) => (exports.formattedFindTypeToMablscript[field] = findType));
|
|
19
19
|
class FindAction extends MablAction_1.MablAction {
|
|
20
20
|
constructor(name, args) {
|
|
21
|
-
super(name, args);
|
|
21
|
+
super(name, name, args);
|
|
22
22
|
const actionName = this.getActionName();
|
|
23
23
|
if (!(0, domUtil_1.isFindType)(actionName)) {
|
|
24
24
|
throw new Error(`Unknown find type for action: ${actionName}`);
|
|
@@ -114,8 +114,8 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
findType = stepArgs.findType
|
|
117
|
-
? formattedFindTypeToMablscript[stepArgs.findType]
|
|
118
|
-
: formattedFindTypeToMablscript.FindOne;
|
|
117
|
+
? exports.formattedFindTypeToMablscript[stepArgs.findType]
|
|
118
|
+
: exports.formattedFindTypeToMablscript.FindOne;
|
|
119
119
|
}
|
|
120
120
|
if (!stepArgs.selectorAncestors) {
|
|
121
121
|
return new FindAction(findType, [
|
|
@@ -4,7 +4,7 @@ exports.GenerateEmailAddressAction = void 0;
|
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
class GenerateEmailAddressAction extends MablAction_1.MablAction {
|
|
6
6
|
constructor(name, args) {
|
|
7
|
-
super(name, args);
|
|
7
|
+
super(name, 'generate_email_address', args);
|
|
8
8
|
}
|
|
9
9
|
toMablscript() {
|
|
10
10
|
return 'generate_email_address()';
|
|
@@ -5,7 +5,7 @@ const MablAction_1 = require("../MablAction");
|
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
6
|
class GenerateRandomStringAction extends MablAction_1.MablAction {
|
|
7
7
|
constructor(name, args) {
|
|
8
|
-
super(name, args);
|
|
8
|
+
super(name, 'generate_random_string', args);
|
|
9
9
|
this.generateString = this.getActionArgs()[0];
|
|
10
10
|
}
|
|
11
11
|
toMablscript() {
|
|
@@ -5,7 +5,7 @@ const MablAction_1 = require("../MablAction");
|
|
|
5
5
|
const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
|
|
6
6
|
class GetUrlAction extends MablAction_1.MablAction {
|
|
7
7
|
constructor(name, args) {
|
|
8
|
-
super(name, args);
|
|
8
|
+
super(name, 'get_current_location', args);
|
|
9
9
|
}
|
|
10
10
|
toMablscript() {
|
|
11
11
|
return `get_current_location()`;
|
|
@@ -6,7 +6,7 @@ const MablSymbol_1 = require("../MablSymbol");
|
|
|
6
6
|
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
7
7
|
class GetVariableValue extends MablAction_1.MablAction {
|
|
8
8
|
constructor(name, args) {
|
|
9
|
-
super(name, args);
|
|
9
|
+
super(name, 'get_variable_value', args);
|
|
10
10
|
const arg = this.getActionArgs()[0];
|
|
11
11
|
if (typeof arg !== 'string') {
|
|
12
12
|
throw new Error('Expected string argument');
|
|
@@ -23,7 +23,7 @@ function isSnippetOptions(value) {
|
|
|
23
23
|
}
|
|
24
24
|
class JavaScriptAction extends MablAction_1.MablAction {
|
|
25
25
|
constructor(name, args) {
|
|
26
|
-
super(name, args);
|
|
26
|
+
super(name, MABLSCRIPT_NAME, args);
|
|
27
27
|
if (args.length < 1 || args.length > 2) {
|
|
28
28
|
throw new Error('EvaluateJS action expects 1 or 2 arguments');
|
|
29
29
|
}
|
|
@@ -36,12 +36,14 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
36
36
|
if (typeof scriptOrSnippetReference === 'string') {
|
|
37
37
|
this.javaScript = {
|
|
38
38
|
encodedJS: scriptOrSnippetReference,
|
|
39
|
+
actionCode: MABLSCRIPT_NAME,
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
else if (isLegacySnippetReference(scriptOrSnippetReference)) {
|
|
42
43
|
const { id } = scriptOrSnippetReference;
|
|
43
44
|
this.javaScript = {
|
|
44
45
|
snippetInvariantId: id,
|
|
46
|
+
actionCode: MABLSCRIPT_NAME,
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
else if (isReusableSnippetReference(scriptOrSnippetReference)) {
|
|
@@ -50,6 +52,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
50
52
|
snippetId: id,
|
|
51
53
|
snippetInvariantId: invariant_id,
|
|
52
54
|
parameterOverrides: [],
|
|
55
|
+
actionCode: MABLSCRIPT_NAME,
|
|
53
56
|
};
|
|
54
57
|
const snippetOptions = args[1];
|
|
55
58
|
if (isSnippetOptions(snippetOptions)) {
|
|
@@ -60,6 +63,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
60
63
|
this.javaScript = {
|
|
61
64
|
inlineSnippet: scriptOrSnippetReference,
|
|
62
65
|
parameterOverrides: [],
|
|
66
|
+
actionCode: MABLSCRIPT_NAME,
|
|
63
67
|
};
|
|
64
68
|
const snippetOptions = args[1];
|
|
65
69
|
if (isSnippetOptions(snippetOptions)) {
|
|
@@ -71,7 +75,7 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
toDescriptor() {
|
|
74
|
-
return { javaScript: this.javaScript };
|
|
78
|
+
return { javaScript: this.javaScript, actionCode: this.actionCode };
|
|
75
79
|
}
|
|
76
80
|
static fromDescriptor(descriptor) {
|
|
77
81
|
const { javaScript } = descriptor;
|
|
@@ -105,24 +109,27 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
105
109
|
throw new Error(`Invalid javascript action descriptor: ${JSON.stringify(descriptor)}`);
|
|
106
110
|
}
|
|
107
111
|
toYaml() {
|
|
112
|
+
return JavaScriptAction.toYamlFromJavaScriptDescriptor(this.javaScript);
|
|
113
|
+
}
|
|
114
|
+
static toYamlFromJavaScriptDescriptor(javaScript) {
|
|
108
115
|
const actionYaml = {};
|
|
109
|
-
if ((0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(
|
|
110
|
-
actionYaml.snippetId =
|
|
111
|
-
actionYaml.snippetInvariantId =
|
|
112
|
-
actionYaml.parameterOverrides =
|
|
116
|
+
if ((0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(javaScript)) {
|
|
117
|
+
actionYaml.snippetId = javaScript.snippetId;
|
|
118
|
+
actionYaml.snippetInvariantId = javaScript.snippetInvariantId;
|
|
119
|
+
actionYaml.parameterOverrides = javaScript.parameterOverrides;
|
|
113
120
|
}
|
|
114
|
-
else if ((0, JavaScriptDescriptor_1.isInlineSnippetDescriptor)(
|
|
115
|
-
actionYaml.snippet =
|
|
116
|
-
actionYaml.parameterOverrides =
|
|
121
|
+
else if ((0, JavaScriptDescriptor_1.isInlineSnippetDescriptor)(javaScript)) {
|
|
122
|
+
actionYaml.snippet = { ...actionYaml, ...javaScript.inlineSnippet };
|
|
123
|
+
actionYaml.parameterOverrides = javaScript.parameterOverrides;
|
|
117
124
|
}
|
|
118
|
-
else if ((0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(
|
|
119
|
-
actionYaml.snippetId =
|
|
125
|
+
else if ((0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(javaScript)) {
|
|
126
|
+
actionYaml.snippetId = javaScript.snippetInvariantId;
|
|
120
127
|
}
|
|
121
|
-
else if ((0, JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor)(
|
|
122
|
-
actionYaml.code =
|
|
128
|
+
else if ((0, JavaScriptDescriptor_1.isLegacyInlineJavaScriptDescriptor)(javaScript)) {
|
|
129
|
+
actionYaml.code = javaScript.encodedJS;
|
|
123
130
|
}
|
|
124
131
|
else {
|
|
125
|
-
throw new Error(`Cannot export action to yaml: ${JSON.stringify(
|
|
132
|
+
throw new Error(`Cannot export action to yaml: ${JSON.stringify(javaScript)}`);
|
|
126
133
|
}
|
|
127
134
|
return actionYaml;
|
|
128
135
|
}
|
|
@@ -137,6 +144,10 @@ class JavaScriptAction extends MablAction_1.MablAction {
|
|
|
137
144
|
if (formatted.code) {
|
|
138
145
|
args.push(formatted.code);
|
|
139
146
|
}
|
|
147
|
+
else if (formatted.body) {
|
|
148
|
+
delete formatted.parameterOverrides;
|
|
149
|
+
args.push(formatted);
|
|
150
|
+
}
|
|
140
151
|
else if (formatted.snippet) {
|
|
141
152
|
args.push(formatted.snippet);
|
|
142
153
|
}
|
package/mablscript/importer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractOutputVariables = exports.extractInputVariables = exports.parseMablScriptIntoSteps = exports.mablscriptTheLoadedSteps = exports.loadYamlSteps = exports.yamlifyTheLoadedSteps = exports.loadMablScriptIntoSteps = exports.parseMablScript = void 0;
|
|
3
|
+
exports.getSnippetIdsFromJsonFlow = exports.parseMablScriptIntoV2Step = exports.extractOutputVariables = exports.extractInputVariables = exports.parseMablScriptIntoSteps = exports.mablscriptTheLoadedSteps = exports.interpretStepsFromObjects = exports.loadYamlSteps = exports.yamlifyTheLoadedSteps = exports.loadMablScriptIntoSteps = exports.parseMablScript = void 0;
|
|
4
4
|
const esprima_1 = require("esprima");
|
|
5
5
|
const estraverse_1 = require("estraverse");
|
|
6
6
|
const AssertStep_1 = require("./steps/AssertStep");
|
|
@@ -53,6 +53,16 @@ const AccessibilityCheck_1 = require("./steps/AccessibilityCheck");
|
|
|
53
53
|
const EvaluateFlowStep_1 = require("./steps/EvaluateFlowStep");
|
|
54
54
|
const RightClickStep_1 = require("./steps/RightClickStep");
|
|
55
55
|
const EnterAuthCodeStep_1 = require("./steps/EnterAuthCodeStep");
|
|
56
|
+
const TapStep_1 = require("./mobile/steps/TapStep");
|
|
57
|
+
const EnterTextStep_2 = require("./mobile/steps/EnterTextStep");
|
|
58
|
+
const SetOrientationStep_1 = require("./mobile/steps/SetOrientationStep");
|
|
59
|
+
const ScrollStep_1 = require("./mobile/steps/ScrollStep");
|
|
60
|
+
const CreateVariableMobileStep_1 = require("./mobile/steps/CreateVariableMobileStep");
|
|
61
|
+
const NavigateBackStep_1 = require("./mobile/steps/NavigateBackStep");
|
|
62
|
+
const NavigateHomeStep_1 = require("./mobile/steps/NavigateHomeStep");
|
|
63
|
+
const CreateVariableStepDescriptor_1 = require("./types/CreateVariableStepDescriptor");
|
|
64
|
+
const JavaScriptDescriptor_1 = require("./types/JavaScriptDescriptor");
|
|
65
|
+
const MablStepV2_1 = require("./MablStepV2");
|
|
56
66
|
const ActionTypes = [
|
|
57
67
|
AwaitDownloadAction_1.AwaitDownloadAction,
|
|
58
68
|
AwaitPDFDownloadAction_1.AwaitPDFDownloadAction,
|
|
@@ -103,6 +113,16 @@ const StepTypes = [
|
|
|
103
113
|
VisitUrlStep_1.VisitUrlStep,
|
|
104
114
|
WaitStep_1.WaitStep,
|
|
105
115
|
];
|
|
116
|
+
const MobileStepTypes = [
|
|
117
|
+
AssertStep_1.AssertStep,
|
|
118
|
+
CreateVariableMobileStep_1.CreateVariableMobileStep,
|
|
119
|
+
NavigateBackStep_1.NavigateBackStep,
|
|
120
|
+
NavigateHomeStep_1.NavigateHomeStep,
|
|
121
|
+
TapStep_1.TapStep,
|
|
122
|
+
EnterTextStep_2.EnterTextStep,
|
|
123
|
+
SetOrientationStep_1.SetOrientationStep,
|
|
124
|
+
ScrollStep_1.ScrollStep,
|
|
125
|
+
];
|
|
106
126
|
function parseMablScript(mablscript) {
|
|
107
127
|
const ast = (0, esprima_1.parseScript)(mablscript, { loc: true });
|
|
108
128
|
const stepStack = {};
|
|
@@ -151,13 +171,13 @@ function loadMablScriptIntoSteps(parsedMablscript) {
|
|
|
151
171
|
const actionType = rawMablscriptToObjectsActionsMap[parsedAction.name];
|
|
152
172
|
const action = actionType
|
|
153
173
|
? new actionType(parsedAction.name, parsedAction.arguments)
|
|
154
|
-
: new MablAction_1.MablAction(parsedAction.name, parsedAction.arguments);
|
|
174
|
+
: new MablAction_1.MablAction(parsedAction.name, parsedAction.name, parsedAction.arguments);
|
|
155
175
|
action.setActionSourceIndexInStep(actionIndex);
|
|
156
176
|
return action;
|
|
157
177
|
});
|
|
158
178
|
let step = stepType
|
|
159
179
|
? new stepType(lastAction.name, lastAction.arguments, actions)
|
|
160
|
-
: new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions);
|
|
180
|
+
: new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions, lastAction.name);
|
|
161
181
|
if (step instanceof AssertStepOld_1.AssertStepOld) {
|
|
162
182
|
step = step.getNewAssertionStep();
|
|
163
183
|
}
|
|
@@ -172,31 +192,50 @@ function yamlifyTheLoadedSteps(translatedSteps, fullLocatorsOn = true) {
|
|
|
172
192
|
return (0, js_yaml_1.dump)(steps);
|
|
173
193
|
}
|
|
174
194
|
exports.yamlifyTheLoadedSteps = yamlifyTheLoadedSteps;
|
|
175
|
-
const
|
|
195
|
+
const yamlMablscriptToObjectsStepV1Map = {};
|
|
176
196
|
StepTypes.forEach((step) => {
|
|
177
|
-
step.yamlMablScriptNames.forEach((name) => (
|
|
197
|
+
step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsStepV1Map[name] = step.fromYaml));
|
|
178
198
|
});
|
|
179
|
-
|
|
199
|
+
const yamlMablscriptToObjectsMobileStepMap = {};
|
|
200
|
+
MobileStepTypes.forEach((step) => {
|
|
201
|
+
step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsMobileStepMap[name] = step.fromYaml));
|
|
202
|
+
});
|
|
203
|
+
function loadYamlSteps(yamlSteps, isMobile) {
|
|
180
204
|
const loadedStepData = (0, js_yaml_1.load)(yamlSteps);
|
|
181
|
-
return loadedStepData
|
|
205
|
+
return interpretStepsFromObjects(loadedStepData, isMobile);
|
|
206
|
+
}
|
|
207
|
+
exports.loadYamlSteps = loadYamlSteps;
|
|
208
|
+
function interpretStepsFromObjects(steps, isMobile) {
|
|
209
|
+
return steps.map((stepObject, index) => {
|
|
210
|
+
var _a;
|
|
182
211
|
const stepName = Object.keys(stepObject)[0];
|
|
183
212
|
const stepArgs = stepObject[stepName];
|
|
184
213
|
const isStepDisabled = stepObject[stepName].disabled;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
214
|
+
const step = stepFromObjectInfo(stepName, stepArgs, isMobile !== null && isMobile !== void 0 ? isMobile : false);
|
|
215
|
+
step.setStepSourceIndexInFlow(index);
|
|
216
|
+
const actionCount = step.actions.length;
|
|
217
|
+
(_a = step.actions) === null || _a === void 0 ? void 0 : _a.forEach((action, index) => {
|
|
218
|
+
if ((0, MablStepV2_1.isMablStepV2)(step) || index + 1 !== actionCount) {
|
|
219
|
+
action.setActionSourceIndexInStep(index);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
193
222
|
if (isStepDisabled) {
|
|
194
223
|
step.setDisabled(isStepDisabled);
|
|
195
224
|
}
|
|
196
225
|
return step;
|
|
197
226
|
});
|
|
198
227
|
}
|
|
199
|
-
exports.
|
|
228
|
+
exports.interpretStepsFromObjects = interpretStepsFromObjects;
|
|
229
|
+
function stepFromObjectInfo(stepName, stepArgs, isMobile) {
|
|
230
|
+
if (isMobile &&
|
|
231
|
+
Object.keys(yamlMablscriptToObjectsMobileStepMap).includes(stepName)) {
|
|
232
|
+
return yamlMablscriptToObjectsMobileStepMap[stepName](stepName, stepArgs);
|
|
233
|
+
}
|
|
234
|
+
if (Object.keys(yamlMablscriptToObjectsStepV1Map).includes(stepName)) {
|
|
235
|
+
return yamlMablscriptToObjectsStepV1Map[stepName](stepName, stepArgs);
|
|
236
|
+
}
|
|
237
|
+
return new MablStep_1.MablStep(stepName, [], [], stepName);
|
|
238
|
+
}
|
|
200
239
|
function getMablscriptMaybeWithComment(step) {
|
|
201
240
|
return `${step.isDisabled() ? '//' : ''}${step.toMablscript()}`;
|
|
202
241
|
}
|
|
@@ -389,3 +428,47 @@ function extractOutputVariables(steps) {
|
|
|
389
428
|
return (0, MablAction_1.distinctStrings)(steps.flatMap((step) => step.getOutputVariables()));
|
|
390
429
|
}
|
|
391
430
|
exports.extractOutputVariables = extractOutputVariables;
|
|
431
|
+
function parseMablScriptIntoV2Step(script) {
|
|
432
|
+
if (!script) {
|
|
433
|
+
throw new Error('Unable to parse step with invalid script');
|
|
434
|
+
}
|
|
435
|
+
const parsedMablscriptStep = parseMablScriptIntoSteps({
|
|
436
|
+
script,
|
|
437
|
+
});
|
|
438
|
+
const stepAsObject = parsedMablscriptStep[0].getFormattedStep(true);
|
|
439
|
+
const [parsedStep] = interpretStepsFromObjects([stepAsObject], true);
|
|
440
|
+
return parsedStep;
|
|
441
|
+
}
|
|
442
|
+
exports.parseMablScriptIntoV2Step = parseMablScriptIntoV2Step;
|
|
443
|
+
function getSnippetIdsFromJsonFlow(flow) {
|
|
444
|
+
const steps = interpretStepsFromObjects(flow.json_steps.steps, true);
|
|
445
|
+
const snippetIds = [];
|
|
446
|
+
steps.forEach((step) => {
|
|
447
|
+
let jsDescriptor;
|
|
448
|
+
if ((0, EvaluateJavaScriptStep_1.isEvaluateJavaScriptStep)(step)) {
|
|
449
|
+
jsDescriptor = step.evaluateJsAction.javaScript;
|
|
450
|
+
}
|
|
451
|
+
else if ((0, IfConditionStep_1.isIfConditionStep)(step) || (0, ElseIfConditionStep_1.isElseIfConditionStep)(step)) {
|
|
452
|
+
if ((0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.primaryAction)) {
|
|
453
|
+
jsDescriptor = step.primaryAction.javaScript;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else if ((0, CreateVariableStep_1.isCreateVariableStep)(step)) {
|
|
457
|
+
if (step.generationType === CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT &&
|
|
458
|
+
(0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.actions[0])) {
|
|
459
|
+
jsDescriptor = step.actions[0].javaScript;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
else if ((0, CreateVariableMobileStep_1.isCreateVariableMobileStep)(step)) {
|
|
463
|
+
if ((0, JavaScriptAction_1.isJavaScriptActionDescriptor)(step.descriptor.generator)) {
|
|
464
|
+
jsDescriptor = step.descriptor.generator.javaScript;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if ((jsDescriptor && (0, JavaScriptDescriptor_1.isReusableSnippetDescriptor)(jsDescriptor)) ||
|
|
468
|
+
(0, JavaScriptDescriptor_1.isLegacyReusableSnippetDescriptor)(jsDescriptor)) {
|
|
469
|
+
snippetIds.push(jsDescriptor.snippetInvariantId);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return snippetIds;
|
|
473
|
+
}
|
|
474
|
+
exports.getSnippetIdsFromJsonFlow = getSnippetIdsFromJsonFlow;
|