@mablhq/mabl-cli 2.72.4 → 2.72.12
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/browserEngines/chromiumBrowserEngine.js +17 -0
- package/browserLauncher/index.js +3 -3
- package/commands/mcp/mcp_cmds/tools/createTest.js +10 -0
- package/commands/mcp/mcp_cmds/tools/getApplications.js +69 -0
- package/commands/mcp/mcp_cmds/tools/{getPlanResults.js → getLatestPlanRuns.js} +6 -6
- package/commands/mcp/mcp_cmds/tools/{getPlanRun.js → getPlanRunResult.js} +5 -5
- package/commands/mcp/mcp_cmds/tools/index.js +6 -4
- package/core/execution/ApiTestUtils.js +3 -1
- package/execution/index.js +1 -1
- package/http/requestInterceptor.js +10 -5
- package/index.d.ts +2 -0
- package/mablscript/MablStepV2.js +40 -10
- package/mablscript/MablStepWithFindAction.js +126 -2
- package/mablscript/actions/AwaitDownloadAction.js +4 -3
- package/mablscript/actions/AwaitPDFDownloadAction.js +6 -5
- package/mablscript/actions/ConditionAction.js +2 -1
- package/mablscript/actions/ExtractAction.js +8 -13
- package/mablscript/actions/FindAction.js +20 -0
- package/mablscript/actions/GetVariableValue.js +15 -4
- package/mablscript/actions/JavaScriptAction.js +25 -39
- package/mablscript/diffing/diffingUtil.js +5 -5
- package/mablscript/importer.js +79 -59
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +3 -1
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +10 -8
- package/mablscript/steps/AccessibilityCheck.js +78 -36
- package/mablscript/steps/AssertStep.js +267 -86
- package/mablscript/steps/AssertStepOld.js +69 -139
- package/mablscript/steps/AwaitTabStep.js +32 -9
- package/mablscript/steps/AwaitUploadsStep.js +24 -8
- package/mablscript/steps/ClearCookiesStep.js +24 -8
- package/mablscript/steps/ClickAndHoldStep.js +47 -47
- package/mablscript/steps/ClickStep.js +38 -33
- package/mablscript/steps/CreateVariableStep.js +169 -137
- package/mablscript/steps/DatabaseQueryStep.js +16 -4
- package/mablscript/steps/DoubleClickStep.js +39 -40
- package/mablscript/steps/DownloadStep.js +81 -63
- package/mablscript/steps/EchoStep.js +28 -8
- package/mablscript/steps/ElseIfConditionStep.js +25 -12
- package/mablscript/steps/ElseStep.js +24 -9
- package/mablscript/steps/EndStep.js +24 -9
- package/mablscript/steps/EnterAuthCodeStep.js +38 -34
- package/mablscript/steps/EnterTextStep.js +53 -64
- package/mablscript/steps/EvaluateFlowStep.js +41 -18
- package/mablscript/steps/EvaluateJavaScriptStep.js +19 -19
- package/mablscript/steps/HoverStep.js +39 -39
- package/mablscript/steps/IfConditionStep.js +141 -99
- package/mablscript/steps/NavigateStep.js +31 -9
- package/mablscript/steps/OpenEmailStep.js +41 -21
- package/mablscript/steps/ReleaseStep.js +48 -38
- package/mablscript/steps/RemoveCookieStep.js +27 -9
- package/mablscript/steps/RightClickStep.js +38 -33
- package/mablscript/steps/SelectStep.js +71 -46
- package/mablscript/steps/SendHttpRequestStep.js +11 -4
- package/mablscript/steps/SendKeyStep.js +175 -49
- package/mablscript/steps/SetCookieStep.js +58 -23
- package/mablscript/steps/SetFilesStep.js +44 -43
- package/mablscript/steps/SetViewportStep.js +40 -12
- package/mablscript/steps/StepGroupStep.js +70 -0
- package/mablscript/steps/SwitchContextStep.js +93 -83
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +31 -21
- package/mablscript/steps/WaitStep.js +21 -8
- package/mablscript/steps/WaitUntilStep.js +32 -13
- package/mablscript/types/AssertStepDescriptor.js +2 -0
- package/mablscript/types/ConditionDescriptor.js +5 -5
- package/mablscript/types/GetVariableDescriptor.js +0 -8
- package/mablscript/types/StepGroupStepDescriptor.js +2 -0
- package/package.json +4 -4
- package/proxy/index.js +1 -1
- package/upload/index.js +1 -1
|
@@ -5,68 +5,51 @@ 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';
|
|
9
8
|
class SendKeyStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
12
|
-
|
|
9
|
+
constructor(descriptor, findAction) {
|
|
10
|
+
super(SendKeyStep.stepName, descriptor, SendKeyStep.actionCode, findAction);
|
|
11
|
+
this.keys = descriptor.keys;
|
|
12
|
+
}
|
|
13
|
+
static validateActionsAndGetFindAction(name, actions) {
|
|
14
|
+
if (actions.length !== 1 || !(actions[0] instanceof FindAction_1.FindAction)) {
|
|
13
15
|
throw new Error(`${name} step should have one sub-action and it should be a find`);
|
|
14
16
|
}
|
|
15
|
-
if ((0, domUtil_1.isFindElementType)(
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
throw new Error(`Unexpected find action for ${name} step: ${JSON.stringify(this.actions[0])}`);
|
|
17
|
+
if ((0, domUtil_1.isFindElementType)(actions[0].getActionName())) {
|
|
18
|
+
return actions[0];
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
throw new Error(`Unexpected find action for ${name} step: ${JSON.stringify(actions[0])}`);
|
|
21
|
+
}
|
|
22
|
+
static validateKeys(name, args) {
|
|
23
|
+
if (!args?.length) {
|
|
23
24
|
throw new Error(`${name} step expects at least one key`);
|
|
24
25
|
}
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new Error(`Unexpected key format for ${name} step: ${JSON.stringify(keys)}`);
|
|
26
|
+
if (args.every(SendKeyStepDescriptor_1.isCrossPlatformKeyPress)) {
|
|
27
|
+
return args;
|
|
30
28
|
}
|
|
29
|
+
throw new Error(`Unexpected key format for ${name} step: ${JSON.stringify(args)}`);
|
|
31
30
|
}
|
|
32
31
|
getStepName() {
|
|
33
|
-
return
|
|
32
|
+
return SendKeyStep.stepName;
|
|
34
33
|
}
|
|
35
34
|
toStepDescriptor() {
|
|
36
|
-
|
|
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
|
-
}
|
|
35
|
+
return buildStepDescriptor(this.findAction, this.keys);
|
|
51
36
|
}
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
if (this.stepId()) {
|
|
61
|
-
step[STEP_NAME].id = this.stepId();
|
|
37
|
+
static fromYaml(_stepName, stepArgs) {
|
|
38
|
+
const keys = stepArgs.keys || stepArgs.sendKeys;
|
|
39
|
+
const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
|
|
40
|
+
const stepDescriptor = buildStepDescriptor(findAction, keys);
|
|
41
|
+
const step = new SendKeyStep(stepDescriptor, findAction);
|
|
42
|
+
if (stepArgs.id) {
|
|
43
|
+
step.setStepId(stepArgs.id);
|
|
62
44
|
}
|
|
63
45
|
return step;
|
|
64
46
|
}
|
|
65
|
-
static
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
step
|
|
47
|
+
static fromLegacyMablscript(args, actions) {
|
|
48
|
+
const findAction = SendKeyStep.validateActionsAndGetFindAction(SendKeyStep.stepName, actions);
|
|
49
|
+
const keys = SendKeyStep.validateKeys(SendKeyStep.stepName, args);
|
|
50
|
+
const stepDescriptor = buildStepDescriptor(findAction, keys);
|
|
51
|
+
const step = new SendKeyStep(stepDescriptor, findAction);
|
|
52
|
+
step.actions = actions;
|
|
70
53
|
return step;
|
|
71
54
|
}
|
|
72
55
|
toMablscript() {
|
|
@@ -78,7 +61,150 @@ class SendKeyStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
|
78
61
|
getInputVariables() {
|
|
79
62
|
return this.findAction.getInputVariables();
|
|
80
63
|
}
|
|
64
|
+
stepDescription() {
|
|
65
|
+
const keypresses = this.generateHumanizedKeys(this.isPasswordField());
|
|
66
|
+
const pluralizedKeypress = this.keys.length > 1 ? 'keypresses' : 'keypress';
|
|
67
|
+
const elementDescription = this.humanizeFind();
|
|
68
|
+
return `Send "${keypresses}" ${pluralizedKeypress} to ${elementDescription}`;
|
|
69
|
+
}
|
|
70
|
+
isPasswordField() {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
generateHumanizedKeys(isPasswordField) {
|
|
74
|
+
return this.keys
|
|
75
|
+
.map((key) => this.humanizeKeyInfo(key, isPasswordField))
|
|
76
|
+
.join('');
|
|
77
|
+
}
|
|
78
|
+
humanizeKeyInfo(keyInfo, isPasswordField) {
|
|
79
|
+
if (!keyInfo) {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
const activeModifiers = SendKeyStep.getActiveModifiers(keyInfo, false);
|
|
83
|
+
const activeModifierStrings = activeModifiers.map((modifierKey) => SendKeyStep.modifierKeyHumanizedMap[modifierKey]);
|
|
84
|
+
const hasActiveModifiersFlag = !this.isEmpty(activeModifierStrings);
|
|
85
|
+
const activeModifiersPrefix = hasActiveModifiersFlag
|
|
86
|
+
? activeModifierStrings.join('+') + '+'
|
|
87
|
+
: '';
|
|
88
|
+
const hasMacOverride = keyInfo.mac?.key;
|
|
89
|
+
const hasWindowsOverride = keyInfo.windows?.key;
|
|
90
|
+
let humanizedString = `${activeModifiersPrefix}${this.generateHumanizedKey(keyInfo, isPasswordField)}`;
|
|
91
|
+
if (hasMacOverride || hasWindowsOverride) {
|
|
92
|
+
humanizedString = `Default: ${humanizedString}`;
|
|
93
|
+
}
|
|
94
|
+
if (hasMacOverride) {
|
|
95
|
+
humanizedString += `, Mac: ${this.humanizeKeyInfo(keyInfo.mac, isPasswordField)}`;
|
|
96
|
+
}
|
|
97
|
+
if (hasWindowsOverride) {
|
|
98
|
+
humanizedString += `, Windows: ${this.humanizeKeyInfo(keyInfo.windows, isPasswordField)}`;
|
|
99
|
+
}
|
|
100
|
+
return humanizedString;
|
|
101
|
+
}
|
|
102
|
+
generateHumanizedKey(keyInfo, isPasswordField) {
|
|
103
|
+
if (SendKeyStep.keyIsSpecial(keyInfo.key)) {
|
|
104
|
+
return `[${keyInfo.key.toUpperCase()}]`;
|
|
105
|
+
}
|
|
106
|
+
return isPasswordField ? '*' : keyInfo.key;
|
|
107
|
+
}
|
|
108
|
+
static keyIsSpecial(key) {
|
|
109
|
+
return SendKeyStep.specialKeys.includes(key);
|
|
110
|
+
}
|
|
111
|
+
static getActiveModifiers(keyInfo, includeOverrides) {
|
|
112
|
+
const modifiers = SendKeyStep.getModifiers(keyInfo, includeOverrides);
|
|
113
|
+
return Object.keys(SendKeyStep.pickBy(modifiers));
|
|
114
|
+
}
|
|
115
|
+
static getModifiers(keyInfo, includeOverrides) {
|
|
116
|
+
const objectKeys = Object.keys(SendKeyStep.modifierKeyIdentifierMap);
|
|
117
|
+
let modifiers = SendKeyStep.pick(keyInfo, objectKeys);
|
|
118
|
+
if (includeOverrides) {
|
|
119
|
+
modifiers = {
|
|
120
|
+
...modifiers,
|
|
121
|
+
...SendKeyStep.pick(keyInfo, objectKeys.map((key) => `windows.${key}`)),
|
|
122
|
+
...SendKeyStep.pick(keyInfo, objectKeys.map((key) => `mac.${key}`)),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return modifiers;
|
|
126
|
+
}
|
|
127
|
+
isEmpty(obj) {
|
|
128
|
+
return obj === undefined || Object.keys(obj).length === 0;
|
|
129
|
+
}
|
|
130
|
+
static pick(object, paths) {
|
|
131
|
+
const result = {};
|
|
132
|
+
for (const path of paths) {
|
|
133
|
+
if (path in object) {
|
|
134
|
+
result[path] = object[path];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
static pickBy(object) {
|
|
140
|
+
const result = {};
|
|
141
|
+
for (const key in object) {
|
|
142
|
+
if (object[key]) {
|
|
143
|
+
result[key] = object[key];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
81
148
|
}
|
|
82
149
|
exports.SendKeyStep = SendKeyStep;
|
|
83
|
-
SendKeyStep.
|
|
84
|
-
SendKeyStep.
|
|
150
|
+
SendKeyStep.stepName = 'SendKeys';
|
|
151
|
+
SendKeyStep.actionCode = 'send_keys';
|
|
152
|
+
SendKeyStep.mablScriptStepNames = [SendKeyStep.actionCode];
|
|
153
|
+
SendKeyStep.yamlMablScriptNames = [SendKeyStep.stepName];
|
|
154
|
+
SendKeyStep.modifierKeyHumanizedMap = {
|
|
155
|
+
altKey: 'Alt',
|
|
156
|
+
ctrlKey: 'Ctrl',
|
|
157
|
+
metaKey: 'Cmd',
|
|
158
|
+
shiftKey: 'Shift',
|
|
159
|
+
};
|
|
160
|
+
SendKeyStep.modifierKeyIdentifierMap = {
|
|
161
|
+
altKey: false,
|
|
162
|
+
ctrlKey: false,
|
|
163
|
+
metaKey: false,
|
|
164
|
+
shiftKey: false,
|
|
165
|
+
};
|
|
166
|
+
SendKeyStep.specialKeys = [
|
|
167
|
+
'Enter',
|
|
168
|
+
'Tab',
|
|
169
|
+
'Escape',
|
|
170
|
+
'Backspace',
|
|
171
|
+
'Delete',
|
|
172
|
+
'ArrowUp',
|
|
173
|
+
'ArrowDown',
|
|
174
|
+
'ArrowLeft',
|
|
175
|
+
'ArrowRight',
|
|
176
|
+
'Home',
|
|
177
|
+
'End',
|
|
178
|
+
'PageUp',
|
|
179
|
+
'PageDown',
|
|
180
|
+
'Insert',
|
|
181
|
+
'F1',
|
|
182
|
+
'F2',
|
|
183
|
+
'F3',
|
|
184
|
+
'F4',
|
|
185
|
+
'F5',
|
|
186
|
+
'F6',
|
|
187
|
+
'F7',
|
|
188
|
+
'F8',
|
|
189
|
+
'F9',
|
|
190
|
+
'F10',
|
|
191
|
+
'F11',
|
|
192
|
+
'F12',
|
|
193
|
+
];
|
|
194
|
+
function buildStepDescriptor(findAction, keys) {
|
|
195
|
+
const find = findAction.toDescriptor();
|
|
196
|
+
switch (find.findType) {
|
|
197
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
198
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
199
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
200
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
201
|
+
return {
|
|
202
|
+
find,
|
|
203
|
+
keys,
|
|
204
|
+
descriptorToActionMap: new Map().set(find, findAction),
|
|
205
|
+
actionCode: 'send_keys',
|
|
206
|
+
};
|
|
207
|
+
default:
|
|
208
|
+
throw new Error(`Error generating step descriptor for SendKeys: Unexpected find type ${find.findType}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetCookieStep = void 0;
|
|
4
|
-
const
|
|
4
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
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.
|
|
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
|
-
}
|
|
8
|
+
class SetCookieStep extends MablStepV2_1.MablStepV2 {
|
|
9
|
+
constructor(descriptor) {
|
|
10
|
+
super(SetCookieStep.stepName, descriptor, SetCookieStep.actionCode);
|
|
11
|
+
this.cookieName = descriptor.name;
|
|
12
|
+
this.cookieValue = descriptor.value;
|
|
13
|
+
this.cookieOptions = descriptor.options;
|
|
26
14
|
}
|
|
27
15
|
getStepName() {
|
|
28
|
-
return
|
|
16
|
+
return SetCookieStep.stepName;
|
|
29
17
|
}
|
|
30
18
|
toStepDescriptor() {
|
|
31
19
|
return {
|
|
@@ -36,10 +24,52 @@ class SetCookieStep extends MablStep_1.MablStep {
|
|
|
36
24
|
};
|
|
37
25
|
}
|
|
38
26
|
static fromYaml(_stepName, stepArgs) {
|
|
39
|
-
const
|
|
27
|
+
const cookieName = CookieUtils_1.CookieUtils.normalizeName(stepArgs.name);
|
|
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);
|
|
40
46
|
step.setStepId(stepArgs.id);
|
|
41
47
|
return step;
|
|
42
48
|
}
|
|
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
|
+
const step = new SetCookieStep(stepDescriptor);
|
|
70
|
+
step.actions = _actions;
|
|
71
|
+
return step;
|
|
72
|
+
}
|
|
43
73
|
toMablscript() {
|
|
44
74
|
const cookieSelector = {
|
|
45
75
|
name: this.cookieName,
|
|
@@ -63,7 +93,12 @@ class SetCookieStep extends MablStep_1.MablStep {
|
|
|
63
93
|
...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.cookieValue),
|
|
64
94
|
]);
|
|
65
95
|
}
|
|
96
|
+
stepDescription() {
|
|
97
|
+
return `Set cookie: "${this.cookieName}"`;
|
|
98
|
+
}
|
|
66
99
|
}
|
|
67
100
|
exports.SetCookieStep = SetCookieStep;
|
|
68
|
-
SetCookieStep.
|
|
69
|
-
SetCookieStep.
|
|
101
|
+
SetCookieStep.stepName = 'SetCookie';
|
|
102
|
+
SetCookieStep.actionCode = 'set_cookie';
|
|
103
|
+
SetCookieStep.mablScriptStepNames = [SetCookieStep.actionCode];
|
|
104
|
+
SetCookieStep.yamlMablScriptNames = [SetCookieStep.stepName];
|
|
@@ -5,57 +5,33 @@ 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");
|
|
8
9
|
class SetFilesStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
11
|
-
this.files =
|
|
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
|
-
}
|
|
10
|
+
constructor(descriptor, findAction) {
|
|
11
|
+
super(SetFilesStep.stepName, descriptor, SetFilesStep.actionCode, findAction);
|
|
12
|
+
this.files = descriptor.files;
|
|
19
13
|
}
|
|
20
14
|
getStepName() {
|
|
21
|
-
return
|
|
15
|
+
return SetFilesStep.stepName;
|
|
22
16
|
}
|
|
23
17
|
toStepDescriptor() {
|
|
24
|
-
|
|
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;
|
|
18
|
+
return buildStepDescriptor(this.findAction, this.files);
|
|
51
19
|
}
|
|
52
20
|
static fromYaml(_stepName, stepArgs) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
|
|
22
|
+
const stepDescriptor = buildStepDescriptor(findAction, stepArgs.files);
|
|
23
|
+
const step = new SetFilesStep(stepDescriptor, findAction);
|
|
56
24
|
step.setStepId(stepArgs.id);
|
|
57
25
|
return step;
|
|
58
26
|
}
|
|
27
|
+
static fromLegacyMablscript(args, actions) {
|
|
28
|
+
const files = args;
|
|
29
|
+
const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
|
|
30
|
+
const stepDescriptor = buildStepDescriptor(findAction, files);
|
|
31
|
+
const step = new SetFilesStep(stepDescriptor, findAction);
|
|
32
|
+
step.actions = actions;
|
|
33
|
+
return step;
|
|
34
|
+
}
|
|
59
35
|
toMablscript() {
|
|
60
36
|
const files = this.files
|
|
61
37
|
.map((key) => (0, MablAction_1.convertObjectToMablscriptArgs)(key))
|
|
@@ -65,7 +41,32 @@ class SetFilesStep extends MablStepWithFindAction_1.MablStepWithFindAction {
|
|
|
65
41
|
getInputVariables() {
|
|
66
42
|
return this.findAction.getInputVariables();
|
|
67
43
|
}
|
|
44
|
+
stepDescription() {
|
|
45
|
+
const fileCount = this.files.length;
|
|
46
|
+
const fileText = fileCount === 1 ? 'file' : 'files';
|
|
47
|
+
const elementDescription = this.humanizeFind();
|
|
48
|
+
return `Set ${fileCount} ${fileText} on ${elementDescription}`;
|
|
49
|
+
}
|
|
68
50
|
}
|
|
69
51
|
exports.SetFilesStep = SetFilesStep;
|
|
70
|
-
SetFilesStep.
|
|
71
|
-
SetFilesStep.
|
|
52
|
+
SetFilesStep.stepName = 'SetFiles';
|
|
53
|
+
SetFilesStep.actionCode = 'set_files';
|
|
54
|
+
SetFilesStep.mablScriptStepNames = [SetFilesStep.actionCode];
|
|
55
|
+
SetFilesStep.yamlMablScriptNames = [SetFilesStep.stepName];
|
|
56
|
+
function buildStepDescriptor(findAction, files) {
|
|
57
|
+
const find = findAction.toDescriptor();
|
|
58
|
+
switch (find.findType) {
|
|
59
|
+
case domUtil_1.FindType.FIND_FIRST:
|
|
60
|
+
case domUtil_1.FindType.FIND_LAST:
|
|
61
|
+
case domUtil_1.FindType.FIND_ANY:
|
|
62
|
+
case domUtil_1.FindType.FIND_ONE:
|
|
63
|
+
return {
|
|
64
|
+
files,
|
|
65
|
+
find,
|
|
66
|
+
descriptorToActionMap: new Map().set(find, findAction),
|
|
67
|
+
actionCode: SetFilesStep.actionCode,
|
|
68
|
+
};
|
|
69
|
+
default:
|
|
70
|
+
throw new Error(`Error generating step descriptor for ${SetFilesStep.stepName}: Unexpected find type ${find.findType}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,22 +1,30 @@
|
|
|
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
|
-
|
|
9
|
-
this.size = viewportArg?.size;
|
|
4
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
5
|
+
class SetViewportStep extends MablStepV2_1.MablStepV2 {
|
|
6
|
+
constructor(descriptor) {
|
|
7
|
+
super(SetViewportStep.stepName, descriptor, SetViewportStep.actionCode);
|
|
8
|
+
this.size = descriptor.size;
|
|
10
9
|
}
|
|
11
10
|
getStepName() {
|
|
12
|
-
return
|
|
11
|
+
return SetViewportStep.stepName;
|
|
13
12
|
}
|
|
14
13
|
toStepDescriptor() {
|
|
15
14
|
return { size: this.size, actionCode: this.actionCode };
|
|
16
15
|
}
|
|
17
|
-
static fromYaml(_stepName,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
static fromYaml(_stepName, stepDescriptor) {
|
|
17
|
+
return new SetViewportStep(stepDescriptor);
|
|
18
|
+
}
|
|
19
|
+
static fromLegacyMablscript(args, _actions) {
|
|
20
|
+
const stepDescriptor = {
|
|
21
|
+
size: {
|
|
22
|
+
width: args[0]?.size?.width ?? undefined,
|
|
23
|
+
height: args[0]?.size?.height ?? undefined,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const step = new SetViewportStep(stepDescriptor);
|
|
27
|
+
step.actions = _actions;
|
|
20
28
|
return step;
|
|
21
29
|
}
|
|
22
30
|
toMablscript() {
|
|
@@ -32,7 +40,27 @@ class SetViewportStep extends MablStep_1.MablStep {
|
|
|
32
40
|
}
|
|
33
41
|
return `set_viewport(${sizeArg})`;
|
|
34
42
|
}
|
|
43
|
+
stepDescription() {
|
|
44
|
+
if (this.size) {
|
|
45
|
+
let message = 'Set viewport size';
|
|
46
|
+
const width = this.size.width;
|
|
47
|
+
const height = this.size.height;
|
|
48
|
+
if (width) {
|
|
49
|
+
message += ` to width ${width}`;
|
|
50
|
+
if (height) {
|
|
51
|
+
message += ` and height ${height}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (height) {
|
|
55
|
+
message += ` to height ${height}`;
|
|
56
|
+
}
|
|
57
|
+
return message;
|
|
58
|
+
}
|
|
59
|
+
return `Invalid set viewport step definition`;
|
|
60
|
+
}
|
|
35
61
|
}
|
|
36
62
|
exports.SetViewportStep = SetViewportStep;
|
|
37
|
-
SetViewportStep.
|
|
38
|
-
SetViewportStep.
|
|
63
|
+
SetViewportStep.stepName = 'SetViewport';
|
|
64
|
+
SetViewportStep.actionCode = 'set_viewport';
|
|
65
|
+
SetViewportStep.mablScriptStepNames = [SetViewportStep.actionCode];
|
|
66
|
+
SetViewportStep.yamlMablScriptNames = [SetViewportStep.stepName];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StepGroupStep = void 0;
|
|
4
|
+
const MablAction_1 = require("../MablAction");
|
|
5
|
+
const MablStepV2_1 = require("../MablStepV2");
|
|
6
|
+
const importer_1 = require("../importer");
|
|
7
|
+
class StepGroupStep extends MablStepV2_1.MablStepV2 {
|
|
8
|
+
constructor(descriptor) {
|
|
9
|
+
super(StepGroupStep.stepName, descriptor, StepGroupStep.actionCode);
|
|
10
|
+
this.intent = descriptor.intent;
|
|
11
|
+
this.steps = this.createStepsFromDescriptors(descriptor.steps);
|
|
12
|
+
}
|
|
13
|
+
createStepsFromDescriptors(stepDescriptors) {
|
|
14
|
+
return (0, importer_1.interpretStepsFromObjects)(stepDescriptors);
|
|
15
|
+
}
|
|
16
|
+
getStepName() {
|
|
17
|
+
return StepGroupStep.stepName;
|
|
18
|
+
}
|
|
19
|
+
toStepDescriptor() {
|
|
20
|
+
const steps = this.steps.map((step) => ({
|
|
21
|
+
[step.getStepName()]: step.toStepDescriptor(true),
|
|
22
|
+
}));
|
|
23
|
+
return {
|
|
24
|
+
steps,
|
|
25
|
+
intent: this.intent,
|
|
26
|
+
actionCode: this.actionCode,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static fromYaml(_stepName, stepArgs) {
|
|
30
|
+
const stepDescriptor = {
|
|
31
|
+
steps: stepArgs.steps || [],
|
|
32
|
+
intent: stepArgs.intent || { description: '' },
|
|
33
|
+
actionCode: StepGroupStep.actionCode,
|
|
34
|
+
};
|
|
35
|
+
const step = new StepGroupStep(stepDescriptor);
|
|
36
|
+
step.setStepId(stepArgs.id);
|
|
37
|
+
return step;
|
|
38
|
+
}
|
|
39
|
+
static fromLegacyMablscript(_args, _actions) {
|
|
40
|
+
throw new Error('Legacy mablscript conversion not supported for StepGroupStep');
|
|
41
|
+
}
|
|
42
|
+
toMablscript() {
|
|
43
|
+
throw new Error('Legacy mablscript generation not supported for StepGroupStep');
|
|
44
|
+
}
|
|
45
|
+
stepDescription() {
|
|
46
|
+
return `Step Group: "${this.intent.description}" (${this.steps.length} steps)`;
|
|
47
|
+
}
|
|
48
|
+
getInputVariables() {
|
|
49
|
+
const inputVariables = this.steps.flatMap((step) => {
|
|
50
|
+
if (typeof step.getInputVariables === 'function') {
|
|
51
|
+
return step.getInputVariables();
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
});
|
|
55
|
+
return (0, MablAction_1.distinctStrings)(inputVariables);
|
|
56
|
+
}
|
|
57
|
+
getOutputVariables() {
|
|
58
|
+
return this.steps.flatMap((step) => {
|
|
59
|
+
if (typeof step.getOutputVariables === 'function') {
|
|
60
|
+
return step.getOutputVariables();
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.StepGroupStep = StepGroupStep;
|
|
67
|
+
StepGroupStep.stepName = 'StepGroup';
|
|
68
|
+
StepGroupStep.actionCode = 'step_group';
|
|
69
|
+
StepGroupStep.mablScriptStepNames = [StepGroupStep.actionCode];
|
|
70
|
+
StepGroupStep.yamlMablScriptNames = [StepGroupStep.stepName];
|