@mablhq/mabl-cli 2.72.0 → 2.72.4
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/browserLauncher/index.js +3 -3
- package/core/execution/ApiTestUtils.js +12 -2
- package/execution/index.js +1 -1
- package/mablscript/MablStepV2.js +10 -40
- package/mablscript/MablStepWithFindAction.js +2 -126
- package/mablscript/actions/AwaitDownloadAction.js +3 -4
- package/mablscript/actions/AwaitPDFDownloadAction.js +5 -6
- package/mablscript/actions/ConditionAction.js +1 -2
- package/mablscript/actions/ExtractAction.js +13 -8
- package/mablscript/actions/FindAction.js +0 -20
- package/mablscript/actions/GetVariableValue.js +4 -15
- package/mablscript/actions/JavaScriptAction.js +39 -25
- package/mablscript/diffing/diffingUtil.js +5 -5
- package/mablscript/importer.js +59 -79
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +1 -3
- package/mablscript/mobile/steps/stepUtil.js +2 -2
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +8 -10
- package/mablscript/steps/AccessibilityCheck.js +36 -76
- package/mablscript/steps/AssertStep.js +86 -266
- package/mablscript/steps/AssertStepOld.js +139 -69
- package/mablscript/steps/AwaitTabStep.js +9 -30
- package/mablscript/steps/AwaitUploadsStep.js +8 -22
- package/mablscript/steps/ClearCookiesStep.js +8 -22
- package/mablscript/steps/ClickAndHoldStep.js +47 -45
- package/mablscript/steps/ClickStep.js +33 -36
- package/mablscript/steps/CreateVariableStep.js +137 -169
- package/mablscript/steps/DatabaseQueryStep.js +4 -14
- package/mablscript/steps/DoubleClickStep.js +40 -37
- package/mablscript/steps/DownloadStep.js +63 -79
- package/mablscript/steps/EchoStep.js +8 -26
- package/mablscript/steps/ElseIfConditionStep.js +12 -23
- package/mablscript/steps/ElseStep.js +9 -22
- package/mablscript/steps/EndStep.js +9 -22
- package/mablscript/steps/EnterAuthCodeStep.js +34 -36
- package/mablscript/steps/EnterTextStep.js +64 -51
- package/mablscript/steps/EvaluateFlowStep.js +18 -39
- package/mablscript/steps/EvaluateJavaScriptStep.js +19 -17
- package/mablscript/steps/HoverStep.js +39 -37
- package/mablscript/steps/IfConditionStep.js +99 -139
- package/mablscript/steps/NavigateStep.js +9 -29
- package/mablscript/steps/OpenEmailStep.js +21 -39
- package/mablscript/steps/ReleaseStep.js +38 -46
- package/mablscript/steps/RemoveCookieStep.js +9 -25
- package/mablscript/steps/RightClickStep.js +33 -36
- package/mablscript/steps/SelectStep.js +46 -69
- package/mablscript/steps/SendHttpRequestStep.js +4 -13
- package/mablscript/steps/SendKeyStep.js +50 -174
- package/mablscript/steps/SetCookieStep.js +23 -56
- package/mablscript/steps/SetFilesStep.js +43 -42
- package/mablscript/steps/SetViewportStep.js +13 -39
- package/mablscript/steps/SwitchContextStep.js +83 -89
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +22 -30
- package/mablscript/steps/WaitStep.js +9 -20
- package/mablscript/steps/WaitUntilStep.js +14 -31
- package/mablscript/types/ConditionDescriptor.js +5 -5
- package/mablscript/types/GetVariableDescriptor.js +8 -0
- package/package.json +3 -3
- package/mablscript/steps/StepGroupStep.js +0 -70
- package/mablscript/types/AssertStepDescriptor.js +0 -2
- package/mablscript/types/StepGroupStepDescriptor.js +0 -2
|
@@ -1,89 +1,159 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
exports.AssertStepOld = void 0;
|
|
4
|
+
const ExtractAction_1 = require("../actions/ExtractAction");
|
|
5
|
+
const MablStep_1 = require("../MablStep");
|
|
6
|
+
const FindAction_1 = require("../actions/FindAction");
|
|
7
|
+
const domUtil_1 = require("../../domUtil");
|
|
8
|
+
const importer_1 = require("../importer");
|
|
9
|
+
const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
|
|
10
|
+
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
11
|
+
const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
|
|
12
|
+
const oldToNewAssertionTypes = {
|
|
12
13
|
assert_contains: 'AssertContains',
|
|
13
14
|
assert_does_not_contain: 'AssertDoesNotContain',
|
|
15
|
+
assert_does_not_equal: 'AssertDoesNotEqual',
|
|
16
|
+
assert_download: 'AssertDownload',
|
|
17
|
+
assert_equals: 'AssertEquals',
|
|
18
|
+
assert_greater_than: 'AssertGreaterThan',
|
|
19
|
+
assert_greater_than_or_equals: 'AssertGreaterThanOrEquals',
|
|
20
|
+
assert_less_than: 'AssertLessThan',
|
|
21
|
+
assert_less_than_or_equals: 'AssertLessThanOrEquals',
|
|
22
|
+
assert_not_present: 'AssertNotPresent',
|
|
23
|
+
assert_present: 'AssertPresent',
|
|
14
24
|
assert_starts_with: 'AssertStartsWith',
|
|
15
25
|
assert_starts_without: 'AssertStartsWithout',
|
|
16
26
|
assert_ends_with: 'AssertEndsWith',
|
|
17
27
|
assert_ends_without: 'AssertEndsWithout',
|
|
18
|
-
assert_greater_than: 'AssertGreaterThan',
|
|
19
|
-
assert_less_than: 'AssertLessThan',
|
|
20
|
-
assert_greater_than_or_equals: 'AssertGreaterThanOrEquals',
|
|
21
|
-
assert_less_than_or_equals: 'AssertLessThanOrEquals',
|
|
22
|
-
assert_matches_regex: 'AssertMatchesRegex',
|
|
23
|
-
assert_ai_prompt: 'AssertAIPrompt',
|
|
24
28
|
};
|
|
25
|
-
class
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
class AssertStepOld extends MablStep_1.MablStep {
|
|
30
|
+
constructor(name, args, actions) {
|
|
31
|
+
super(name, args, actions, name);
|
|
32
|
+
this.assertionType = '';
|
|
33
|
+
this.assertAttribute = '';
|
|
34
|
+
this.validate();
|
|
35
|
+
this.setAssertAttribute();
|
|
36
|
+
this.assertionType = this.name;
|
|
37
|
+
this.primaryAction = actions[0];
|
|
38
|
+
this.extractAction = actions[1];
|
|
39
|
+
if (args.length === 1) {
|
|
40
|
+
this.onFailure = args[0].onFailure;
|
|
41
|
+
this.observationScope = args[0].observationScope;
|
|
30
42
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
newActions.push(actions[1]);
|
|
43
|
+
else if (args.length === 2) {
|
|
44
|
+
this.onFailure = args[1].onFailure;
|
|
45
|
+
this.observationScope = args[1].observationScope;
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
assertionArguments = firstArg;
|
|
43
|
-
if (name === 'assert_present' || name === 'assert_not_present') {
|
|
44
|
-
assertionValue = undefined;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
assertionValue = args[1];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
assertionValue = firstArg;
|
|
52
|
-
if (args[1] && typeof args[1] === 'object') {
|
|
53
|
-
assertionArguments = args[1];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
assertionValue = firstArg;
|
|
59
|
-
if (args[1] && typeof args[1] === 'object') {
|
|
60
|
-
assertionArguments = args[1];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
47
|
+
}
|
|
48
|
+
validate() {
|
|
49
|
+
if (this.actions.length !== 2 &&
|
|
50
|
+
!(this.actions[0] instanceof FindAction_1.FindAction) &&
|
|
51
|
+
!(this.actions[1] instanceof ExtractAction_1.ExtractAction)) {
|
|
52
|
+
throw new Error('Legacy assert steps should have exactly two sub action: a find and an extract');
|
|
63
53
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
}
|
|
55
|
+
setAssertAttribute() {
|
|
56
|
+
this.assertAttribute = this.getActionArgs()[0];
|
|
57
|
+
}
|
|
58
|
+
getStepName() {
|
|
59
|
+
return oldToNewAssertionTypes[this.getAssertionType()];
|
|
60
|
+
}
|
|
61
|
+
getAssertionType() {
|
|
62
|
+
return this.assertionType;
|
|
63
|
+
}
|
|
64
|
+
toStepDescriptor() {
|
|
65
|
+
const formatted = {};
|
|
66
|
+
if (this.assertionType !== 'assert_present' &&
|
|
67
|
+
this.assertionType !== 'assert_not_present') {
|
|
68
|
+
formatted.assertionValue = this.assertAttribute;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (this.extractAction) {
|
|
71
|
+
formatted.extractType =
|
|
72
|
+
ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
|
|
73
|
+
formatted.attribute = this.extractAction.extractionAttribute;
|
|
74
|
+
}
|
|
75
|
+
const find = this.primaryAction.toDescriptor();
|
|
76
|
+
formatted.findOptions = find.selectorFindOption;
|
|
77
|
+
if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) ||
|
|
78
|
+
(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) ||
|
|
79
|
+
(0, GetViewportDescriptor_1.isGetViewportDescriptor)(find)) {
|
|
80
|
+
formatted.kind = find.kind;
|
|
72
81
|
}
|
|
73
82
|
else {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
switch (find.findType) {
|
|
84
|
+
case domUtil_1.FindType.FIND_COOKIE:
|
|
85
|
+
case domUtil_1.FindType.FIND_EMAIL:
|
|
86
|
+
formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
|
|
87
|
+
formatted.selector = find.findTarget;
|
|
88
|
+
break;
|
|
89
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
90
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
91
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
92
|
+
case domUtil_1.FindType.FIND_ALL:
|
|
93
|
+
formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
|
|
94
|
+
formatted.selector = find.findTarget;
|
|
95
|
+
break;
|
|
96
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
97
|
+
formatted.selector = find.findTarget.selector;
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
77
101
|
}
|
|
78
|
-
conditionAction = new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
79
|
-
conditionType,
|
|
80
|
-
assertionValue || '',
|
|
81
|
-
]);
|
|
82
102
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
formatted.assertArguments = {
|
|
104
|
+
onFailure: this.onFailure,
|
|
105
|
+
observationScope: this.observationScope,
|
|
106
|
+
};
|
|
107
|
+
return formatted;
|
|
108
|
+
}
|
|
109
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
110
|
+
const result = {};
|
|
111
|
+
result[this.getStepName()] = { ...this.annotationsAsYml() };
|
|
112
|
+
const formatted = result[this.getStepName()];
|
|
113
|
+
if (this.extractAction) {
|
|
114
|
+
formatted.attribute = this.extractAction.extractionAttribute;
|
|
115
|
+
formatted.extractType =
|
|
116
|
+
ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
|
|
117
|
+
}
|
|
118
|
+
if (this.assertionType !== 'assert_present' &&
|
|
119
|
+
this.assertionType !== 'assert_not_present') {
|
|
120
|
+
formatted.assertionValue = this.assertAttribute;
|
|
121
|
+
}
|
|
122
|
+
const targetDescriptor = this.primaryAction.toDescriptor();
|
|
123
|
+
if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
|
|
124
|
+
formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
formatted.target = targetDescriptor;
|
|
128
|
+
}
|
|
129
|
+
formatted.assertArguments = {
|
|
130
|
+
onFailure: this.onFailure,
|
|
131
|
+
observationScope: this.observationScope,
|
|
132
|
+
};
|
|
133
|
+
if (this.stepId()) {
|
|
134
|
+
formatted.id = this.stepId();
|
|
135
|
+
}
|
|
86
136
|
return result;
|
|
87
137
|
}
|
|
138
|
+
getNewAssertionStep() {
|
|
139
|
+
const yamlified = (0, importer_1.yamlifyTheLoadedSteps)([this]);
|
|
140
|
+
const reloadedSteps = (0, importer_1.loadYamlSteps)(yamlified);
|
|
141
|
+
const result = reloadedSteps[0];
|
|
142
|
+
if (this.stepSourceIndexInFlow !== undefined) {
|
|
143
|
+
result.setStepSourceIndexInFlow(this.stepSourceIndexInFlow);
|
|
144
|
+
}
|
|
145
|
+
this.actions.forEach((_oldAction, actionIndex) => {
|
|
146
|
+
result.actions[actionIndex].setActionSourceIndexInStep(actionIndex);
|
|
147
|
+
});
|
|
148
|
+
if (this.actionSourceIndexInStep !== undefined) {
|
|
149
|
+
result.setActionSourceIndexInStep(this.actionSourceIndexInStep);
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
static fromYaml(stepName, _stepArgs) {
|
|
154
|
+
return new MablStep_1.MablStep(stepName, [], [], 'assert');
|
|
155
|
+
}
|
|
88
156
|
}
|
|
89
|
-
exports.
|
|
157
|
+
exports.AssertStepOld = AssertStepOld;
|
|
158
|
+
AssertStepOld.mablScriptStepNames = Object.keys(oldToNewAssertionTypes);
|
|
159
|
+
AssertStepOld.yamlMablScriptNames = [];
|
|
@@ -3,16 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AwaitTabStep = void 0;
|
|
4
4
|
exports.hasCustomFindOptions = hasCustomFindOptions;
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
super(AwaitTabStep.stepName, descriptor, AwaitTabStep.actionCode);
|
|
12
|
-
this.tab = descriptor.tab;
|
|
6
|
+
const MablStep_1 = require("../MablStep");
|
|
7
|
+
class AwaitTabStep extends MablStep_1.MablStep {
|
|
8
|
+
constructor(name, args, actions) {
|
|
9
|
+
super(name, args, actions, 'await_tab');
|
|
10
|
+
this.tab = this.getActionArgs()[0];
|
|
13
11
|
}
|
|
14
12
|
getStepName() {
|
|
15
|
-
return
|
|
13
|
+
return 'AwaitTab';
|
|
16
14
|
}
|
|
17
15
|
toStepDescriptor() {
|
|
18
16
|
return {
|
|
@@ -21,30 +19,13 @@ class AwaitTabStep extends MablStepV2_1.MablStepV2 {
|
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
static fromYaml(_stepName, stepArgs) {
|
|
24
|
-
const
|
|
25
|
-
actionCode: AwaitTabStep.actionCode,
|
|
26
|
-
tab: stepArgs.tab,
|
|
27
|
-
};
|
|
28
|
-
const step = new AwaitTabStep(stepDescriptor);
|
|
22
|
+
const step = new AwaitTabStep('await_tab', [stepArgs.tab], []);
|
|
29
23
|
step.setStepId(stepArgs.id);
|
|
30
24
|
return step;
|
|
31
25
|
}
|
|
32
|
-
static fromLegacyMablscript(args, _actions) {
|
|
33
|
-
const stepDescriptor = {
|
|
34
|
-
actionCode: AwaitTabStep.actionCode,
|
|
35
|
-
tab: args[0],
|
|
36
|
-
};
|
|
37
|
-
return new AwaitTabStep(stepDescriptor);
|
|
38
|
-
}
|
|
39
26
|
toMablscript() {
|
|
40
27
|
return `await_tab(${AwaitTabStep.getMablscriptSelectorFromTabFindAction(this.tab)})`;
|
|
41
28
|
}
|
|
42
|
-
getInputVariables() {
|
|
43
|
-
return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.tab);
|
|
44
|
-
}
|
|
45
|
-
stepDescription() {
|
|
46
|
-
return `Wait for ${(0, mablscriptFind_1.humanizeTabSelector)(this.tab)}`;
|
|
47
|
-
}
|
|
48
29
|
static hasCustomFindOptions(tab) {
|
|
49
30
|
return Object.keys(tab.configuration?.propertyPreferences ?? {}).length > 0;
|
|
50
31
|
}
|
|
@@ -80,10 +61,8 @@ class AwaitTabStep extends MablStepV2_1.MablStepV2 {
|
|
|
80
61
|
}
|
|
81
62
|
}
|
|
82
63
|
exports.AwaitTabStep = AwaitTabStep;
|
|
83
|
-
AwaitTabStep.
|
|
84
|
-
AwaitTabStep.
|
|
85
|
-
AwaitTabStep.mablScriptStepNames = [AwaitTabStep.actionCode];
|
|
86
|
-
AwaitTabStep.yamlMablScriptNames = [AwaitTabStep.stepName];
|
|
64
|
+
AwaitTabStep.mablScriptStepNames = ['await_tab'];
|
|
65
|
+
AwaitTabStep.yamlMablScriptNames = ['AwaitTab'];
|
|
87
66
|
function hasCustomFindOptions(tab) {
|
|
88
67
|
return AwaitTabStep.hasCustomFindOptions(tab);
|
|
89
68
|
}
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AwaitUploadsStep = void 0;
|
|
4
|
-
const
|
|
5
|
-
class AwaitUploadsStep extends
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
4
|
+
const MablStep_1 = require("../MablStep");
|
|
5
|
+
class AwaitUploadsStep extends MablStep_1.MablStep {
|
|
6
|
+
constructor(name, args, actions) {
|
|
7
|
+
super(name, args, actions, 'await_uploads');
|
|
8
8
|
}
|
|
9
9
|
getStepName() {
|
|
10
|
-
return
|
|
10
|
+
return 'AwaitUploads';
|
|
11
11
|
}
|
|
12
12
|
toStepDescriptor() {
|
|
13
13
|
return { actionCode: this.actionCode };
|
|
14
14
|
}
|
|
15
15
|
static fromYaml(_stepName, stepArgs) {
|
|
16
|
-
const
|
|
17
|
-
actionCode: AwaitUploadsStep.actionCode,
|
|
18
|
-
};
|
|
19
|
-
const step = new AwaitUploadsStep(stepDescriptor);
|
|
16
|
+
const step = new AwaitUploadsStep('await_uploads', [], []);
|
|
20
17
|
step.setStepId(stepArgs.id);
|
|
21
18
|
return step;
|
|
22
19
|
}
|
|
23
|
-
static fromLegacyMablscript(_args, _actions) {
|
|
24
|
-
const stepDescriptor = {
|
|
25
|
-
actionCode: AwaitUploadsStep.actionCode,
|
|
26
|
-
};
|
|
27
|
-
return new AwaitUploadsStep(stepDescriptor);
|
|
28
|
-
}
|
|
29
20
|
toMablscript() {
|
|
30
21
|
return `await_uploads()`;
|
|
31
22
|
}
|
|
32
|
-
stepDescription() {
|
|
33
|
-
return 'Wait for uploads to complete';
|
|
34
|
-
}
|
|
35
23
|
}
|
|
36
24
|
exports.AwaitUploadsStep = AwaitUploadsStep;
|
|
37
|
-
AwaitUploadsStep.
|
|
38
|
-
AwaitUploadsStep.
|
|
39
|
-
AwaitUploadsStep.mablScriptStepNames = [AwaitUploadsStep.actionCode];
|
|
40
|
-
AwaitUploadsStep.yamlMablScriptNames = [AwaitUploadsStep.stepName];
|
|
25
|
+
AwaitUploadsStep.mablScriptStepNames = ['await_uploads'];
|
|
26
|
+
AwaitUploadsStep.yamlMablScriptNames = ['AwaitUploads'];
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClearCookiesStep = void 0;
|
|
4
|
-
const
|
|
5
|
-
class ClearCookiesStep extends
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
4
|
+
const MablStep_1 = require("../MablStep");
|
|
5
|
+
class ClearCookiesStep extends MablStep_1.MablStep {
|
|
6
|
+
constructor(name, args, actions) {
|
|
7
|
+
super(name, args, actions, 'clear_cookies');
|
|
8
8
|
}
|
|
9
9
|
getStepName() {
|
|
10
|
-
return
|
|
10
|
+
return 'ClearCookies';
|
|
11
11
|
}
|
|
12
12
|
toStepDescriptor() {
|
|
13
13
|
return { actionCode: this.actionCode };
|
|
14
14
|
}
|
|
15
15
|
static fromYaml(_stepName, stepArgs) {
|
|
16
|
-
const
|
|
17
|
-
actionCode: ClearCookiesStep.actionCode,
|
|
18
|
-
};
|
|
19
|
-
const step = new ClearCookiesStep(stepDescriptor);
|
|
16
|
+
const step = new ClearCookiesStep('clear_cookies', [], []);
|
|
20
17
|
step.setStepId(stepArgs.id);
|
|
21
18
|
return step;
|
|
22
19
|
}
|
|
23
|
-
static fromLegacyMablscript(_args, _actions) {
|
|
24
|
-
const stepDescriptor = {
|
|
25
|
-
actionCode: ClearCookiesStep.actionCode,
|
|
26
|
-
};
|
|
27
|
-
return new ClearCookiesStep(stepDescriptor);
|
|
28
|
-
}
|
|
29
20
|
toMablscript() {
|
|
30
21
|
return `clear_cookies()`;
|
|
31
22
|
}
|
|
32
|
-
stepDescription() {
|
|
33
|
-
return 'Clear cookies from the current domain';
|
|
34
|
-
}
|
|
35
23
|
}
|
|
36
24
|
exports.ClearCookiesStep = ClearCookiesStep;
|
|
37
|
-
ClearCookiesStep.
|
|
38
|
-
ClearCookiesStep.
|
|
39
|
-
ClearCookiesStep.mablScriptStepNames = [ClearCookiesStep.actionCode];
|
|
40
|
-
ClearCookiesStep.yamlMablScriptNames = [ClearCookiesStep.stepName];
|
|
25
|
+
ClearCookiesStep.mablScriptStepNames = ['clear_cookies'];
|
|
26
|
+
ClearCookiesStep.yamlMablScriptNames = ['ClearCookies'];
|
|
@@ -6,68 +6,70 @@ const domUtil_1 = require("../../domUtil");
|
|
|
6
6
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
7
7
|
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
8
8
|
class ClickAndHoldStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
this.
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions, 'click_and_hold');
|
|
11
|
+
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
12
|
+
this.clickArgs = this.parseArgs(args) ?? { isHtml5: false };
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
parseArgs(args) {
|
|
14
15
|
if (args.length === 0) {
|
|
15
16
|
return undefined;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
18
|
+
if (args.length !== 1) {
|
|
19
|
+
throw new Error(`Unexpected number of arguments to ${this.getStepName()} step.`);
|
|
20
|
+
}
|
|
21
|
+
if (!isClickAndHoldArgs(args[0])) {
|
|
22
|
+
throw new Error(`Invalid argument passed to ${this.getStepName()} step.`);
|
|
23
|
+
}
|
|
24
|
+
return args[0];
|
|
20
25
|
}
|
|
21
26
|
getStepName() {
|
|
22
|
-
return
|
|
27
|
+
return 'ClickAndHold';
|
|
23
28
|
}
|
|
24
29
|
toStepDescriptor() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const find = this.findAction.toDescriptor();
|
|
31
|
+
switch (find.findType) {
|
|
32
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
33
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
34
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
35
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
36
|
+
return {
|
|
37
|
+
find,
|
|
38
|
+
isHtml5: this.clickArgs.isHtml5,
|
|
39
|
+
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
40
|
+
actionCode: this.actionCode,
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
44
|
+
}
|
|
29
45
|
}
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
46
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
47
|
+
const step = {
|
|
48
|
+
ClickAndHold: {
|
|
49
|
+
...super.annotationsAsYml(),
|
|
50
|
+
...this.findAction.toYaml(),
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
if (this.stepId()) {
|
|
54
|
+
step.ClickAndHold.id = this.stepId();
|
|
55
|
+
}
|
|
56
|
+
return step;
|
|
33
57
|
}
|
|
34
58
|
static fromYaml(_stepName, stepArgs) {
|
|
35
|
-
const
|
|
36
|
-
const clickArgs = { isHtml5: false };
|
|
37
|
-
const stepDescriptor = buildStepDescriptor(findAction, clickArgs);
|
|
38
|
-
const step = new ClickAndHoldStep(stepDescriptor, findAction);
|
|
59
|
+
const step = new ClickAndHoldStep('click_and_hold', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
39
60
|
step.setStepId(stepArgs.id);
|
|
40
61
|
return step;
|
|
41
62
|
}
|
|
42
|
-
static fromLegacyMablscript(args, actions) {
|
|
43
|
-
const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
|
|
44
|
-
const clickArgs = ClickAndHoldStep.parseArgs(args) ?? { isHtml5: false };
|
|
45
|
-
const stepDescriptor = buildStepDescriptor(findAction, clickArgs);
|
|
46
|
-
return new ClickAndHoldStep(stepDescriptor, findAction);
|
|
47
|
-
}
|
|
48
63
|
toMablscript() {
|
|
49
64
|
return `${this.findAction.toMablscript()}.click_and_hold({isHtml5:${this.clickArgs.isHtml5}})`;
|
|
50
65
|
}
|
|
66
|
+
getInputVariables() {
|
|
67
|
+
return this.findAction.getInputVariables();
|
|
68
|
+
}
|
|
51
69
|
}
|
|
52
70
|
exports.ClickAndHoldStep = ClickAndHoldStep;
|
|
53
|
-
ClickAndHoldStep.
|
|
54
|
-
ClickAndHoldStep.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
function buildStepDescriptor(findAction, clickArgs) {
|
|
58
|
-
const find = findAction.toDescriptor();
|
|
59
|
-
switch (find.findType) {
|
|
60
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
61
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
62
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
63
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
64
|
-
return {
|
|
65
|
-
find,
|
|
66
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
67
|
-
actionCode: ClickAndHoldStep.actionCode,
|
|
68
|
-
isHtml5: clickArgs.isHtml5,
|
|
69
|
-
};
|
|
70
|
-
default:
|
|
71
|
-
throw new Error(`Error generating step descriptor for ${ClickAndHoldStep.stepName}: Unexpected find type ${find.findType}`);
|
|
72
|
-
}
|
|
71
|
+
ClickAndHoldStep.mablScriptStepNames = ['click_and_hold'];
|
|
72
|
+
ClickAndHoldStep.yamlMablScriptNames = ['ClickAndHold'];
|
|
73
|
+
function isClickAndHoldArgs(value) {
|
|
74
|
+
return value.isHtml5 !== undefined;
|
|
73
75
|
}
|
|
@@ -6,56 +6,53 @@ const domUtil_1 = require("../../domUtil");
|
|
|
6
6
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
7
7
|
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
8
8
|
class ClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions, 'click');
|
|
11
|
+
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
11
12
|
}
|
|
12
13
|
getStepName() {
|
|
13
|
-
return
|
|
14
|
+
return 'Click';
|
|
14
15
|
}
|
|
15
16
|
toStepDescriptor() {
|
|
16
|
-
|
|
17
|
+
const find = this.findAction.toDescriptor();
|
|
18
|
+
switch (find.findType) {
|
|
19
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
20
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
21
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
22
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
23
|
+
return {
|
|
24
|
+
find,
|
|
25
|
+
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
26
|
+
actionCode: this.actionCode,
|
|
27
|
+
};
|
|
28
|
+
default:
|
|
29
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
33
|
+
const step = {
|
|
34
|
+
Click: {
|
|
35
|
+
...super.annotationsAsYml(),
|
|
36
|
+
...this.findAction.toYaml(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
if (this.stepId()) {
|
|
40
|
+
step.Click.id = this.stepId();
|
|
41
|
+
}
|
|
42
|
+
return step;
|
|
17
43
|
}
|
|
18
44
|
static fromYaml(_stepName, stepArgs) {
|
|
19
|
-
const
|
|
20
|
-
const stepDescriptor = buildStepDescriptor(findAction);
|
|
21
|
-
const step = new ClickStep(stepDescriptor, findAction);
|
|
45
|
+
const step = new ClickStep('click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
22
46
|
step.setStepId(stepArgs.id);
|
|
23
47
|
return step;
|
|
24
48
|
}
|
|
25
|
-
static fromLegacyMablscript(_args, actions) {
|
|
26
|
-
const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
|
|
27
|
-
const stepDescriptor = buildStepDescriptor(findAction);
|
|
28
|
-
return new ClickStep(stepDescriptor, findAction);
|
|
29
|
-
}
|
|
30
49
|
toMablscript() {
|
|
31
50
|
return `${this.findAction.toMablscript()}.click()`;
|
|
32
51
|
}
|
|
33
52
|
getInputVariables() {
|
|
34
53
|
return this.findAction.getInputVariables();
|
|
35
54
|
}
|
|
36
|
-
stepDescription() {
|
|
37
|
-
const elementDescription = this.humanizeFind();
|
|
38
|
-
return `Click on ${elementDescription}`;
|
|
39
|
-
}
|
|
40
55
|
}
|
|
41
56
|
exports.ClickStep = ClickStep;
|
|
42
|
-
ClickStep.
|
|
43
|
-
ClickStep.
|
|
44
|
-
ClickStep.mablScriptStepNames = [ClickStep.actionCode];
|
|
45
|
-
ClickStep.yamlMablScriptNames = [ClickStep.stepName];
|
|
46
|
-
function buildStepDescriptor(findAction) {
|
|
47
|
-
const find = findAction.toDescriptor();
|
|
48
|
-
switch (find.findType) {
|
|
49
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
50
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
51
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
52
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
53
|
-
return {
|
|
54
|
-
find,
|
|
55
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
56
|
-
actionCode: ClickStep.actionCode,
|
|
57
|
-
};
|
|
58
|
-
default:
|
|
59
|
-
throw new Error(`Error generating step descriptor for ${ClickStep.stepName}: Unexpected find type ${find.findType}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
57
|
+
ClickStep.mablScriptStepNames = ['click'];
|
|
58
|
+
ClickStep.yamlMablScriptNames = ['Click'];
|