@mablhq/mabl-cli 1.17.0 → 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/api/basicApiClient.js +7 -1
  2. package/api/featureSet.js +1 -4
  3. package/api/mablApiClient.js +3 -3
  4. package/browserLauncher/browserLauncherFactory.js +2 -3
  5. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
  6. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +11 -9
  7. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +1 -11
  8. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +18 -0
  9. package/browserLauncher/runnerType.js +0 -1
  10. package/commands/constants.js +3 -2
  11. package/commands/tests/testsUtil.js +11 -6
  12. package/commands/tests/tests_cmds/run.js +5 -0
  13. package/domUtil/index.js +1 -1
  14. package/domUtil/index.js.LICENSE.txt +5 -5
  15. package/execution/index.js +1 -1
  16. package/execution/index.js.LICENSE.txt +7 -5
  17. package/index.d.ts +0 -1
  18. package/mablscript/MablAction.js +1 -1
  19. package/mablscript/MablStep.js +21 -3
  20. package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
  21. package/mablscript/actions/ConditionAction.js +11 -3
  22. package/mablscript/actions/ExtractAction.js +16 -7
  23. package/mablscript/actions/FindAction.js +101 -69
  24. package/mablscript/actions/GenerateRandomStringAction.js +2 -1
  25. package/mablscript/actions/GetUrlAction.js +1 -1
  26. package/mablscript/actions/GetVariableValue.js +2 -2
  27. package/mablscript/diffing/diffingUtil.js +146 -0
  28. package/mablscript/importer.js +20 -2
  29. package/mablscript/steps/AccessibilityCheck.js +5 -5
  30. package/mablscript/steps/AssertStep.js +45 -31
  31. package/mablscript/steps/AssertStepOld.js +39 -21
  32. package/mablscript/steps/AwaitTabStep.js +7 -6
  33. package/mablscript/steps/ClickAndHoldStep.js +6 -6
  34. package/mablscript/steps/ClickStep.js +5 -5
  35. package/mablscript/steps/CreateVariableStep.js +2 -2
  36. package/mablscript/steps/DoubleClickStep.js +6 -6
  37. package/mablscript/steps/DownloadStep.js +3 -2
  38. package/mablscript/steps/EchoStep.js +3 -1
  39. package/mablscript/steps/ElseIfConditionStep.js +5 -2
  40. package/mablscript/steps/EnterTextStep.js +11 -8
  41. package/mablscript/steps/EvaluateFlowStep.js +40 -0
  42. package/mablscript/steps/HoverStep.js +5 -5
  43. package/mablscript/steps/IfConditionStep.js +6 -6
  44. package/mablscript/steps/ReleaseStep.js +7 -6
  45. package/mablscript/steps/RemoveCookieStep.js +2 -3
  46. package/mablscript/steps/SelectStep.js +5 -5
  47. package/mablscript/steps/SendHttpRequestStep.js +3 -3
  48. package/mablscript/steps/SendKeyStep.js +8 -8
  49. package/mablscript/steps/SetCookieStep.js +2 -4
  50. package/mablscript/steps/SetFilesStep.js +5 -5
  51. package/mablscript/steps/SetViewportStep.js +1 -1
  52. package/mablscript/steps/SwitchContextStep.js +3 -3
  53. package/mablscript/steps/VisitUrlStep.js +2 -1
  54. package/mablscript/steps/WaitStep.js +1 -4
  55. package/mablscript/steps/WaitUntilStep.js +3 -3
  56. package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
  57. package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
  58. package/mablscriptFind/index.js +1 -1
  59. package/mablscriptFind/index.js.LICENSE.txt +5 -5
  60. package/package.json +3 -3
  61. package/resources/mablFind.js +1 -1
  62. package/resources/pdf-viewer/index.js +1 -1
  63. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
  64. package/util/actionabilityUtil.js +1 -24
  65. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -134
  66. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
  67. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
  68. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
  69. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
  70. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
  71. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
  72. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -332
  73. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.diffFlows = exports.diffTests = exports.convertDiffingFormatIntoDiffingSteps = exports.flattenTestFlowsIntoLineDiffingFormat = exports.convertFlowToStepList = exports.lineModeDiff = exports.DiffOperation = void 0;
