@mablhq/mabl-cli 1.16.32 → 1.18.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 +9 -4
- package/api/featureSet.js +1 -4
- package/api/mablApiClient.js +16 -9
- package/browserLauncher/browserLauncherFactory.js +4 -4
- package/browserLauncher/elementHandle.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +8 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +11 -9
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +23 -29
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +28 -6
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +5 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +13 -9
- package/browserLauncher/runnerType.js +0 -1
- package/cli.js +12 -8
- package/commands/applications/applications_cmds/describe.js +4 -4
- package/commands/applications/applications_cmds/list.js +4 -4
- package/commands/auth/auth_cmds/activate-key.js +1 -1
- package/commands/branches/branches_cmds/create.js +4 -4
- package/commands/branches/branches_cmds/describe.js +3 -3
- package/commands/branches/branches_cmds/list.js +3 -3
- package/commands/branches/branches_cmds/merge.js +4 -4
- package/commands/commandUtil/codeInsights.js +4 -2
- package/commands/commandUtil/describe.js +1 -1
- package/commands/commandUtil/fileUtil.js +5 -1
- package/commands/commandUtil/util.js +2 -2
- package/commands/config/config_cmds/delete.js +1 -1
- package/commands/config/config_cmds/set.js +1 -1
- package/commands/constants.js +3 -1
- package/commands/credentials/credentials_cmds/list.js +4 -4
- package/commands/deploy/deploy_cmds/create.js +18 -13
- package/commands/deploy/deploy_cmds/describe.js +5 -5
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +1 -1
- package/commands/deploy/deploy_cmds/list.js +4 -4
- package/commands/deploy/deploy_cmds/watch.js +2 -2
- package/commands/environments/environments_cmds/create.js +7 -7
- package/commands/environments/environments_cmds/delete.js +1 -1
- package/commands/environments/environments_cmds/describe.js +4 -4
- package/commands/environments/environments_cmds/list.js +4 -4
- package/commands/environments/environments_cmds/update.js +2 -2
- package/commands/environments/environments_cmds/urls_cmds/add.js +3 -3
- package/commands/environments/environments_cmds/urls_cmds/list.js +2 -2
- package/commands/flows/flows_cmds/export.js +5 -5
- package/commands/flows/flows_cmds/list.js +2 -2
- package/commands/link-agents/link-agents_cmds/delete.js +1 -1
- package/commands/plans/plans_cmds/describe.js +4 -4
- package/commands/plans/plans_cmds/list.js +2 -2
- package/commands/test-runs/test-runs_cmds/export.js +2 -2
- package/commands/tests/executionUtil.js +5 -5
- package/commands/tests/testsUtil.js +30 -18
- package/commands/tests/tests_cmds/create.js +3 -3
- package/commands/tests/tests_cmds/edit.js +3 -3
- package/commands/tests/tests_cmds/export.js +7 -7
- package/commands/tests/tests_cmds/import.js +35 -14
- package/commands/tests/tests_cmds/list.js +3 -3
- package/commands/tests/tests_cmds/run-alpha.js +3 -3
- package/commands/tests/tests_cmds/run-cloud.js +4 -4
- package/commands/tests/tests_cmds/run-legacy.js +8 -8
- package/commands/tests/tests_cmds/run.js +13 -8
- package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +2 -2
- package/commands/tests/tests_cmds/trainer_cmds/update.js +1 -1
- package/commands/tests/tests_cmds/trainer_cmds/version.js +2 -2
- package/commands/workspaces/workspace_cmds/copy.js +2 -2
- package/commands/workspaces/workspace_cmds/describe.js +4 -4
- package/commands/workspaces/workspace_cmds/list.js +2 -2
- package/configGenerators/flowConfigGenerator.js +1 -1
- package/configGenerators/selIdeGenerator.js +6 -6
- package/core/messaging/actions/runnerActions.js +2 -2
- package/core/trainer/openUtils.js +2 -2
- package/core/trainer/trainingSessions.js +26 -26
- package/domUtil/index.js +1 -1
- package/domUtil/index.js.LICENSE.txt +5 -5
- package/env/env.js +5 -1
- package/execution/index.js +1 -1
- package/execution/index.js.LICENSE.txt +7 -5
- package/index.d.ts +0 -1
- package/mablApi/index.js +1 -1
- package/mablscript/AttributesConstants.js +2 -1
- package/mablscript/MablAction.js +1 -1
- package/mablscript/MablStep.js +26 -14
- package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
- package/mablscript/actions/ConditionAction.js +12 -4
- package/mablscript/actions/ExtractAction.js +16 -7
- package/mablscript/actions/FindAction.js +105 -80
- package/mablscript/actions/GenerateRandomStringAction.js +2 -1
- package/mablscript/actions/GetUrlAction.js +2 -2
- package/mablscript/actions/GetVariableValue.js +3 -3
- package/mablscript/actions/JavaScriptAction.js +16 -16
- package/mablscript/diffing/diffingUtil.js +146 -0
- package/mablscript/importer.js +26 -8
- package/mablscript/steps/AccessibilityCheck.js +9 -7
- package/mablscript/steps/AssertStep.js +60 -46
- package/mablscript/steps/AssertStepOld.js +41 -23
- package/mablscript/steps/AwaitTabStep.js +7 -6
- package/mablscript/steps/ClickAndHoldStep.js +6 -6
- package/mablscript/steps/ClickStep.js +6 -6
- package/mablscript/steps/CreateVariableStep.js +8 -8
- package/mablscript/steps/DoubleClickStep.js +7 -7
- package/mablscript/steps/DownloadStep.js +3 -2
- package/mablscript/steps/EchoStep.js +5 -3
- package/mablscript/steps/ElseIfConditionStep.js +5 -2
- package/mablscript/steps/EnterTextStep.js +13 -10
- package/mablscript/steps/EvaluateFlowStep.js +40 -0
- package/mablscript/steps/HoverStep.js +6 -6
- package/mablscript/steps/IfConditionStep.js +8 -7
- package/mablscript/steps/NavigateStep.js +1 -1
- 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 +9 -9
- package/mablscript/steps/SetCookieStep.js +2 -4
- package/mablscript/steps/SetFilesStep.js +5 -5
- package/mablscript/steps/SetViewportStep.js +2 -2
- package/mablscript/steps/SwitchContextStep.js +12 -12
- package/mablscript/steps/VisitUrlStep.js +3 -2
- package/mablscript/steps/WaitStep.js +2 -5
- 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/mablscript/types/OperatingSystemDescriptor.js +5 -1
- package/mablscript/types/VariableNamespace.js +1 -1
- package/mablscriptFind/index.js +1 -1
- package/mablscriptFind/index.js.LICENSE.txt +5 -5
- package/observers/mockObserver.js +4 -2
- package/package.json +55 -56
- package/popupDismissal/index.js +3 -3
- package/providers/authenticationProvider.js +3 -3
- package/providers/logging/loggingProvider.js +5 -1
- package/proxy/index.js +2 -1
- package/proxy/index.js.LICENSE.txt +5 -0
- package/reporters/mochAwesome/mochAwesomeReporter.js +11 -7
- package/reporters/reporter.js +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/pdf-viewer/index.js +1 -1
- package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
- package/resources/popupDismissal.js +1 -1
- package/util/RichPromise.js +1 -0
- package/util/actionabilityUtil.js +16 -35
- package/util/analytics.js +7 -3
- package/util/downloadUtil.js +6 -2
- package/util/httpUtil.js +6 -2
- package/util/markdownUtil.js +1 -1
- package/util/pureUtil.js +5 -1
- package/util/resourceUtil.js +5 -1
- 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 -331
- package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
|
@@ -107,7 +107,8 @@ exports.ALLOWED_ASSERTABLE_URL_ATTRS_PROPS = [
|
|
|
107
107
|
'username',
|
|
108
108
|
];
|
|
109
109
|
const ALLOWED_ASSERTABLE_URL_ATTRS_PROPS_SET = new Set(exports.ALLOWED_ASSERTABLE_URL_ATTRS_PROPS);
|
|
110
|
-
|
|
110
|
+
const isAllowedAssertableUrlAttrProps = (x) => ALLOWED_ASSERTABLE_URL_ATTRS_PROPS_SET.has(x);
|
|
111
|
+
exports.isAllowedAssertableUrlAttrProps = isAllowedAssertableUrlAttrProps;
|
|
111
112
|
exports.ALLOWED_ASSERTABLE_EMAIL_ATTRS_PROPS = [
|
|
112
113
|
'from',
|
|
113
114
|
'subject',
|
package/mablscript/MablAction.js
CHANGED
package/mablscript/MablStep.js
CHANGED
|
@@ -1,9 +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");
|
|
10
|
+
const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
|
|
11
|
+
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
7
12
|
class MablStep extends MablAction_1.MablAction {
|
|
8
13
|
constructor(name, args, actions) {
|
|
9
14
|
super(name, args);
|
|
@@ -24,9 +29,15 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
24
29
|
setAnnotation(annotation) {
|
|
25
30
|
this.annotation = annotation;
|
|
26
31
|
}
|
|
32
|
+
getAnnotation() {
|
|
33
|
+
return this.annotation;
|
|
34
|
+
}
|
|
27
35
|
setDescription(description) {
|
|
28
36
|
this.description = description;
|
|
29
37
|
}
|
|
38
|
+
getDescription() {
|
|
39
|
+
return this.description;
|
|
40
|
+
}
|
|
30
41
|
setStepSourceIndexInFlow(index) {
|
|
31
42
|
this.stepSourceIndexInFlow = index;
|
|
32
43
|
}
|
|
@@ -37,7 +48,7 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
37
48
|
if (argument instanceof MablSymbol_1.MablSymbol) {
|
|
38
49
|
return argument.name;
|
|
39
50
|
}
|
|
40
|
-
if (MablAction_1.argumentIsMablVariable(argument)) {
|
|
51
|
+
if ((0, MablAction_1.argumentIsMablVariable)(argument)) {
|
|
41
52
|
const matches = argument.match(MablSymbol_1.SINGLE_VARIABLE_PATTERN_REGEX);
|
|
42
53
|
if (matches) {
|
|
43
54
|
return matches[1];
|
|
@@ -83,7 +94,7 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
83
94
|
return formatted;
|
|
84
95
|
}
|
|
85
96
|
produceSelIdeFormattedSteps(_stepIndex) {
|
|
86
|
-
const selIdeEcho = SeleniumIdeStep_1.buildSeleniumIdeStep('echo');
|
|
97
|
+
const selIdeEcho = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo');
|
|
87
98
|
const unSupportedStepMessage = `[${this.getStepName()}] Step is not supported for Selenium IDE export`;
|
|
88
99
|
selIdeEcho.comment = unSupportedStepMessage;
|
|
89
100
|
selIdeEcho.target = unSupportedStepMessage;
|
|
@@ -101,7 +112,7 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
101
112
|
case 'number':
|
|
102
113
|
return `${key}: ${objectArgs[key]}`;
|
|
103
114
|
default:
|
|
104
|
-
return `${key}: "${objectArgs[key]}"`;
|
|
115
|
+
return `${key}: "${(0, domUtil_1.escapeMablscriptString)(objectArgs[key])}"`;
|
|
105
116
|
}
|
|
106
117
|
});
|
|
107
118
|
return `{${mablArgs.join(', ')}}`;
|
|
@@ -109,6 +120,14 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
109
120
|
toMablscript() {
|
|
110
121
|
return '';
|
|
111
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
|
+
}
|
|
112
131
|
}
|
|
113
132
|
exports.MablStep = MablStep;
|
|
114
133
|
MablStep.mablScriptStepNames = ['mablStep'];
|
|
@@ -124,7 +143,7 @@ function buildSourceRepresentationOfObject(object) {
|
|
|
124
143
|
if (typeof value === 'number') {
|
|
125
144
|
return `${key}: ${value}`;
|
|
126
145
|
}
|
|
127
|
-
return `${key}: "${escapeMablscriptString(value)}"`;
|
|
146
|
+
return `${key}: "${(0, domUtil_1.escapeMablscriptString)(value)}"`;
|
|
128
147
|
}
|
|
129
148
|
return `${key}: ${buildSourceRepresentationOfObject(value)}`;
|
|
130
149
|
});
|
|
@@ -140,14 +159,14 @@ function buildObjectString(objectString) {
|
|
|
140
159
|
return final;
|
|
141
160
|
}
|
|
142
161
|
if (typeof objectString[key] === 'string') {
|
|
143
|
-
return final.push(`${key}: "${escapeMablscriptString(objectString[key])}"`);
|
|
162
|
+
return final.push(`${key}: "${(0, domUtil_1.escapeMablscriptString)(objectString[key])}"`);
|
|
144
163
|
}
|
|
145
164
|
else if (typeof objectString[key] === 'number') {
|
|
146
165
|
return final.push(`${key}: ${objectString[key]}`);
|
|
147
166
|
}
|
|
148
167
|
else if (Array.isArray(objectString[key])) {
|
|
149
168
|
return final.push(`"${key}": [${objectString[key]
|
|
150
|
-
.map((arrayVal) => `"${escapeMablscriptString(arrayVal)}"`)
|
|
169
|
+
.map((arrayVal) => `"${(0, domUtil_1.escapeMablscriptString)(arrayVal)}"`)
|
|
151
170
|
.join(', ')}]`);
|
|
152
171
|
}
|
|
153
172
|
return final.push(`${key}: {${buildObjectString(objectString[key])}}`);
|
|
@@ -155,10 +174,3 @@ function buildObjectString(objectString) {
|
|
|
155
174
|
return final;
|
|
156
175
|
}
|
|
157
176
|
exports.buildObjectString = buildObjectString;
|
|
158
|
-
function escapeMablscriptString(unescapedString) {
|
|
159
|
-
return unescapedString
|
|
160
|
-
.replace(/\\/g, '\\\\')
|
|
161
|
-
.replace(/\n/g, '\\n')
|
|
162
|
-
.replace(/"/g, '\\"')
|
|
163
|
-
.replace(/\r/g, '');
|
|
164
|
-
}
|
|
@@ -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 {
|
|
@@ -35,7 +36,7 @@ class ConditionAction extends MablAction_1.MablAction {
|
|
|
35
36
|
return {
|
|
36
37
|
conditionType: ConditionDescriptor_1.ConditionType.Comparison,
|
|
37
38
|
comparisonType: ConditionDescriptor_1.ComparisonType.fromString(this.conditionAttribute),
|
|
38
|
-
comparatorValue: MablAction_1.parseArgument(this.conditionValueAttribute),
|
|
39
|
+
comparatorValue: (0, MablAction_1.parseArgument)(this.conditionValueAttribute),
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
getEvaluatePresence() {
|
|
@@ -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 (!
|
|
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 (
|
|
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,61 +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 (
|
|
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
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
']'
|
|
173
|
-
: buildElementSelectorString(find.findTarget.selector);
|
|
182
|
+
const selectors = ((_a = find.findTarget.auxiliaryDescriptors) === null || _a === void 0 ? void 0 : _a.length)
|
|
183
|
+
? '[' +
|
|
184
|
+
[find.findTarget, ...find.findTarget.auxiliaryDescriptors]
|
|
185
|
+
.map(mablscriptFind_1.buildFindDescriptorString)
|
|
186
|
+
.filter(Boolean)
|
|
187
|
+
.join(', ') +
|
|
188
|
+
']'
|
|
189
|
+
: (0, mablscriptFind_1.buildFindDescriptorString)(find.findTarget);
|
|
174
190
|
const options = buildFindOptionsString(find.findOptions);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
case
|
|
179
|
-
case
|
|
180
|
-
case
|
|
181
|
-
case mablscriptFind_1.FindType.FIND_ALL:
|
|
182
|
-
case mablscriptFind_1.FindType.FIND_COOKIE:
|
|
183
|
-
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: {
|
|
184
197
|
const find = this.findDescriptor;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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)}`;
|
|
218
|
+
}
|
|
219
|
+
if (find.findType === domUtil_1.FindType.FIND_ANY) {
|
|
220
|
+
action = domUtil_1.FindType.FIND_FIRST;
|
|
192
221
|
}
|
|
193
|
-
|
|
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;
|
|
194
234
|
default:
|
|
195
235
|
throw new Error(`Error generating mablscript: Unexpected find type in ${JSON.stringify(this.findDescriptor)}`);
|
|
196
236
|
}
|
|
237
|
+
return `${action}(${args})`;
|
|
197
238
|
}
|
|
198
239
|
isValidDescriptor() {
|
|
199
240
|
return this.isValid;
|
|
@@ -224,37 +265,21 @@ function buildFindOptionsString(findOptions) {
|
|
|
224
265
|
if (!findOptions) {
|
|
225
266
|
return '';
|
|
226
267
|
}
|
|
227
|
-
|
|
228
|
-
if (findOptions.hints) {
|
|
229
|
-
findOptionsFinal += `hints: {${MablStep_1.buildObjectString(findOptions.hints).join(', ')}}`;
|
|
230
|
-
}
|
|
231
|
-
if (findOptions.waitUntil) {
|
|
232
|
-
findOptionsFinal += `waitUntil: {${MablStep_1.buildObjectString(findOptions.waitUntil)}}`;
|
|
233
|
-
}
|
|
234
|
-
findOptionsFinal += '}';
|
|
235
|
-
return findOptionsFinal;
|
|
236
|
-
}
|
|
237
|
-
function buildElementSelectorString(selectorObject) {
|
|
238
|
-
const findInfoList = MablStep_1.buildObjectString(selectorObject);
|
|
239
|
-
if (!findInfoList.find((info) => info.includes('selector_type'))) {
|
|
240
|
-
findInfoList.push('selector_type: "element"');
|
|
241
|
-
}
|
|
242
|
-
findInfoList.sort();
|
|
243
|
-
return `{${findInfoList.join(', ')}}`;
|
|
268
|
+
return JSON.stringify(findOptions);
|
|
244
269
|
}
|
|
245
270
|
function isElementSelector(maybeSelectors) {
|
|
246
271
|
const [target, ancestor] = Array.isArray(maybeSelectors)
|
|
247
272
|
? [...maybeSelectors]
|
|
248
273
|
: [maybeSelectors];
|
|
249
|
-
const validTarget =
|
|
274
|
+
const validTarget = (0, domUtil_1.isStandardSelector)(target) || (0, domUtil_1.isNormalizedFindDescriptor)(target);
|
|
250
275
|
const validAncestor = !ancestor ||
|
|
251
|
-
|
|
252
|
-
|
|
276
|
+
(0, domUtil_1.isStandardSelector)(ancestor) ||
|
|
277
|
+
(0, domUtil_1.isNormalizedFindDescriptor)(ancestor);
|
|
253
278
|
return !!(validTarget && validAncestor);
|
|
254
279
|
}
|
|
255
280
|
exports.isElementSelector = isElementSelector;
|
|
256
281
|
function normalize(maybeFindDescriptor) {
|
|
257
|
-
if (
|
|
282
|
+
if ((0, domUtil_1.isNormalizedFindDescriptor)(maybeFindDescriptor)) {
|
|
258
283
|
return { ...maybeFindDescriptor };
|
|
259
284
|
}
|
|
260
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;
|
|
@@ -11,9 +11,9 @@ class GetUrlAction extends MablAction_1.MablAction {
|
|
|
11
11
|
return `get_current_location()`;
|
|
12
12
|
}
|
|
13
13
|
toDescriptor() {
|
|
14
|
-
return GetCurrentLocationDescriptor_1.newGetCurrentLocationDescriptor();
|
|
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);
|
|
@@ -17,9 +17,9 @@ class GetVariableValue extends MablAction_1.MablAction {
|
|
|
17
17
|
return `get_variable_value(${this.subVariable(this.variable.toString())})`;
|
|
18
18
|
}
|
|
19
19
|
toDescriptor() {
|
|
20
|
-
return GetVariableDescriptor_1.newGetVariableDescriptor(this.variable);
|
|
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
|
}
|