@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,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssertStep = exports.assertStepYamlMablscriptNames = exports.MAX_AI_ASSERTIONS_PER_CLOUD_RUN = exports.OnFailure = void 0;
|
|
4
|
-
exports.buildAssertStepDescriptor = buildAssertStepDescriptor;
|
|
5
4
|
const ConditionAction_1 = require("../actions/ConditionAction");
|
|
6
5
|
const FindAction_1 = require("../actions/FindAction");
|
|
6
|
+
const MablStep_1 = require("../MablStep");
|
|
7
7
|
const MablAction_1 = require("../MablAction");
|
|
8
8
|
const ExtractAction_1 = require("../actions/ExtractAction");
|
|
9
9
|
const domUtil_1 = require("../../domUtil");
|
|
@@ -16,9 +16,6 @@ const CountAction_1 = require("../actions/CountAction");
|
|
|
16
16
|
const MobileFindAction_1 = require("../mobile/steps/actions/MobileFindAction");
|
|
17
17
|
const GetViewportDescriptor_1 = require("../types/GetViewportDescriptor");
|
|
18
18
|
const GetViewportAction_1 = require("../actions/GetViewportAction");
|
|
19
|
-
const MablStepV2_1 = require("../MablStepV2");
|
|
20
|
-
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
|
|
21
|
-
const AssertStepOld_1 = require("./AssertStepOld");
|
|
22
19
|
var OnFailure;
|
|
23
20
|
(function (OnFailure) {
|
|
24
21
|
OnFailure["ContinueWithWarning"] = "continue";
|
|
@@ -32,11 +29,9 @@ const assertStepYamlMablscriptNames = () => {
|
|
|
32
29
|
return assertionNames;
|
|
33
30
|
};
|
|
34
31
|
exports.assertStepYamlMablscriptNames = assertStepYamlMablscriptNames;
|
|
35
|
-
class AssertStep extends
|
|
36
|
-
constructor(name, args, actions
|
|
37
|
-
|
|
38
|
-
super(name, stepDescriptor, AssertStep.actionCode);
|
|
39
|
-
this.actions = actions;
|
|
32
|
+
class AssertStep extends MablStep_1.MablStep {
|
|
33
|
+
constructor(name, args, actions) {
|
|
34
|
+
super(name, args, actions, 'assert');
|
|
40
35
|
const firstAction = actions[0];
|
|
41
36
|
if (firstAction instanceof FindAction_1.FindAction ||
|
|
42
37
|
firstAction instanceof MobileFindAction_1.MobileFindAction ||
|
|
@@ -77,13 +72,14 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
77
72
|
this.assertionType = (0, ConditionDescriptor_1.getAssertionConditionFieldFromDescriptor)(this.conditionAction.conditionDescriptor);
|
|
78
73
|
this.assertionValue = (0, ConditionDescriptor_1.getOptionalComparatorValue)(this.conditionAction.conditionDescriptor);
|
|
79
74
|
this.isWaitUntilStep = this.determineIfWaitUntilStep();
|
|
75
|
+
this.assertArguments =
|
|
76
|
+
args[0] && typeof args[0] === 'object'
|
|
77
|
+
? args[0]
|
|
78
|
+
: undefined;
|
|
80
79
|
this.onFailure =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if ('observationScope' in stepDescriptor) {
|
|
85
|
-
this.observationScope = stepDescriptor.observationScope;
|
|
86
|
-
}
|
|
80
|
+
this.assertArguments?.onFailure ||
|
|
81
|
+
OnFailure.FailImmediately;
|
|
82
|
+
this.observationScope = this.assertArguments?.observationScope;
|
|
87
83
|
}
|
|
88
84
|
canContinueOnFailure() {
|
|
89
85
|
return this.onFailure !== OnFailure.FailImmediately;
|
|
@@ -116,47 +112,77 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
116
112
|
return ConditionDescriptor_1.AssertionConditionFieldToStepName[this.assertionType];
|
|
117
113
|
}
|
|
118
114
|
toStepDescriptor() {
|
|
119
|
-
const
|
|
115
|
+
const find = this.primaryAction.toDescriptor();
|
|
120
116
|
const descriptorToActionMap = new Map()
|
|
121
|
-
.set(
|
|
117
|
+
.set(find, this.primaryAction)
|
|
122
118
|
.set(this.conditionAction.conditionDescriptor, this.conditionAction);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
descriptorToActionMap.set(extractDescriptor, this.extractAction);
|
|
119
|
+
if (this.extractAction) {
|
|
120
|
+
descriptorToActionMap.set(this.extractAction.extractDescriptor, this.extractAction);
|
|
126
121
|
}
|
|
127
122
|
if (this.countAction) {
|
|
128
123
|
descriptorToActionMap.set(this.countAction.countDescriptor, this.countAction);
|
|
129
124
|
}
|
|
130
125
|
return {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
find,
|
|
127
|
+
extractDescriptor: this.extractAction?.extractDescriptor,
|
|
128
|
+
conditionDescriptor: this.conditionAction.conditionDescriptor,
|
|
129
|
+
countDescriptor: this.countAction?.countDescriptor,
|
|
135
130
|
onFailure: this.onFailure,
|
|
136
131
|
observationScope: this.observationScope,
|
|
137
132
|
descriptorToActionMap,
|
|
138
133
|
actionCode: this.actionCode,
|
|
139
134
|
};
|
|
140
135
|
}
|
|
136
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
137
|
+
const result = {};
|
|
138
|
+
result[this.getStepName()] = { ...this.annotationsAsYml() };
|
|
139
|
+
const formatted = result[this.getStepName()];
|
|
140
|
+
if (this.extractAction) {
|
|
141
|
+
formatted.attribute = this.extractAction.extractionAttribute;
|
|
142
|
+
formatted.extractType =
|
|
143
|
+
ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
|
|
144
|
+
}
|
|
145
|
+
if (this.countAction) {
|
|
146
|
+
formatted.attribute = 'count';
|
|
147
|
+
}
|
|
148
|
+
if (this.assertionValue !== undefined) {
|
|
149
|
+
formatted.assertionValue = this.assertionValue;
|
|
150
|
+
}
|
|
151
|
+
if (this.aiPrompt !== undefined) {
|
|
152
|
+
formatted.aiPrompt = this.aiPrompt;
|
|
153
|
+
}
|
|
154
|
+
const targetDescriptor = this.primaryAction.toDescriptor();
|
|
155
|
+
if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
|
|
156
|
+
formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
formatted.target = targetDescriptor;
|
|
160
|
+
}
|
|
161
|
+
if (this.conditionAction.hasOptionsAtInstantiation) {
|
|
162
|
+
formatted.conditionOptions = (0, ConditionDescriptor_1.getOptionalConditionOptions)(this.conditionAction.conditionDescriptor);
|
|
163
|
+
}
|
|
164
|
+
if (!!this.assertArguments?.observationScope ||
|
|
165
|
+
!!this.assertArguments?.onFailure) {
|
|
166
|
+
formatted.assertArguments = this.assertArguments;
|
|
167
|
+
}
|
|
168
|
+
result[this.getStepName()] =
|
|
169
|
+
MablStep_1.MablStep.cloneAndRemoveUndefinedEntriesFromObject(formatted);
|
|
170
|
+
if (this.stepId()) {
|
|
171
|
+
result[this.getStepName()].id = this.stepId();
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
141
175
|
static fromYaml(stepName, stepArgs) {
|
|
142
176
|
const actions = [];
|
|
143
177
|
const assertionType = ConditionDescriptor_1.AssertionStepNameToField[stepName];
|
|
144
|
-
const assertionValue = stepArgs.assertionValue
|
|
145
|
-
|
|
146
|
-
stepArgs.condition?.comparatorValue;
|
|
147
|
-
const conditionOptions = stepArgs.conditionOptions
|
|
148
|
-
?.caseInsensitive
|
|
149
|
-
? { caseInsensitive: stepArgs.conditionOptions.caseInsensitive }
|
|
150
|
-
: {
|
|
151
|
-
caseInsensitive: stepArgs.conditionDescriptor?.caseInsensitive ??
|
|
152
|
-
stepArgs.condition?.caseInsensitive,
|
|
153
|
-
};
|
|
178
|
+
const assertionValue = stepArgs.assertionValue;
|
|
179
|
+
const conditionOptions = stepArgs.conditionOptions;
|
|
154
180
|
let primaryAction;
|
|
155
181
|
if (stepArgs.target?.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
156
182
|
primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
|
|
157
183
|
}
|
|
158
|
-
else if (
|
|
159
|
-
primaryAction = GetVariableValue_1.GetVariableValue.
|
|
184
|
+
else if (stepArgs.target?.kind === GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
185
|
+
primaryAction = new GetVariableValue_1.GetVariableValue(GetVariableValue_1.GetVariableValue.mablScriptStepNames[0], [stepArgs.target?.variable]);
|
|
160
186
|
}
|
|
161
187
|
else if ((0, GetViewportDescriptor_1.isGetViewportDescriptor)(stepArgs.target)) {
|
|
162
188
|
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
@@ -173,10 +199,7 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
173
199
|
else if ((0, domUtil_1.isFindElementDescriptor)(stepArgs.target)) {
|
|
174
200
|
const { findOptions, findTarget, findType } = stepArgs.target;
|
|
175
201
|
if (findType === domUtil_1.FindType.FIND_ONE) {
|
|
176
|
-
|
|
177
|
-
? findTarget
|
|
178
|
-
: findTarget.selector;
|
|
179
|
-
primaryAction = new FindAction_1.FindAction(findType, [findArgument, findOptions]);
|
|
202
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
180
203
|
}
|
|
181
204
|
else {
|
|
182
205
|
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
@@ -186,106 +209,41 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
186
209
|
throw new Error(`Error parsing [${stepName}] with incompatible step arguments`);
|
|
187
210
|
}
|
|
188
211
|
actions.push(primaryAction);
|
|
189
|
-
let extractAction;
|
|
190
|
-
let countAction;
|
|
191
|
-
let conditionAction;
|
|
192
212
|
if (assertionType === 'ai_prompt') {
|
|
193
|
-
|
|
194
|
-
stepArgs.userPrompt ??
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
stepArgs.conditionDescriptor?.metaPrompt ??
|
|
201
|
-
stepArgs.condition?.metaPrompt;
|
|
202
|
-
const criteria = stepArgs.aiPrompt?.criteria ??
|
|
203
|
-
stepArgs.conditionDescriptor?.criteria ??
|
|
204
|
-
stepArgs.condition?.criteria;
|
|
205
|
-
if (metaPrompt || criteria) {
|
|
206
|
-
conditionArgs.push({
|
|
207
|
-
metaPrompt,
|
|
208
|
-
criteria,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
conditionAction = new ConditionAction_1.ConditionAction('evaluate_ai_prompt', conditionArgs);
|
|
212
|
-
actions.push(conditionAction);
|
|
213
|
+
actions.push(new ConditionAction_1.ConditionAction('evaluate_ai_prompt', [
|
|
214
|
+
stepArgs.aiPrompt?.userPrompt ?? stepArgs.userPrompt,
|
|
215
|
+
{
|
|
216
|
+
metaPrompt: stepArgs.aiPrompt?.metaPrompt ?? stepArgs.metaPrompt,
|
|
217
|
+
criteria: stepArgs.aiPrompt?.criteria,
|
|
218
|
+
},
|
|
219
|
+
]));
|
|
213
220
|
}
|
|
214
221
|
else if (assertionType === 'present' || assertionType === 'not_present') {
|
|
215
|
-
|
|
216
|
-
assertionType,
|
|
217
|
-
]);
|
|
218
|
-
actions.push(conditionAction);
|
|
222
|
+
actions.push(new ConditionAction_1.ConditionAction('evaluate_presence', [assertionType]));
|
|
219
223
|
}
|
|
220
224
|
else if (stepName === 'WaitUntil') {
|
|
221
|
-
|
|
222
|
-
actions.push(conditionAction);
|
|
225
|
+
actions.push(new ConditionAction_1.ConditionAction('evaluate_presence', ['present']));
|
|
223
226
|
}
|
|
224
227
|
else {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
stepArgs.count?.count;
|
|
228
|
-
const attributeName = stepArgs.attribute ??
|
|
229
|
-
stepArgs.extractDescriptor?.attributeName ??
|
|
230
|
-
stepArgs.extract?.attributeName;
|
|
231
|
-
if (isCountAssertion) {
|
|
232
|
-
countAction = new CountAction_1.CountAction('count', ['count']);
|
|
233
|
-
actions.push(countAction);
|
|
228
|
+
if (stepArgs.attribute === 'count') {
|
|
229
|
+
actions.push(new CountAction_1.CountAction('count', [stepArgs.attribute]));
|
|
234
230
|
}
|
|
235
|
-
else if (stepArgs.target?.kind !== GetVariableDescriptor_1.GET_VARIABLE_VALUE
|
|
236
|
-
|
|
237
|
-
const extractType = stepArgs.extractType ??
|
|
238
|
-
stepArgs.extractDescriptor?.extractType ??
|
|
239
|
-
stepArgs.extract?.extractType;
|
|
240
|
-
const extractArgs = [attributeName];
|
|
241
|
-
if (extractType === 'extract_css_properties') {
|
|
242
|
-
extractArgs.push({ extraction_type: 'css' });
|
|
243
|
-
}
|
|
244
|
-
extractAction = new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(extractType), extractArgs);
|
|
245
|
-
actions.push(extractAction);
|
|
231
|
+
else if (stepArgs.target?.kind !== GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
232
|
+
actions.push(new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(stepArgs.extractType), [stepArgs.attribute]));
|
|
246
233
|
}
|
|
247
|
-
|
|
234
|
+
actions.push(new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
248
235
|
assertionType,
|
|
249
236
|
assertionValue,
|
|
250
237
|
conditionOptions,
|
|
251
|
-
]);
|
|
252
|
-
actions.push(conditionAction);
|
|
238
|
+
]));
|
|
253
239
|
}
|
|
254
|
-
const
|
|
255
|
-
const onFailure = stepArgs.onFailure ?? stepArgs.assertArguments?.onFailure;
|
|
256
|
-
const observationScope = stepArgs.observationScope ?? stepArgs.assertArguments?.observationScope;
|
|
257
|
-
const descriptorToActionMap = new Map()
|
|
258
|
-
.set(target, primaryAction)
|
|
259
|
-
.set(conditionAction.conditionDescriptor, conditionAction);
|
|
260
|
-
if (extractAction) {
|
|
261
|
-
descriptorToActionMap.set(extractAction.toDescriptor(), extractAction);
|
|
262
|
-
}
|
|
263
|
-
if (countAction) {
|
|
264
|
-
descriptorToActionMap.set(countAction.countDescriptor, countAction);
|
|
265
|
-
}
|
|
266
|
-
const stepDescriptor = {
|
|
267
|
-
target,
|
|
268
|
-
extract: extractAction?.toDescriptor(),
|
|
269
|
-
condition: conditionAction.conditionDescriptor,
|
|
270
|
-
count: countAction?.countDescriptor,
|
|
271
|
-
onFailure,
|
|
272
|
-
observationScope,
|
|
273
|
-
descriptorToActionMap,
|
|
274
|
-
actionCode: AssertStep.actionCode,
|
|
275
|
-
description: stepArgs.description,
|
|
276
|
-
disabled: stepArgs.disabled,
|
|
277
|
-
};
|
|
278
|
-
const assertStep = new AssertStep('assert', [], actions, stepDescriptor);
|
|
240
|
+
const assertStep = new AssertStep('assert', [stepArgs.assertArguments], actions);
|
|
279
241
|
if (stepArgs.annotation) {
|
|
280
242
|
assertStep.setAnnotation(stepArgs.annotation);
|
|
281
243
|
}
|
|
282
244
|
assertStep.setStepId(stepArgs.id);
|
|
283
245
|
return assertStep;
|
|
284
246
|
}
|
|
285
|
-
static fromLegacyMablscript(args, actions) {
|
|
286
|
-
const stepDescriptor = buildAssertStepDescriptor('assert', args, actions);
|
|
287
|
-
return new AssertStep('assert', [], [], stepDescriptor);
|
|
288
|
-
}
|
|
289
247
|
toMablscript() {
|
|
290
248
|
if (this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
291
249
|
throw new Error('Mobile steps do not generate mablscript');
|
|
@@ -298,11 +256,13 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
298
256
|
if (primaryActionFindMablscriptPrefix.length > 0) {
|
|
299
257
|
primaryActionFindMablscriptPrefix += '.';
|
|
300
258
|
}
|
|
301
|
-
const assertAction = `.assert(${!!(this.
|
|
302
|
-
|
|
259
|
+
const assertAction = `.assert(${!!(this.assertArguments?.onFailure ||
|
|
260
|
+
this.assertArguments?.observationScope)
|
|
303
261
|
? (0, MablAction_1.convertObjectToMablscriptArgs)({
|
|
304
|
-
|
|
305
|
-
onFailure: this.onFailure
|
|
262
|
+
...this.assertArguments,
|
|
263
|
+
onFailure: this.assertArguments?.onFailure === OnFailure.FailImmediately
|
|
264
|
+
? undefined
|
|
265
|
+
: this.assertArguments?.onFailure,
|
|
306
266
|
})
|
|
307
267
|
: ''})`;
|
|
308
268
|
if (this.countAction) {
|
|
@@ -346,147 +306,7 @@ class AssertStep extends MablStepV2_1.MablStepV2 {
|
|
|
346
306
|
...(this.extractAction?.getInputVariables() ?? []),
|
|
347
307
|
]);
|
|
348
308
|
}
|
|
349
|
-
stepDescription() {
|
|
350
|
-
if (this.assertionType === 'ai_prompt') {
|
|
351
|
-
return `Assert AI prompt: "${this.aiPrompt?.userPrompt}"`;
|
|
352
|
-
}
|
|
353
|
-
if (this.isWaitUntilStep) {
|
|
354
|
-
const elementDescription = this.humanizeFind();
|
|
355
|
-
return `Wait until ${elementDescription} is present`;
|
|
356
|
-
}
|
|
357
|
-
const elementDescription = this.humanizeFind();
|
|
358
|
-
if (this.assertionType === 'present') {
|
|
359
|
-
return `Assert that ${elementDescription} is present`;
|
|
360
|
-
}
|
|
361
|
-
if (this.assertionType === 'not_present') {
|
|
362
|
-
return `Assert that ${elementDescription} is not present`;
|
|
363
|
-
}
|
|
364
|
-
if (this.countAction) {
|
|
365
|
-
const comparator = this.getComparatorText();
|
|
366
|
-
return `Assert that count of ${elementDescription} ${comparator} ${this.assertionValue}`;
|
|
367
|
-
}
|
|
368
|
-
if (this.extractAction) {
|
|
369
|
-
const attribute = this.extractAction.extractionAttribute;
|
|
370
|
-
const comparator = this.getComparatorText();
|
|
371
|
-
return `Assert that ${attribute} of ${elementDescription} ${comparator} ${this.assertionValue}`;
|
|
372
|
-
}
|
|
373
|
-
const comparator = this.getComparatorText();
|
|
374
|
-
return `Assert that ${elementDescription} ${comparator} ${this.assertionValue}`;
|
|
375
|
-
}
|
|
376
|
-
humanizeFind() {
|
|
377
|
-
if (this.primaryAction instanceof GetUrlAction_1.GetUrlAction) {
|
|
378
|
-
return 'current URL';
|
|
379
|
-
}
|
|
380
|
-
if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
381
|
-
return `variable {{${this.primaryAction.variableName}}}`;
|
|
382
|
-
}
|
|
383
|
-
if (this.primaryAction instanceof GetViewportAction_1.GetViewportAction) {
|
|
384
|
-
return 'viewport';
|
|
385
|
-
}
|
|
386
|
-
if (this.primaryAction instanceof FindAction_1.FindAction) {
|
|
387
|
-
const findDescriptor = this.primaryAction.toDescriptor();
|
|
388
|
-
return (0, MablStepWithFindAction_1.humanizeFindDescriptor)(findDescriptor);
|
|
389
|
-
}
|
|
390
|
-
return 'element';
|
|
391
|
-
}
|
|
392
|
-
getComparatorText() {
|
|
393
|
-
switch (this.assertionType) {
|
|
394
|
-
case 'equals':
|
|
395
|
-
return 'equals';
|
|
396
|
-
case 'does_not_equal':
|
|
397
|
-
return 'does not equal';
|
|
398
|
-
case 'contains':
|
|
399
|
-
return 'contains';
|
|
400
|
-
case 'does_not_contain':
|
|
401
|
-
return 'does not contain';
|
|
402
|
-
case 'matches_regex':
|
|
403
|
-
return 'matches';
|
|
404
|
-
case 'greater_than':
|
|
405
|
-
return 'is greater than';
|
|
406
|
-
case 'less_than':
|
|
407
|
-
return 'is less than';
|
|
408
|
-
case 'greater_than_or_equals':
|
|
409
|
-
return 'is greater than or equal to';
|
|
410
|
-
case 'less_than_or_equals':
|
|
411
|
-
return 'is less than or equal to';
|
|
412
|
-
case 'starts_with':
|
|
413
|
-
return 'starts with';
|
|
414
|
-
case 'starts_without':
|
|
415
|
-
return 'starts without';
|
|
416
|
-
case 'ends_with':
|
|
417
|
-
return 'ends with';
|
|
418
|
-
case 'ends_without':
|
|
419
|
-
return 'ends without';
|
|
420
|
-
default:
|
|
421
|
-
return 'is';
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
309
|
}
|
|
425
310
|
exports.AssertStep = AssertStep;
|
|
426
|
-
AssertStep.
|
|
427
|
-
AssertStep.mablScriptStepNames = [
|
|
428
|
-
AssertStep.actionCode,
|
|
429
|
-
...Object.keys(AssertStepOld_1.oldToV2StepNameMap),
|
|
430
|
-
];
|
|
311
|
+
AssertStep.mablScriptStepNames = ['assert'];
|
|
431
312
|
AssertStep.yamlMablScriptNames = (0, exports.assertStepYamlMablscriptNames)();
|
|
432
|
-
function buildAssertStepDescriptor(_name, args, actions) {
|
|
433
|
-
const firstAction = actions[0];
|
|
434
|
-
let primaryAction;
|
|
435
|
-
if (firstAction instanceof FindAction_1.FindAction ||
|
|
436
|
-
firstAction instanceof MobileFindAction_1.MobileFindAction ||
|
|
437
|
-
firstAction instanceof GetUrlAction_1.GetUrlAction ||
|
|
438
|
-
firstAction instanceof GetVariableValue_1.GetVariableValue ||
|
|
439
|
-
firstAction instanceof GetViewportAction_1.GetViewportAction) {
|
|
440
|
-
primaryAction = firstAction;
|
|
441
|
-
}
|
|
442
|
-
else if (firstAction instanceof ConditionAction_1.ConditionAction &&
|
|
443
|
-
(0, ConditionDescriptor_1.isAIPromptCondition)(firstAction.conditionDescriptor)) {
|
|
444
|
-
primaryAction = new GetViewportAction_1.GetViewportAction();
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
throw new Error(`Unexpected action type. Expected FindAction|MobileFindAction|GetUrlAction|GetVariableValue but got: ${firstAction.constructor.name}`);
|
|
448
|
-
}
|
|
449
|
-
let extractAction;
|
|
450
|
-
let countAction;
|
|
451
|
-
let conditionAction;
|
|
452
|
-
if (actions.length === 3) {
|
|
453
|
-
if (actions[1] instanceof CountAction_1.CountAction) {
|
|
454
|
-
countAction = actions[1];
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
extractAction = actions[1];
|
|
458
|
-
}
|
|
459
|
-
conditionAction = actions[2];
|
|
460
|
-
}
|
|
461
|
-
else if (firstAction instanceof ConditionAction_1.ConditionAction) {
|
|
462
|
-
conditionAction = firstAction;
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
conditionAction = actions[1];
|
|
466
|
-
}
|
|
467
|
-
const find = primaryAction.toDescriptor();
|
|
468
|
-
const assertArguments = args[0] && typeof args[0] === 'object'
|
|
469
|
-
? args[0]
|
|
470
|
-
: undefined;
|
|
471
|
-
const onFailure = assertArguments?.onFailure || OnFailure.FailImmediately;
|
|
472
|
-
const observationScope = assertArguments?.observationScope;
|
|
473
|
-
const descriptorToActionMap = new Map()
|
|
474
|
-
.set(find, primaryAction)
|
|
475
|
-
.set(conditionAction.conditionDescriptor, conditionAction);
|
|
476
|
-
if (extractAction) {
|
|
477
|
-
descriptorToActionMap.set(extractAction.toDescriptor(), extractAction);
|
|
478
|
-
}
|
|
479
|
-
if (countAction) {
|
|
480
|
-
descriptorToActionMap.set(countAction.countDescriptor, countAction);
|
|
481
|
-
}
|
|
482
|
-
return {
|
|
483
|
-
target: find,
|
|
484
|
-
extract: extractAction?.toDescriptor(),
|
|
485
|
-
condition: conditionAction.conditionDescriptor,
|
|
486
|
-
count: countAction?.countDescriptor,
|
|
487
|
-
onFailure,
|
|
488
|
-
observationScope,
|
|
489
|
-
descriptorToActionMap,
|
|
490
|
-
actionCode: AssertStep.actionCode,
|
|
491
|
-
};
|
|
492
|
-
}
|