7
+ const mablApi_1 = require("../../mablApi");
8
+ const importer_1 = require("../importer");
9
+ const EvaluateFlowStep_1 = require("../steps/EvaluateFlowStep");
10
+ const diffPatchMatch_1 = __importDefault(require("./diffPatchMatch"));
11
+ const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
12
+ var DiffOperation;
13
+ (function (DiffOperation) {
14
+ DiffOperation["DELETE"] = "DELETE";
15
+ DiffOperation["EQUAL"] = "EQUAL";
16
+ DiffOperation["INSERT"] = "INSERT";
17
+ })(DiffOperation = exports.DiffOperation || (exports.DiffOperation = {}));
18
+ function lineModeDiff(text1, text2) {
19
+ const dmp = new diffPatchMatch_1.default();
20
+ const lineToCharDiff = dmp.diff_linesToChars(text1, text2);
21
+ const lineText1 = lineToCharDiff.chars1;
22
+ const lineText2 = lineToCharDiff.chars2;
23
+ const lineArray = lineToCharDiff.lineArray;
24
+ const diffs = dmp.diff_main(lineText1, lineText2, false);
25
+ dmp.diff_charsToLines(diffs, lineArray);
26
+ const typedDiff = diffs.map((diff) => ({
27
+ operation: convertOperationValue(diff[0]),
28
+ text: diff[1],
29
+ }));
30
+ return typedDiff;
31
+ }
32
+ exports.lineModeDiff = lineModeDiff;
33
+ function convertOperationValue(op) {
34
+ switch (op) {
35
+ case -1:
36
+ return DiffOperation.DELETE;
37
+ case 0:
38
+ return DiffOperation.EQUAL;
39
+ case 1:
40
+ return DiffOperation.INSERT;
41
+ default:
42
+ return DiffOperation.EQUAL;
43
+ }
44
+ }
45
+ function convertFlowToStepList(flow, flowConfig) {
46
+ if (!flow.reusable && flow.flow_type === mablApi_1.Flow.FlowTypeEnum.Mablscript) {
47
+ return (0, importer_1.parseMablScriptIntoSteps)(flow);
48
+ }
49
+ const evaluateFlowStep = new EvaluateFlowStep_1.EvaluateFlowStep(EvaluateFlowStep_1.EvaluateFlowStep.mablScriptStepNames[0], [
50
+ {
51
+ invariant_id: flow === null || flow === void 0 ? void 0 : flow.invariant_id,
52
+ },
53
+ flowConfig,
54
+ ], []);
55
+ if (flow.description) {
56
+ evaluateFlowStep.setDescription(flow.description);
57
+ }
58
+ return [evaluateFlowStep];
59
+ }
60
+ exports.convertFlowToStepList = convertFlowToStepList;
61
+ function flattenTestFlowsIntoSteps(flows, flowConfig) {
62
+ return flows.flatMap((flow, index) => convertFlowToStepList(flow, flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig[index]));
63
+ }
64
+ function flattenTestFlowsIntoLineDiffingFormat(flows, flowConfig) {
65
+ const flattenedSteps = flattenTestFlowsIntoSteps(flows, flowConfig);
66
+ const diffingFormat = flattenedSteps
67
+ .map((step) => step.toLineDiffFormat())
68
+ .join('\n');
69
+ return { flattenedSteps, diffingFormat };
70
+ }
71
+ exports.flattenTestFlowsIntoLineDiffingFormat = flattenTestFlowsIntoLineDiffingFormat;
72
+ function convertDiffingFormatIntoDiffingSteps(diffs, sourceSteps, targetSteps) {
73
+ const leftSteps = [...sourceSteps];
74
+ const rightSteps = [...targetSteps];
75
+ leftSteps.forEach((step) => {
76
+ step.setStepSourceIndexInFlow(0);
77
+ });
78
+ rightSteps.forEach((step) => {
79
+ step.setStepSourceIndexInFlow(0);
80
+ });
81
+ const stepDiffs = diffs.map((diff) => {
82
+ const lineDiffs = diff.text.trim().split('\n');
83
+ const stepDiffCount = lineDiffs.length;
84
+ let steps = [];
85
+ switch (diff.operation) {
86
+ case DiffOperation.EQUAL:
87
+ steps = leftSteps.splice(0, stepDiffCount);
88
+ rightSteps.splice(0, stepDiffCount);
89
+ break;
90
+ case DiffOperation.INSERT:
91
+ steps = rightSteps.splice(0, stepDiffCount);
92
+ break;
93
+ case DiffOperation.DELETE:
94
+ steps = leftSteps.splice(0, stepDiffCount);
95
+ break;
96
+ }
97
+ return {
98
+ operation: diff.operation,
99
+ steps,
100
+ };
101
+ });
102
+ return stepDiffs;
103
+ }
104
+ exports.convertDiffingFormatIntoDiffingSteps = convertDiffingFormatIntoDiffingSteps;
105
+ function diffTests(test1Flows, test1FlowConfig, test2Flows, test2FlowConfig) {
106
+ const { flattenedSteps: flattenedTest1Steps, diffingFormat: test1DiffingFormat, } = flattenTestFlowsIntoLineDiffingFormat(test1Flows, test1FlowConfig);
107
+ const { flattenedSteps: flattenedTest2Steps, diffingFormat: test2DiffingFormat, } = flattenTestFlowsIntoLineDiffingFormat(test2Flows, test2FlowConfig);
108
+ const diffs = lineModeDiff(test1DiffingFormat, test2DiffingFormat);
109
+ return convertDiffingFormatIntoDiffingSteps(diffs, flattenedTest1Steps, flattenedTest2Steps);
110
+ }
111
+ exports.diffTests = diffTests;
112
+ function diffFlows(flow1, flow2) {
113
+ var _a, _b;
114
+ const flow1Steps = (0, importer_1.parseMablScriptIntoSteps)(flow1);
115
+ const formattedFlow1Steps = flow1Steps
116
+ .map((step) => step.toLineDiffFormat())
117
+ .join('\n');
118
+ const flow2Steps = (0, importer_1.parseMablScriptIntoSteps)(flow2);
119
+ const formattedFlow2Steps = flow2Steps
120
+ .map((step) => step.toLineDiffFormat())
121
+ .join('\n');
122
+ const flattenedDiffs = lineModeDiff(formattedFlow1Steps, formattedFlow2Steps);
123
+ const stepDiffs = convertDiffingFormatIntoDiffingSteps(flattenedDiffs, flow1Steps, flow2Steps);
124
+ const parametersDiff = diffFlowVariables(flow1.parameters, flow2.parameters);
125
+ const inputVariablesDiff = diffFlowVariables((_a = flow1.variables) === null || _a === void 0 ? void 0 : _a.inputs, (_b = flow2.variables) === null || _b === void 0 ? void 0 : _b.inputs);
126
+ return { stepDiff: stepDiffs, parametersDiff, inputVariablesDiff };
127
+ }
128
+ exports.diffFlows = diffFlows;
129
+ function diffFlowVariables(flow1Variables, flow2Variables) {
130
+ const flow1VariablesFlattened = flattenFlowVariables(flow1Variables);
131
+ const flow2VariablesFlattened = flattenFlowVariables(flow2Variables);
132
+ const diffs = lineModeDiff(flow1VariablesFlattened, flow2VariablesFlattened);
133
+ const flowVariablesDiff = diffs.map((diff) => {
134
+ const variablesStringified = diff.text.trim().split('\n');
135
+ const reassembledVariables = variablesStringified.map((variablesText) => JSON.parse(variablesText));
136
+ return {
137
+ operation: diff.operation,
138
+ variables: reassembledVariables,
139
+ };
140
+ });
141
+ return flowVariablesDiff;
142
+ }
143
+ function flattenFlowVariables(flowVariables) {
144
+ var _a;
145
+ return ((_a = flowVariables === null || flowVariables === void 0 ? void 0 : flowVariables.sort((a, b) => a.name.localeCompare(b.name)).map((parameter) => (0, fast_json_stable_stringify_1.default)(parameter)).join('\n')) !== null && _a !== void 0 ? _a : '');
146
+ }
@@ -51,6 +51,7 @@ const ReleaseStep_1 = require("./steps/ReleaseStep");
51
51
  const CountAction_1 = require("./actions/CountAction");
