@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
|
@@ -5,50 +5,69 @@ const FindAction_1 = require("../actions/FindAction");
|
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
6
|
const SendKeyStepDescriptor_1 = require("../types/SendKeyStepDescriptor");
|
|
7
7
|
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
8
|
+
const STEP_NAME = 'SendKeys';
|
|
8
9
|
class SendKeyStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
this.
|
|
12
|
-
}
|
|
13
|
-
static validateActionsAndGetFindAction(name, actions) {
|
|
14
|
-
if (actions.length !== 1 || !(actions[0] instanceof FindAction_1.FindAction)) {
|
|
10
|
+
constructor(name, args, actions) {
|
|
11
|
+
super(name, args, actions, 'send_keys');
|
|
12
|
+
if (this.actions.length !== 1 && !(this.actions[0] instanceof FindAction_1.FindAction)) {
|
|
15
13
|
throw new Error(`${name} step should have one sub-action and it should be a find`);
|
|
16
14
|
}
|
|
17
|
-
if ((0, domUtil_1.isFindElementType)(actions[0].getActionName())) {
|
|
18
|
-
|
|
15
|
+
if ((0, domUtil_1.isFindElementType)(this.actions[0].getActionName())) {
|
|
16
|
+
this.findAction = this.actions[0];
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
else {
|
|
19
|
+
throw new Error(`Unexpected find action for ${name} step: ${JSON.stringify(this.actions[0])}`);
|
|
20
|
+
}
|
|
21
|
+
const keys = this.getActionArgs();
|
|
22
|
+
if (!keys?.length) {
|
|
24
23
|
throw new Error(`${name} step expects at least one key`);
|
|
25
24
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
25
|
+
if (keys.every(SendKeyStepDescriptor_1.isCrossPlatformKeyPress)) {
|
|
26
|
+
this.keys = keys;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(`Unexpected key format for ${name} step: ${JSON.stringify(keys)}`);
|
|
28
30
|
}
|
|
29
|
-
throw new Error(`Unexpected key format for ${name} step: ${JSON.stringify(args)}`);
|
|
30
31
|
}
|
|
31
32
|
getStepName() {
|
|
32
|
-
return
|
|
33
|
+
return STEP_NAME;
|
|
33
34
|
}
|
|
34
35
|
toStepDescriptor() {
|
|
35
|
-
|
|
36
|
+
const find = this.findAction.toDescriptor();
|
|
37
|
+
switch (find.findType) {
|
|
38
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
39
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
40
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
41
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
42
|
+
return {
|
|
43
|
+
find,
|
|
44
|
+
keys: this.keys,
|
|
45
|
+
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
46
|
+
actionCode: this.actionCode,
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
50
|
+
}
|
|
36
51
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
getFormattedStep() {
|
|
53
|
+
const step = {
|
|
54
|
+
[STEP_NAME]: {
|
|
55
|
+
...super.annotationsAsYml(),
|
|
56
|
+
sendKeys: this.keys,
|
|
57
|
+
...this.findAction.toYaml(),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
if (this.stepId()) {
|
|
61
|
+
step[STEP_NAME].id = this.stepId();
|
|
44
62
|
}
|
|
45
63
|
return step;
|
|
46
64
|
}
|
|
47
|
-
static
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
static fromYaml(_stepName, stepArgs) {
|
|
66
|
+
const step = new SendKeyStep('send_keys', stepArgs.sendKeys, [
|
|
67
|
+
FindAction_1.FindAction.findActionFromStepArgs(stepArgs),
|
|
68
|
+
]);
|
|
69
|
+
step.setStepId(stepArgs.id);
|
|
70
|
+
return step;
|
|
52
71
|
}
|
|
53
72
|
toMablscript() {
|
|
54
73
|
const keysToSend = this.keys
|
|
@@ -59,150 +78,7 @@ class SendKeyStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
|
59
78
|
getInputVariables() {
|
|
60
79
|
return this.findAction.getInputVariables();
|
|
61
80
|
}
|
|
62
|
-
stepDescription() {
|
|
63
|
-
const keypresses = this.generateHumanizedKeys(this.isPasswordField());
|
|
64
|
-
const pluralizedKeypress = this.keys.length > 1 ? 'keypresses' : 'keypress';
|
|
65
|
-
const elementDescription = this.humanizeFind();
|
|
66
|
-
return `Send "${keypresses}" ${pluralizedKeypress} to ${elementDescription}`;
|
|
67
|
-
}
|
|
68
|
-
isPasswordField() {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
generateHumanizedKeys(isPasswordField) {
|
|
72
|
-
return this.keys
|
|
73
|
-
.map((key) => this.humanizeKeyInfo(key, isPasswordField))
|
|
74
|
-
.join('');
|
|
75
|
-
}
|
|
76
|
-
humanizeKeyInfo(keyInfo, isPasswordField) {
|
|
77
|
-
if (!keyInfo) {
|
|
78
|
-
return '';
|
|
79
|
-
}
|
|
80
|
-
const activeModifiers = SendKeyStep.getActiveModifiers(keyInfo, false);
|
|
81
|
-
const activeModifierStrings = activeModifiers.map((modifierKey) => SendKeyStep.modifierKeyHumanizedMap[modifierKey]);
|
|
82
|
-
const hasActiveModifiersFlag = !this.isEmpty(activeModifierStrings);
|
|
83
|
-
const activeModifiersPrefix = hasActiveModifiersFlag
|
|
84
|
-
? activeModifierStrings.join('+') + '+'
|
|
85
|
-
: '';
|
|
86
|
-
const hasMacOverride = keyInfo.mac?.key;
|
|
87
|
-
const hasWindowsOverride = keyInfo.windows?.key;
|
|
88
|
-
let humanizedString = `${activeModifiersPrefix}${this.generateHumanizedKey(keyInfo, isPasswordField)}`;
|
|
89
|
-
if (hasMacOverride || hasWindowsOverride) {
|
|
90
|
-
humanizedString = `Default: ${humanizedString}`;
|
|
91
|
-
}
|
|
92
|
-
if (hasMacOverride) {
|
|
93
|
-
humanizedString += `, Mac: ${this.humanizeKeyInfo(keyInfo.mac, isPasswordField)}`;
|
|
94
|
-
}
|
|
95
|
-
if (hasWindowsOverride) {
|
|
96
|
-
humanizedString += `, Windows: ${this.humanizeKeyInfo(keyInfo.windows, isPasswordField)}`;
|
|
97
|
-
}
|
|
98
|
-
return humanizedString;
|
|
99
|
-
}
|
|
100
|
-
generateHumanizedKey(keyInfo, isPasswordField) {
|
|
101
|
-
if (SendKeyStep.keyIsSpecial(keyInfo.key)) {
|
|
102
|
-
return `[${keyInfo.key.toUpperCase()}]`;
|
|
103
|
-
}
|
|
104
|
-
return isPasswordField ? '*' : keyInfo.key;
|
|
105
|
-
}
|
|
106
|
-
static keyIsSpecial(key) {
|
|
107
|
-
return SendKeyStep.specialKeys.includes(key);
|
|
108
|
-
}
|
|
109
|
-
static getActiveModifiers(keyInfo, includeOverrides) {
|
|
110
|
-
const modifiers = SendKeyStep.getModifiers(keyInfo, includeOverrides);
|
|
111
|
-
return Object.keys(SendKeyStep.pickBy(modifiers));
|
|
112
|
-
}
|
|
113
|
-
static getModifiers(keyInfo, includeOverrides) {
|
|
114
|
-
const objectKeys = Object.keys(SendKeyStep.modifierKeyIdentifierMap);
|
|
115
|
-
let modifiers = SendKeyStep.pick(keyInfo, objectKeys);
|
|
116
|
-
if (includeOverrides) {
|
|
117
|
-
modifiers = {
|
|
118
|
-
...modifiers,
|
|
119
|
-
...SendKeyStep.pick(keyInfo, objectKeys.map((key) => `windows.${key}`)),
|
|
120
|
-
...SendKeyStep.pick(keyInfo, objectKeys.map((key) => `mac.${key}`)),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return modifiers;
|
|
124
|
-
}
|
|
125
|
-
isEmpty(obj) {
|
|
126
|
-
return obj === undefined || Object.keys(obj).length === 0;
|
|
127
|
-
}
|
|
128
|
-
static pick(object, paths) {
|
|
129
|
-
const result = {};
|
|
130
|
-
for (const path of paths) {
|
|
131
|
-
if (path in object) {
|
|
132
|
-
result[path] = object[path];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
static pickBy(object) {
|
|
138
|
-
const result = {};
|
|
139
|
-
for (const key in object) {
|
|
140
|
-
if (object[key]) {
|
|
141
|
-
result[key] = object[key];
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
81
|
}
|
|
147
82
|
exports.SendKeyStep = SendKeyStep;
|
|
148
|
-
SendKeyStep.
|
|
149
|
-
SendKeyStep.
|
|
150
|
-
SendKeyStep.mablScriptStepNames = [SendKeyStep.actionCode];
|
|
151
|
-
SendKeyStep.yamlMablScriptNames = [SendKeyStep.stepName];
|
|
152
|
-
SendKeyStep.modifierKeyHumanizedMap = {
|
|
153
|
-
altKey: 'Alt',
|
|
154
|
-
ctrlKey: 'Ctrl',
|
|
155
|
-
metaKey: 'Cmd',
|
|
156
|
-
shiftKey: 'Shift',
|
|
157
|
-
};
|
|
158
|
-
SendKeyStep.modifierKeyIdentifierMap = {
|
|
159
|
-
altKey: false,
|
|
160
|
-
ctrlKey: false,
|
|
161
|
-
metaKey: false,
|
|
162
|
-
shiftKey: false,
|
|
163
|
-
};
|
|
164
|
-
SendKeyStep.specialKeys = [
|
|
165
|
-
'Enter',
|
|
166
|
-
'Tab',
|
|
167
|
-
'Escape',
|
|
168
|
-
'Backspace',
|
|
169
|
-
'Delete',
|
|
170
|
-
'ArrowUp',
|
|
171
|
-
'ArrowDown',
|
|
172
|
-
'ArrowLeft',
|
|
173
|
-
'ArrowRight',
|
|
174
|
-
'Home',
|
|
175
|
-
'End',
|
|
176
|
-
'PageUp',
|
|
177
|
-
'PageDown',
|
|
178
|
-
'Insert',
|
|
179
|
-
'F1',
|
|
180
|
-
'F2',
|
|
181
|
-
'F3',
|
|
182
|
-
'F4',
|
|
183
|
-
'F5',
|
|
184
|
-
'F6',
|
|
185
|
-
'F7',
|
|
186
|
-
'F8',
|
|
187
|
-
'F9',
|
|
188
|
-
'F10',
|
|
189
|
-
'F11',
|
|
190
|
-
'F12',
|
|
191
|
-
];
|
|
192
|
-
function buildStepDescriptor(findAction, keys) {
|
|
193
|
-
const find = findAction.toDescriptor();
|
|
194
|
-
switch (find.findType) {
|
|
195
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
196
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
197
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
198
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
199
|
-
return {
|
|
200
|
-
find,
|
|
201
|
-
keys,
|
|
202
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
203
|
-
actionCode: 'send_keys',
|
|
204
|
-
};
|
|
205
|
-
default:
|
|
206
|
-
throw new Error(`Error generating step descriptor for SendKeys: Unexpected find type ${find.findType}`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
83
|
+
SendKeyStep.mablScriptStepNames = ['send_keys'];
|
|
84
|
+
SendKeyStep.yamlMablScriptNames = ['SendKeys'];
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetCookieStep = void 0;
|
|
4
|
-
const
|
|
4
|
+
const MablStep_1 = require("../MablStep");
|
|
5
5
|
const MablAction_1 = require("../MablAction");
|
|
6
6
|
const CookieUtils_1 = require("./CookieUtils");
|
|
7
7
|
const domUtil_1 = require("../../domUtil");
|
|
8
|
-
class SetCookieStep extends
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
8
|
+
class SetCookieStep extends MablStep_1.MablStep {
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions, 'set_cookie');
|
|
11
|
+
const cookieSelector = this.getActionArgs()[0];
|
|
12
|
+
this.cookieName = CookieUtils_1.CookieUtils.normalizeName(cookieSelector.name);
|
|
13
|
+
this.cookieValue = CookieUtils_1.CookieUtils.normalizeValue(cookieSelector.value);
|
|
14
|
+
const cookieOptions = {
|
|
15
|
+
domain: cookieSelector.domain,
|
|
16
|
+
path: cookieSelector.path,
|
|
17
|
+
expires: cookieSelector.expiry,
|
|
18
|
+
httpOnly: cookieSelector.http_only,
|
|
19
|
+
secure: cookieSelector.secure,
|
|
20
|
+
sameSite: cookieSelector.same_site,
|
|
21
|
+
url: cookieSelector.url,
|
|
22
|
+
};
|
|
23
|
+
if (Object.values(cookieOptions).filter((optionValue) => optionValue !== undefined).length > 0) {
|
|
24
|
+
this.cookieOptions = cookieOptions;
|
|
25
|
+
}
|
|
14
26
|
}
|
|
15
27
|
getStepName() {
|
|
16
|
-
return
|
|
28
|
+
return 'SetCookie';
|
|
17
29
|
}
|
|
18
30
|
toStepDescriptor() {
|
|
19
31
|
return {
|
|
@@ -24,50 +36,10 @@ class SetCookieStep extends MablStepV2_1.MablStepV2 {
|
|
|
24
36
|
};
|
|
25
37
|
}
|
|
26
38
|
static fromYaml(_stepName, stepArgs) {
|
|
27
|
-
const
|
|
28
|
-
const cookieValue = CookieUtils_1.CookieUtils.normalizeValue(stepArgs.value);
|
|
29
|
-
const cookieOptions = {
|
|
30
|
-
domain: stepArgs.domain,
|
|
31
|
-
path: stepArgs.path,
|
|
32
|
-
expires: stepArgs.expiry,
|
|
33
|
-
httpOnly: stepArgs.http_only,
|
|
34
|
-
secure: stepArgs.secure,
|
|
35
|
-
sameSite: stepArgs.same_site,
|
|
36
|
-
url: stepArgs.url,
|
|
37
|
-
};
|
|
38
|
-
const hasOptions = Object.values(cookieOptions).filter((optionValue) => optionValue !== undefined).length > 0;
|
|
39
|
-
const stepDescriptor = {
|
|
40
|
-
name: cookieName,
|
|
41
|
-
value: cookieValue,
|
|
42
|
-
options: hasOptions ? cookieOptions : undefined,
|
|
43
|
-
actionCode: SetCookieStep.actionCode,
|
|
44
|
-
};
|
|
45
|
-
const step = new SetCookieStep(stepDescriptor);
|
|
39
|
+
const step = new SetCookieStep('set_cookie', [stepArgs], []);
|
|
46
40
|
step.setStepId(stepArgs.id);
|
|
47
41
|
return step;
|
|
48
42
|
}
|
|
49
|
-
static fromLegacyMablscript(args, _actions) {
|
|
50
|
-
const cookieSelector = args[0];
|
|
51
|
-
const cookieName = CookieUtils_1.CookieUtils.normalizeName(cookieSelector.name);
|
|
52
|
-
const cookieValue = CookieUtils_1.CookieUtils.normalizeValue(cookieSelector.value);
|
|
53
|
-
const cookieOptions = {
|
|
54
|
-
domain: cookieSelector.domain,
|
|
55
|
-
path: cookieSelector.path,
|
|
56
|
-
expires: cookieSelector.expiry,
|
|
57
|
-
httpOnly: cookieSelector.http_only,
|
|
58
|
-
secure: cookieSelector.secure,
|
|
59
|
-
sameSite: cookieSelector.same_site,
|
|
60
|
-
url: cookieSelector.url,
|
|
61
|
-
};
|
|
62
|
-
const hasOptions = Object.values(cookieOptions).filter((optionValue) => optionValue !== undefined).length > 0;
|
|
63
|
-
const stepDescriptor = {
|
|
64
|
-
name: cookieName,
|
|
65
|
-
value: cookieValue,
|
|
66
|
-
options: hasOptions ? cookieOptions : undefined,
|
|
67
|
-
actionCode: SetCookieStep.actionCode,
|
|
68
|
-
};
|
|
69
|
-
return new SetCookieStep(stepDescriptor);
|
|
70
|
-
}
|
|
71
43
|
toMablscript() {
|
|
72
44
|
const cookieSelector = {
|
|
73
45
|
name: this.cookieName,
|
|
@@ -91,12 +63,7 @@ class SetCookieStep extends MablStepV2_1.MablStepV2 {
|
|
|
91
63
|
...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.cookieValue),
|
|
92
64
|
]);
|
|
93
65
|
}
|
|
94
|
-
stepDescription() {
|
|
95
|
-
return `Set cookie: "${this.cookieName}"`;
|
|
96
|
-
}
|
|
97
66
|
}
|
|
98
67
|
exports.SetCookieStep = SetCookieStep;
|
|
99
|
-
SetCookieStep.
|
|
100
|
-
SetCookieStep.
|
|
101
|
-
SetCookieStep.mablScriptStepNames = [SetCookieStep.actionCode];
|
|
102
|
-
SetCookieStep.yamlMablScriptNames = [SetCookieStep.stepName];
|
|
68
|
+
SetCookieStep.mablScriptStepNames = ['set_cookie'];
|
|
69
|
+
SetCookieStep.yamlMablScriptNames = ['SetCookie'];
|
|
@@ -5,31 +5,57 @@ const FindAction_1 = require("../actions/FindAction");
|
|
|
5
5
|
const MablAction_1 = require("../MablAction");
|
|
6
6
|
const domUtil_1 = require("../../domUtil");
|
|
7
7
|
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
8
|
-
const ActionsUtils_1 = require("./ActionsUtils");
|
|
9
8
|
class SetFilesStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
12
|
-
this.files =
|
|
9
|
+
constructor(name, args, actions) {
|
|
10
|
+
super(name, args, actions, 'set_files');
|
|
11
|
+
this.files = this.getActionArgs();
|
|
12
|
+
this.validate();
|
|
13
|
+
this.findAction = this.actions[0];
|
|
14
|
+
}
|
|
15
|
+
validate() {
|
|
16
|
+
if (this.actions.length !== 1 && !(this.actions[0] instanceof FindAction_1.FindAction)) {
|
|
17
|
+
throw new Error('Set files steps should have exactly on sub action and it should be a find');
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
getStepName() {
|
|
15
|
-
return
|
|
21
|
+
return 'SetFiles';
|
|
16
22
|
}
|
|
17
23
|
toStepDescriptor() {
|
|
18
|
-
|
|
24
|
+
const formatted = {};
|
|
25
|
+
formatted.files = this.files;
|
|
26
|
+
const find = this.findAction.toDescriptor();
|
|
27
|
+
switch (find.findType) {
|
|
28
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
29
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
30
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
31
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
32
|
+
formatted.find = find;
|
|
33
|
+
formatted.descriptorToActionMap = new Map().set(find, this.findAction);
|
|
34
|
+
return formatted;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
40
|
+
const step = {
|
|
41
|
+
SetFiles: {
|
|
42
|
+
...super.annotationsAsYml(),
|
|
43
|
+
...this.findAction.toYaml(),
|
|
44
|
+
files: this.files,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
if (this.stepId()) {
|
|
48
|
+
step.SetFiles.id = this.stepId();
|
|
49
|
+
}
|
|
50
|
+
return step;
|
|
19
51
|
}
|
|
20
52
|
static fromYaml(_stepName, stepArgs) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
const step = new SetFilesStep('set_files', stepArgs.files, [
|
|
54
|
+
FindAction_1.FindAction.findActionFromStepArgs(stepArgs),
|
|
55
|
+
]);
|
|
24
56
|
step.setStepId(stepArgs.id);
|
|
25
57
|
return step;
|
|
26
58
|
}
|
|
27
|
-
static fromLegacyMablscript(args, actions) {
|
|
28
|
-
const files = args;
|
|
29
|
-
const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
|
|
30
|
-
const stepDescriptor = buildStepDescriptor(findAction, files);
|
|
31
|
-
return new SetFilesStep(stepDescriptor, findAction);
|
|
32
|
-
}
|
|
33
59
|
toMablscript() {
|
|
34
60
|
const files = this.files
|
|
35
61
|
.map((key) => (0, MablAction_1.convertObjectToMablscriptArgs)(key))
|
|
@@ -39,32 +65,7 @@ class SetFilesStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
|
39
65
|
getInputVariables() {
|
|
40
66
|
return this.findAction.getInputVariables();
|
|
41
67
|
}
|
|
42
|
-
stepDescription() {
|
|
43
|
-
const fileCount = this.files.length;
|
|
44
|
-
const fileText = fileCount === 1 ? 'file' : 'files';
|
|
45
|
-
const elementDescription = this.humanizeFind();
|
|
46
|
-
return `Set ${fileCount} ${fileText} on ${elementDescription}`;
|
|
47
|
-
}
|
|
48
68
|
}
|
|
49
69
|
exports.SetFilesStep = SetFilesStep;
|
|
50
|
-
SetFilesStep.
|
|
51
|
-
SetFilesStep.
|
|
52
|
-
SetFilesStep.mablScriptStepNames = [SetFilesStep.actionCode];
|
|
53
|
-
SetFilesStep.yamlMablScriptNames = [SetFilesStep.stepName];
|
|
54
|
-
function buildStepDescriptor(findAction, files) {
|
|
55
|
-
const find = findAction.toDescriptor();
|
|
56
|
-
switch (find.findType) {
|
|
57
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
58
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
59
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
60
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
61
|
-
return {
|
|
62
|
-
files,
|
|
63
|
-
find,
|
|
64
|
-
descriptorToActionMap: new Map().set(find, findAction),
|
|
65
|
-
actionCode: SetFilesStep.actionCode,
|
|
66
|
-
};
|
|
67
|
-
default:
|
|
68
|
-
throw new Error(`Error generating step descriptor for ${SetFilesStep.stepName}: Unexpected find type ${find.findType}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
70
|
+
SetFilesStep.mablScriptStepNames = ['set_files'];
|
|
71
|
+
SetFilesStep.yamlMablScriptNames = ['SetFiles'];
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetViewportStep = void 0;
|
|
4
|
-
const
|
|
5
|
-
class SetViewportStep extends
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
8
|
-
|
|
4
|
+
const MablStep_1 = require("../MablStep");
|
|
5
|
+
class SetViewportStep extends MablStep_1.MablStep {
|
|
6
|
+
constructor(name, args, actions) {
|
|
7
|
+
super(name, args, actions, 'set_viewport');
|
|
8
|
+
const viewportArg = this.getActionArgs()[0];
|
|
9
|
+
this.size = viewportArg?.size;
|
|
9
10
|
}
|
|
10
11
|
getStepName() {
|
|
11
|
-
return
|
|
12
|
+
return 'SetViewport';
|
|
12
13
|
}
|
|
13
14
|
toStepDescriptor() {
|
|
14
15
|
return { size: this.size, actionCode: this.actionCode };
|
|
15
16
|
}
|
|
16
|
-
static fromYaml(_stepName,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const stepDescriptor = {
|
|
21
|
-
size: {
|
|
22
|
-
width: args[0]?.size?.width ?? undefined,
|
|
23
|
-
height: args[0]?.size?.height ?? undefined,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
return new SetViewportStep(stepDescriptor);
|
|
17
|
+
static fromYaml(_stepName, stepArgs) {
|
|
18
|
+
const step = new SetViewportStep('set_viewport', [stepArgs], []);
|
|
19
|
+
step.setStepId(stepArgs.id);
|
|
20
|
+
return step;
|
|
27
21
|
}
|
|
28
22
|
toMablscript() {
|
|
29
23
|
let sizeArg;
|
|
@@ -38,27 +32,7 @@ class SetViewportStep extends MablStepV2_1.MablStepV2 {
|
|
|
38
32
|
}
|
|
39
33
|
return `set_viewport(${sizeArg})`;
|
|
40
34
|
}
|
|
41
|
-
stepDescription() {
|
|
42
|
-
if (this.size) {
|
|
43
|
-
let message = 'Set viewport size';
|
|
44
|
-
const width = this.size.width;
|
|
45
|
-
const height = this.size.height;
|
|
46
|
-
if (width) {
|
|
47
|
-
message += ` to width ${width}`;
|
|
48
|
-
if (height) {
|
|
49
|
-
message += ` and height ${height}`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (height) {
|
|
53
|
-
message += ` to height ${height}`;
|
|
54
|
-
}
|
|
55
|
-
return message;
|
|
56
|
-
}
|
|
57
|
-
return `Invalid set viewport step definition`;
|
|
58
|
-
}
|
|
59
35
|
}
|
|
60
36
|
exports.SetViewportStep = SetViewportStep;
|
|
61
|
-
SetViewportStep.
|
|
62
|
-
SetViewportStep.
|
|
63
|
-
SetViewportStep.mablScriptStepNames = [SetViewportStep.actionCode];
|
|
64
|
-
SetViewportStep.yamlMablScriptNames = [SetViewportStep.stepName];
|
|
37
|
+
SetViewportStep.mablScriptStepNames = ['set_viewport'];
|
|
38
|
+
SetViewportStep.yamlMablScriptNames = ['SetViewport'];
|