52
52
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
53
53
  const AccessibilityCheck_1 = require("./steps/AccessibilityCheck");
54
+ const EvaluateFlowStep_1 = require("./steps/EvaluateFlowStep");
54
55
  const ActionTypes = [
55
56
  AwaitDownloadAction_1.AwaitDownloadAction,
56
57
  AwaitPDFDownloadAction_1.AwaitPDFDownloadAction,
@@ -81,6 +82,7 @@ const StepTypes = [
81
82
  ElseIfConditionStep_1.ElseIfConditionStep,
82
83
  EndStep_1.EndStep,
83
84
  EnterTextStep_1.EnterTextStep,
85
+ EvaluateFlowStep_1.EvaluateFlowStep,
84
86
  HoverStep_1.HoverStep,
85
87
  IfConditionStep_1.IfConditionStep,
86
88
  EvaluateJavaScriptStep_1.EvaluateJavaScriptStep,
@@ -150,9 +152,12 @@ function loadMablScriptIntoSteps(parsedMablscript) {
150
152
  action.setActionSourceIndexInStep(actionIndex);
151
153
  return action;
152
154
  });
153
- const step = stepType
155
+ let step = stepType
154
156
  ? new stepType(lastAction.name, lastAction.arguments, actions)
155
157
  : new MablStep_1.MablStep(lastAction.name, lastAction.arguments, actions);
158
+ if (step instanceof AssertStepOld_1.AssertStepOld) {
159
+ step = step.getNewAssertionStep();
160
+ }
156
161
  step.setActionSourceIndexInStep(actions.length);
157
162
  step.setStepSourceIndexInFlow(parseInt(stepIndexString));
158
163
  return step;
@@ -169,7 +174,7 @@ StepTypes.forEach((step) => {
169
174
  step.yamlMablScriptNames.forEach((name) => (yamlMablscriptToObjectsStepMap[name] = step.fromYaml));
170
175
  });
171
176
  function loadYamlSteps(yamlSteps) {
172
- const loadedStepData = (0, js_yaml_1.safeLoad)(yamlSteps);
177
+ const loadedStepData = (0, js_yaml_1.load)(yamlSteps);
173
178
  return loadedStepData.map((stepObject) => {
174
179
  const stepName = Object.keys(stepObject)[0];
175
180
  const stepArgs = stepObject[stepName];
@@ -280,6 +285,19 @@ function parseObjectExpression(expression) {
280
285
  let key;
281
286
  let value;
282
287
  switch (property.value.type) {
288
+ case 'UnaryExpression':
289
+ key = property.key;
290
+ value = property.value;
291
+ const operator = value.operator;
292
+ const rawValue = Number(value.argument.raw);
293
+ if (operator === '-') {
294
+ value = -Math.abs(rawValue);
295
+ }
296
+ else {
297
+ throw Error(`Cannot parse UnaryExpression ${property}`);
298
+ }
299
+ finalObj[key.name] = value;
300
+ break;
283
301
  case 'Literal':
284
302
  key =
285
303
  property.key.type === 'Identifier'
@@ -4,7 +4,7 @@ exports.AccessibilityCheckStep = exports.AccessibilityCheckSeverity = void 0;
4
4
  const MablStep_1 = require("../MablStep");
5
5
  const FindAction_1 = require("../actions/FindAction");
6
6
  const ActionsUtils_1 = require("./ActionsUtils");
7
- const mablscriptFind_1 = require("../../mablscriptFind");
7
+ const domUtil_1 = require("../../domUtil");
8
8
  var AccessibilityCheckSeverity;
9
9
  (function (AccessibilityCheckSeverity) {
10
10
  AccessibilityCheckSeverity["Critical"] = "critical";
@@ -32,10 +32,10 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
32
32
  if (this.findAction) {
33
33
  const find = this.findAction.toDescriptor();
34
34
  switch (find.findType) {
35
- case mablscriptFind_1.FindType.FIND_FIRST:
36
- case mablscriptFind_1.FindType.FIND_LAST:
37
- case mablscriptFind_1.FindType.FIND_ANY:
38
- case mablscriptFind_1.FindType.FIND_ONE:
35
+ case domUtil_1.FindType.FIND_FIRST:
36
+ case domUtil_1.FindType.FIND_LAST:
37
+ case domUtil_1.FindType.FIND_ANY:
38
+ case domUtil_1.FindType.FIND_ONE:
39
39
  return {
40
40
  ...this.checkConfig,
41
41
  find,
@@ -6,7 +6,7 @@ const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
6
6
  const FindAction_1 = require("../actions/FindAction");
7
7
  const MablStep_1 = require("../MablStep");
8
8
  const ExtractAction_1 = require("../actions/ExtractAction");
9
- const mablscriptFind_1 = require("../../mablscriptFind");
9
+ const domUtil_1 = require("../../domUtil");
10
10
  const GetUrlAction_1 = require("../actions/GetUrlAction");
11
11
  const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
12
12
  const GetVariableValue_1 = require("../actions/GetVariableValue");
@@ -37,6 +37,7 @@ exports.fieldToAssertionStep = {};
37
37
  Object.entries(exports.assertionStepToField).forEach(([stepType, field]) => (exports.fieldToAssertionStep[field] = stepType));
38
38
  class AssertStep extends MablStep_1.MablStep {
39
39
  constructor(name, args, actions) {
40
+ var _a, _b;
40
41
  super(name, args, actions);
41
42
  const firstAction = actions[0];
42
43
  if (firstAction instanceof FindAction_1.FindAction ||
@@ -62,11 +63,12 @@ class AssertStep extends MablStep_1.MablStep {
62
63
  this.assertionType = this.conditionAction.conditionAttribute;
63
64
  this.assertionValue = this.conditionAction.conditionValueAttribute;
64
65
  this.isWaitUntilStep = this.determineIfWaitUntilStep();
65
- const assertArguments = args[0] && typeof args[0] === 'object'
66
- ? args[0]
67
- : undefined;
68
- this.continueOnFailure = (assertArguments === null || assertArguments === void 0 ? void 0 : assertArguments.onFailure) === 'continue';
69
- this.observationScope = assertArguments === null || assertArguments === void 0 ? void 0 : assertArguments.observationScope;
66
+ this.assertArguments =
67
+ args[0] && typeof args[0] === 'object'
68
+ ? args[0]
69
+ : undefined;
70
+ this.continueOnFailure = ((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) === 'continue';
71
+ this.observationScope = (_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope;
70
72
  }
71
73
  validate() {
72
74
  if (!(this.actions.length === 2 || this.actions.length === 3) &&
@@ -78,7 +80,7 @@ class AssertStep extends MablStep_1.MablStep {
78
80
  determineIfWaitUntilStep() {
79
81
  var _a, _b;
80
82
  const find = this.primaryAction.toDescriptor();
81
- if ((0, mablscriptFind_1.isFindElementDescriptor)(find)) {
83
+ if ((0, domUtil_1.isFindElementDescriptor)(find)) {
82
84
  if ((_b = (_a = find.findOptions) === null || _a === void 0 ? void 0 : _a.waitUntil) === null || _b === void 0 ? void 0 : _b.timeoutSeconds) {
83
85
  return true;
84
86
  }
@@ -133,19 +135,19 @@ class AssertStep extends MablStep_1.MablStep {
133
135
  }
134
136
  else {
135
137
  switch (find.findType) {
136
- case mablscriptFind_1.FindType.FIND_COOKIE:
137
- case mablscriptFind_1.FindType.FIND_EMAIL:
138
+ case domUtil_1.FindType.FIND_COOKIE:
139
+ case domUtil_1.FindType.FIND_EMAIL:
138
140
  formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
139
141
  formatted.selector = find.findTarget;
140
142
  break;
141
- case mablscriptFind_1.FindType.FIND_FIRST:
142
- case mablscriptFind_1.FindType.FIND_LAST:
143
- case mablscriptFind_1.FindType.FIND_ANY:
144
- case mablscriptFind_1.FindType.FIND_ALL:
143
+ case domUtil_1.FindType.FIND_FIRST:
144
+ case domUtil_1.FindType.FIND_LAST:
145
+ case domUtil_1.FindType.FIND_ANY:
146
+ case domUtil_1.FindType.FIND_ALL:
145
147
  formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
146
148
  formatted.selector = find.findTarget;
147
149
  break;
148
- case mablscriptFind_1.FindType.FIND_ONE:
150
+ case domUtil_1.FindType.FIND_ONE:
149
151
  formatted.selector = find.findTarget.selector;
150
152
  if (find.findOptions) {
151
153
  formatted.findOptions = find.findOptions;
@@ -161,8 +163,14 @@ class AssertStep extends MablStep_1.MablStep {
161
163
  const actions = [];
162
164
  const assertionType = exports.assertionStepToField[stepName];
163
165
  const assertionValue = stepArgs.assertionValue;
164
- const findAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
165
- actions.push(findAction);
166
+ let primaryAction;
167
+ if (stepArgs.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
168
+ primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
169
+ }
170
+ else {
171
+ primaryAction = FindAction_1.FindAction.findActionFromStepArgs(stepArgs);
172
+ }
173
+ actions.push(primaryAction);
166
174
  if (assertionType === 'present' || assertionType === 'not_present') {
167
175
  actions.push(new ConditionAction_1.ConditionAction('evaluate_presence', [assertionType]));
168
176
  }
@@ -181,14 +189,19 @@ class AssertStep extends MablStep_1.MablStep {
181
189
  assertionValue,
182
190
  ]));
183
191
  }
184
- return new AssertStep('assert', [], actions);
192
+ return new AssertStep('assert', [
193
+ {
194
+ onFailure: stepArgs.continueOnFailure ? 'continue' : undefined,
195
+ observationScope: stepArgs.observationScope,
196
+ },
197
+ ], actions);
185
198
  }
186
199
  produceSelIdeFormattedSteps(stepIndex) {
187
200
  const find = this.primaryAction.toDescriptor();
188
201
  if (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
189
202
  !(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
190
- (find.findType === mablscriptFind_1.FindType.FIND_EMAIL ||
191
- find.findType === mablscriptFind_1.FindType.FIND_COOKIE)) {
203
+ (find.findType === domUtil_1.FindType.FIND_EMAIL ||
204
+ find.findType === domUtil_1.FindType.FIND_COOKIE)) {
192
205
  return [this.unsupportedSelIdeExportStep()];
193
206
  }
194
207
  if (this.assertionType === 'present') {
@@ -215,7 +228,7 @@ class AssertStep extends MablStep_1.MablStep {
215
228
  }
216
229
  return buildSeleniumIdeJsAssertion(stepIndex, (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
217
230
  !(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
218
- find.findType === mablscriptFind_1.FindType.FIND_ONE &&
231
+ find.findType === domUtil_1.FindType.FIND_ONE &&
219
232
  find.findTarget.selector.xpath) ||
220
233
  '', this.extractAction ? this.extractAction.extractionAttribute : '', this.substituteSeleniumVariable(this.conditionAction.conditionValueAttribute || ''), this.assertionType, this);
221
234
  }
@@ -229,21 +242,22 @@ class AssertStep extends MablStep_1.MablStep {
229
242
  return seleniumStep;
230
243
  }
231
244
  toMablscript() {
232
- if (this.assertionType === 'present' ||
233
- this.assertionType === 'not_present' ||
234
- this.isWaitUntilStep) {
235
- const finalAssertionType = this.isWaitUntilStep
236
- ? 'present'
237
- : this.assertionType;
238
- return `${this.primaryAction.generateMablscriptFindOne()}.evaluate_presence("${finalAssertionType}").assert()`;
239
- }
245
+ var _a, _b;
246
+ const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
247
+ ((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
248
+ ? this.convertObjectToMablscriptArgs(this.assertArguments)
249
+ : ''})`;
240
250
  if (this.countAction) {
241
- return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
251
+ return `${this.primaryAction.toMablscript()}.${this.countAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
242
252
  }
243
253
  if (this.extractAction) {
244
- return `${this.primaryAction.toMablscript()}.${this.extractAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
254
+ return `${this.primaryAction.toMablscript()}.${this.extractAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
255
+ }
256
+ if (this.assertionType === 'present' ||
257
+ this.assertionType === 'not_present') {
258
+ return `${this.primaryAction.generateFindMablscript()}.evaluate_presence("${this.assertionType}")${assertAction}`;
245
259
  }
246
- return `${this.primaryAction.toMablscript()}.${this.conditionAction.toMablscript()}.assert()`;
260
+ return `${this.primaryAction.toMablscript()}.${this.conditionAction.toMablscript()}${assertAction}`;
247
261
  }
248
262
  }
249
263
  exports.AssertStep = AssertStep;
@@ -4,8 +4,10 @@ exports.AssertStepOld = void 0;
4
4
  const ExtractAction_1 = require("../actions/ExtractAction");
5
5
  const MablStep_1 = require("../MablStep");
6
6
  const FindAction_1 = require("../actions/FindAction");
7
- const mablscriptFind_1 = require("../../mablscriptFind");
7
+ const domUtil_1 = require("../../domUtil");
8
8
  const importer_1 = require("../importer");
9
+ const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescriptor");
10
+ const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
9
11
  const oldToNewAssertionTypes = {
10
12
  assert_contains: 'AssertContains',
11
13
  assert_does_not_contain: 'AssertDoesNotContain',
@@ -31,8 +33,16 @@ class AssertStepOld extends MablStep_1.MablStep {
31
33
  this.validate();
32
34
  this.setAssertAttribute();
33
35
  this.assertionType = this.name;
34
- this.findAction = actions[0];
36
+ this.primaryAction = actions[0];
35
37
  this.extractAction = actions[1];
38
+ if (args.length === 1) {
39
+ this.continueOnFailure = args[0].onFailure === 'continue';
40
+ this.observationScope = args[0].observationScope;
41
+ }
42
+ else if (args.length === 2) {
43
+ this.continueOnFailure = args[1].onFailure === 'continue';
44
+ this.observationScope = args[1].observationScope;
45
+ }
36
46
  }
37
47
  validate() {
38
48
  if (this.actions.length !== 2 &&
@@ -61,26 +71,34 @@ class AssertStepOld extends MablStep_1.MablStep {
61
71
  ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
62
72
  formatted.attribute = this.extractAction.extractionAttribute;
63
73
  }
64
- const find = this.findAction.toDescriptor();
65
- switch (find.findType) {
66
- case mablscriptFind_1.FindType.FIND_COOKIE:
67
- case mablscriptFind_1.FindType.FIND_EMAIL:
68
- formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
69
- formatted.selector = find.findTarget;
70
- break;
71
- case mablscriptFind_1.FindType.FIND_FIRST:
72
- case mablscriptFind_1.FindType.FIND_LAST:
73
- case mablscriptFind_1.FindType.FIND_ANY:
74
- case mablscriptFind_1.FindType.FIND_ALL:
75
- formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
76
- formatted.selector = find.findTarget;
77
- break;
78
- case mablscriptFind_1.FindType.FIND_ONE:
79
- formatted.selector = find.findTarget.selector;
80
- break;
81
- default:
82
- throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
74
+ const find = this.primaryAction.toDescriptor();
75
+ formatted.findOptions = find.selectorFindOption;
76
+ if ((0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) || (0, GetVariableDescriptor_1.isGetVariableDescriptor)(find)) {
77
+ formatted.kind = find.kind;
78
+ }
79
+ else {
80
+ switch (find.findType) {
81
+ case domUtil_1.FindType.FIND_COOKIE:
82
+ case domUtil_1.FindType.FIND_EMAIL:
83
+ formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
84
+ formatted.selector = find.findTarget;
85
+ break;
86
+ case domUtil_1.FindType.FIND_FIRST:
87
+ case domUtil_1.FindType.FIND_LAST:
88
+ case domUtil_1.FindType.FIND_ANY:
89
+ case domUtil_1.FindType.FIND_ALL:
90
+ formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
91
+ formatted.selector = find.findTarget;
92
+ break;
93
+ case domUtil_1.FindType.FIND_ONE:
94
+ formatted.selector = find.findTarget.selector;
95
+ break;
96
+ default:
97
+ throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
98
+ }
83
99
  }
100
+ formatted.continueOnFailure = this.continueOnFailure;
101
+ formatted.observationScope = this.observationScope;
84
102
  return formatted;
85
103
  }
86
104
  getNewAssertionStep() {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AwaitTabStep = void 0;
4
+ const domUtil_1 = require("../../domUtil");
4
5
  const MablStep_1 = require("../MablStep");
5
6
  class AwaitTabStep extends MablStep_1.MablStep {
6
7
  constructor(name, args, actions) {
@@ -20,14 +21,14 @@ class AwaitTabStep extends MablStep_1.MablStep {
20
21
  }
21
22
  toMablscript() {
22
23
  const mablscriptSelectorChunks = ['selector_type: "tab"'];
23
- if (this.tab.title) {
24
- mablscriptSelectorChunks.push(`title: "${this.tab.title}"`);
24
+ if (this.tab.title !== undefined) {
25
+ mablscriptSelectorChunks.push(`title: "${(0, domUtil_1.escapeMablscriptString)(this.tab.title)}"`);
25
26
  }
26
- if (this.tab.url) {
27
- mablscriptSelectorChunks.push(`url: "${this.tab.url}"`);
27
+ if (this.tab.url !== undefined) {
28
+ mablscriptSelectorChunks.push(`url: "${(0, domUtil_1.escapeMablscriptString)(this.tab.url)}"`);
28
29
  }
29
- if (this.tab.uuid) {
30
- mablscriptSelectorChunks.push(`uuid: "${this.tab.uuid}"`);
30
+ if (this.tab.uuid !== undefined) {
31
+ mablscriptSelectorChunks.push(`uuid: "${(0, domUtil_1.escapeMablscriptString)(this.tab.uuid)}"`);
31
32
  }
32
33
  return `await_tab({${mablscriptSelectorChunks.join(', ')}})`;
33
34
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClickAndHoldStep = void 0;
4
4
  const FindAction_1 = require("../actions/FindAction");
5
5
  const MablStep_1 = require("../MablStep");
6
- const mablscriptFind_1 = require("../../mablscriptFind");
6
+ const domUtil_1 = require("../../domUtil");
7
7
  const ActionsUtils_1 = require("./ActionsUtils");
8
8
  class ClickAndHoldStep extends MablStep_1.MablStep {
9
9
  constructor(name, args, actions) {
@@ -30,10 +30,10 @@ class ClickAndHoldStep extends MablStep_1.MablStep {
30
30
  toStepDescriptor() {
31
31
  const find = this.findAction.toDescriptor();
32
32
  switch (find.findType) {
33
- case mablscriptFind_1.FindType.FIND_FIRST:
34
- case mablscriptFind_1.FindType.FIND_LAST:
35
- case mablscriptFind_1.FindType.FIND_ANY:
36
- case mablscriptFind_1.FindType.FIND_ONE:
33
+ case domUtil_1.FindType.FIND_FIRST:
34
+ case domUtil_1.FindType.FIND_LAST:
35
+ case domUtil_1.FindType.FIND_ANY:
36
+ case domUtil_1.FindType.FIND_ONE:
37
37
  return {
38
38
  find,
39
39
  isHtml5: this.clickArgs.isHtml5,
@@ -55,7 +55,7 @@ class ClickAndHoldStep extends MablStep_1.MablStep {
55
55
  return new ClickAndHoldStep('click_and_hold', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
56
56
  }
57
57
  toMablscript() {
58
- return `${this.findAction.toMablscript()}.click_and_hold()`;
58
+ return `${this.findAction.toMablscript()}.click_and_hold({isHtml5:${this.clickArgs.isHtml5}})`;
59
59
  }
60
60
  }
61
61
  exports.ClickAndHoldStep = ClickAndHoldStep;
@@ -4,7 +4,7 @@ exports.ClickStep = void 0;
4
4
  const FindAction_1 = require("../actions/FindAction");
5
5
  const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
6
6
  const MablStep_1 = require("../MablStep");
7
- const mablscriptFind_1 = require("../../mablscriptFind");
7
+ const domUtil_1 = require("../../domUtil");
8
8
  const ActionsUtils_1 = require("./ActionsUtils");
9
9
  class ClickStep extends MablStep_1.MablStep {
10
10
  constructor(name, args, actions) {
@@ -17,10 +17,10 @@ class ClickStep extends MablStep_1.MablStep {
17
17
  toStepDescriptor() {
18
18
  const find = this.findAction.toDescriptor();
19
19
  switch (find.findType) {
20
- case mablscriptFind_1.FindType.FIND_FIRST:
21
- case mablscriptFind_1.FindType.FIND_LAST:
22
- case mablscriptFind_1.FindType.FIND_ANY:
23
- case mablscriptFind_1.FindType.FIND_ONE:
20
+ case domUtil_1.FindType.FIND_FIRST:
21
+ case domUtil_1.FindType.FIND_LAST:
22
+ case domUtil_1.FindType.FIND_ANY:
23
+ case domUtil_1.FindType.FIND_ONE:
24
24
  return {
25
25
  find,
26
26
  descriptorToActionMap: new Map().set(find, this.findAction),
@@ -8,7 +8,7 @@ const FindAction_1 = require("../actions/FindAction");
8
8
  const GenerateEmailAddressAction_1 = require("../actions/GenerateEmailAddressAction");
9
9
  const GenerateRandomStringAction_1 = require("../actions/GenerateRandomStringAction");
10
10
  const CreateVariableStepDescriptor_1 = require("../types/CreateVariableStepDescriptor");
11
- const mablscriptFind_1 = require("../../mablscriptFind");
11
+ const domUtil_1 = require("../../domUtil");
12
12
  const JavaScriptAction_1 = require("../actions/JavaScriptAction");
13
13
  const CountAction_1 = require("../actions/CountAction");
14
14
  class CreateVariableStep extends MablStep_1.MablStep {
@@ -207,7 +207,7 @@ class CreateVariableStep extends MablStep_1.MablStep {
207
207
  actions.push(new ExtractAction_1.ExtractAction('extract_attribute', [generator.attribute]));
208
208
  break;
209
209
  case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
210
- actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs, mablscriptFind_1.FindType.FIND_ALL));
210
+ actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs, domUtil_1.FindType.FIND_ALL));
211
211
  actions.push(new CountAction_1.CountAction('count', []));
212
212
  break;
213
213
  case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
@@ -4,7 +4,7 @@ exports.DoubleClickStep = void 0;
4
4
  const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
5
5
  const MablStep_1 = require("../MablStep");
6
6
  const FindAction_1 = require("../actions/FindAction");
7
- const mablscriptFind_1 = require("../../mablscriptFind");
7
+ const domUtil_1 = require("../../domUtil");
8
8
  class DoubleClickStep extends MablStep_1.MablStep {
9
9
  constructor(name, args, actions) {
10
10
  super(name, args, actions);
@@ -22,11 +22,11 @@ class DoubleClickStep extends MablStep_1.MablStep {
22
22
  toStepDescriptor() {
23
23
  const find = this.findAction.toDescriptor();
24
24
  switch (find.findType) {
25
- case mablscriptFind_1.FindType.FIND_FIRST:
26
- case mablscriptFind_1.FindType.FIND_LAST:
27
- case mablscriptFind_1.FindType.FIND_ANY:
28
- case mablscriptFind_1.FindType.FIND_ALL:
29
- case mablscriptFind_1.FindType.FIND_ONE:
25
+ case domUtil_1.FindType.FIND_FIRST:
26
+ case domUtil_1.FindType.FIND_LAST:
27
+ case domUtil_1.FindType.FIND_ANY:
28
+ case domUtil_1.FindType.FIND_ALL:
29
+ case domUtil_1.FindType.FIND_ONE:
30
30
  return {
31
31
  find,
32
32
  descriptorToActionMap: new Map().set(find, this.findAction),
@@ -4,6 +4,7 @@ exports.DownloadStep = void 0;
4
4
  const MablStep_1 = require("../MablStep");
5
5
  const AwaitDownloadAction_1 = require("../actions/AwaitDownloadAction");
6
6
  const AwaitPDFDownloadAction_1 = require("../actions/AwaitPDFDownloadAction");
7
+ const domUtil_1 = require("../../domUtil");
7
8
  class DownloadStep extends MablStep_1.MablStep {
8
9
  constructor(name, args, actions) {
9
10
  var _a;
@@ -77,8 +78,8 @@ class DownloadStep extends MablStep_1.MablStep {
77
78
  return new DownloadStep('assert_download', [fileAttributes], [awaitDownloadAction]);
78
79
  }
79
80
  toMablscript() {
80
- const mablArgs = this.convertObjectToMablscriptArgs(this.fileAttributes);
81
- return `${this.awaitDownloadAction.toMablscript()}.assert_download(${mablArgs})`;
81
+ const mablArgs = (0, domUtil_1.buildStepArgumentString)(this.fileAttributes);
82
+ return `${this.awaitDownloadAction.toMablscript()}.assert_download(${mablArgs ? mablArgs : ''})`;
82
83
  }
83
84
  }
84
85
  exports.DownloadStep = DownloadStep;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EchoStep = void 0;
4
4
  const MablStep_1 = require("../MablStep");
5
+ const domUtil_1 = require("../../domUtil");
5
6
  const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
6
7
  const MablAction_1 = require("../MablAction");
7
8
  class EchoStep extends MablStep_1.MablStep {
@@ -24,7 +25,8 @@ class EchoStep extends MablStep_1.MablStep {
24
25
  return new EchoStep('echo', [stepArgs.value], []);
25
26
  }
26
27
  toMablscript() {
27
- return `echo(${this.substituteMablscriptVariable(this.echoValue)})`;
28
+ const stringEchoValue = `${this.echoValue}`;
29
+ return `echo("${(0, domUtil_1.escapeMablscriptString)(stringEchoValue)}")`;
28
30
  }
29
31
  }
30
32
  exports.EchoStep = EchoStep;