@mablhq/mabl-cli 1.48.47 → 1.50.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/api/mablApiClient.js +30 -19
- package/commands/commandUtil/fileUtil.js +11 -3
- package/commands/constants.js +3 -1
- package/commands/datatables/datatables.js +1 -1
- package/commands/datatables/datatables_cmds/create.js +18 -105
- package/commands/datatables/datatables_cmds/describe.js +6 -6
- package/commands/datatables/datatables_cmds/export.js +36 -27
- package/commands/datatables/datatables_cmds/list.js +6 -6
- package/commands/datatables/datatables_cmds/update.js +120 -0
- package/commands/datatables/utils.js +138 -0
- package/commands/flows/flows_cmds/export.js +1 -1
- package/commands/tests/testsUtil.js +25 -21
- package/commands/tests/tests_cmds/export.js +53 -22
- package/core/trainer/trainingSessions.js +1 -1
- package/domUtil/index.js +1 -1
- package/execution/index.js +1 -1
- package/functions/apiTest/utils.js +1 -1
- package/index.d.ts +3 -3
- package/mablApi/index.js +1 -1
- package/mablscriptFind/index.js +1 -1
- package/package.json +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/pdf-viewer/EmbeddedPdfHandler.js +1 -1
- package/resources/pdf-viewer/libEmbeddedPdfHandler.js +62 -16
- package/codeGenerators/seleniumConfigGenerators/SeleniumIdeStep.js +0 -40
- package/codeGenerators/seleniumConfigGenerators/flowConfigGenerator.js +0 -86
- package/codeGenerators/seleniumConfigGenerators/selIdeGenerator.js +0 -63
- package/codeGenerators/seleniumConfigGenerators/stepConverters.js +0 -380
- package/codeGenerators/seleniumConfigGenerators/testConfigGenerator.js +0 -77
- package/util/csvUtil.js +0 -13
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enterTextStepToSeleniumSteps = exports.createVariableStepToSeleniumSteps = exports.clickStepToSeleniumSteps = exports.echoStepToSeleniumSteps = exports.hoverStepToSeleniumSteps = exports.stepGenerators = void 0;
|
|
4
|
-
const domUtil_1 = require("../../domUtil");
|
|
5
|
-
const FindAction_1 = require("../../mablscript/actions/FindAction");
|
|
6
|
-
const GetUrlAction_1 = require("../../mablscript/actions/GetUrlAction");
|
|
7
|
-
const GetVariableValue_1 = require("../../mablscript/actions/GetVariableValue");
|
|
8
|
-
const AssertStep_1 = require("../../mablscript/steps/AssertStep");
|
|
9
|
-
const ClickStep_1 = require("../../mablscript/steps/ClickStep");
|
|
10
|
-
const CreateVariableStep_1 = require("../../mablscript/steps/CreateVariableStep");
|
|
11
|
-
const DoubleClickStep_1 = require("../../mablscript/steps/DoubleClickStep");
|
|
12
|
-
const EchoStep_1 = require("../../mablscript/steps/EchoStep");
|
|
13
|
-
const EnterTextStep_1 = require("../../mablscript/steps/EnterTextStep");
|
|
14
|
-
const HoverStep_1 = require("../../mablscript/steps/HoverStep");
|
|
15
|
-
const NavigateStep_1 = require("../../mablscript/steps/NavigateStep");
|
|
16
|
-
const RightClickStep_1 = require("../../mablscript/steps/RightClickStep");
|
|
17
|
-
const SendKeyStep_1 = require("../../mablscript/steps/SendKeyStep");
|
|
18
|
-
const SetViewportStep_1 = require("../../mablscript/steps/SetViewportStep");
|
|
19
|
-
const SwitchContextStep_1 = require("../../mablscript/steps/SwitchContextStep");
|
|
20
|
-
const VisitUrlStep_1 = require("../../mablscript/steps/VisitUrlStep");
|
|
21
|
-
const WaitStep_1 = require("../../mablscript/steps/WaitStep");
|
|
22
|
-
const CreateVariableStepDescriptor_1 = require("../../mablscript/types/CreateVariableStepDescriptor");
|
|
23
|
-
const GetCurrentLocationDescriptor_1 = require("../../mablscript/types/GetCurrentLocationDescriptor");
|
|
24
|
-
const GetVariableDescriptor_1 = require("../../mablscript/types/GetVariableDescriptor");
|
|
25
|
-
const SwitchContextStepDescriptor_1 = require("../../mablscript/types/SwitchContextStepDescriptor");
|
|
26
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
27
|
-
exports.stepGenerators = new Map();
|
|
28
|
-
exports.stepGenerators.set(AssertStep_1.AssertStep.name, assertStepToSeleniumSteps);
|
|
29
|
-
exports.stepGenerators.set(ClickStep_1.ClickStep.name, clickStepToSeleniumSteps);
|
|
30
|
-
exports.stepGenerators.set(CreateVariableStep_1.CreateVariableStep.name, createVariableStepToSeleniumSteps);
|
|
31
|
-
exports.stepGenerators.set(DoubleClickStep_1.DoubleClickStep.name, doubleClickStepToSeleniumSteps);
|
|
32
|
-
exports.stepGenerators.set(EchoStep_1.EchoStep.name, echoStepToSeleniumSteps);
|
|
33
|
-
exports.stepGenerators.set(EnterTextStep_1.EnterTextStep.name, enterTextStepToSeleniumSteps);
|
|
34
|
-
exports.stepGenerators.set(HoverStep_1.HoverStep.name, hoverStepToSeleniumSteps);
|
|
35
|
-
exports.stepGenerators.set(NavigateStep_1.NavigateStep.name, navigateStepToSeleniumSteps);
|
|
36
|
-
exports.stepGenerators.set(RightClickStep_1.RightClickStep.name, rightClickStepToSeleniumSteps);
|
|
37
|
-
exports.stepGenerators.set(SendKeyStep_1.SendKeyStep.name, sendKeyStepToSeleniumSteps);
|
|
38
|
-
exports.stepGenerators.set(SetViewportStep_1.SetViewportStep.name, setViewportStepToSeleniumSteps);
|
|
39
|
-
exports.stepGenerators.set(SwitchContextStep_1.SwitchContextStep.name, switchContextStepToSeleniumSteps);
|
|
40
|
-
exports.stepGenerators.set(VisitUrlStep_1.VisitUrlStep.name, visitUrlStepToSeleniumSteps);
|
|
41
|
-
exports.stepGenerators.set(WaitStep_1.WaitStep.name, waitStepToSeleniumSteps);
|
|
42
|
-
function assertStepToSeleniumSteps(baseStep, stepIndex) {
|
|
43
|
-
var _a;
|
|
44
|
-
const step = baseStep;
|
|
45
|
-
if (!step) {
|
|
46
|
-
throw new Error('Expected an assert step');
|
|
47
|
-
}
|
|
48
|
-
const find = step.primaryAction.toDescriptor();
|
|
49
|
-
if (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
|
|
50
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
51
|
-
(find.findType === domUtil_1.FindType.FIND_EMAIL ||
|
|
52
|
-
find.findType === domUtil_1.FindType.FIND_COOKIE)) {
|
|
53
|
-
return [unsupportedSelIdeExportStep(step)];
|
|
54
|
-
}
|
|
55
|
-
if (step.assertionType === 'present') {
|
|
56
|
-
if (step.primaryAction instanceof GetUrlAction_1.GetUrlAction) {
|
|
57
|
-
throw new Error('Invalid state. You cannot assert presence against URL properties.');
|
|
58
|
-
}
|
|
59
|
-
if (step.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
60
|
-
throw new Error('Invalid state. You cannot assert presence against variable properties.');
|
|
61
|
-
}
|
|
62
|
-
const assertPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementPresent', step);
|
|
63
|
-
assertPresentStep.target = findActionToSeleniumTarget(step.primaryAction);
|
|
64
|
-
return [assertPresentStep];
|
|
65
|
-
}
|
|
66
|
-
else if (step.assertionType === 'not_present') {
|
|
67
|
-
if (step.primaryAction instanceof GetUrlAction_1.GetUrlAction) {
|
|
68
|
-
throw new Error('Invalid state. You cannot assert presence against URL properties.');
|
|
69
|
-
}
|
|
70
|
-
if (step.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
71
|
-
throw new Error('Invalid state. You cannot assert presence against variable properties.');
|
|
72
|
-
}
|
|
73
|
-
const assertNotPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementNotPresent', step);
|
|
74
|
-
assertNotPresentStep.target = findActionToSeleniumTarget(step.primaryAction);
|
|
75
|
-
return [assertNotPresentStep];
|
|
76
|
-
}
|
|
77
|
-
return buildSeleniumIdeJsAssertion(stepIndex, (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
|
|
78
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
79
|
-
find.findType === domUtil_1.FindType.FIND_ONE &&
|
|
80
|
-
find.findTarget.selector.xpath) ||
|
|
81
|
-
'', step.extractAction ? step.extractAction.extractionAttribute : '', (0, SeleniumIdeStep_1.substituteSeleniumVariable)(step.conditionAction.conditionValueAttribute || ''), step.assertionType, step, (_a = step.conditionAction.options) === null || _a === void 0 ? void 0 : _a.caseInsensitive);
|
|
82
|
-
}
|
|
83
|
-
function unsupportedSelIdeExportStep(step) {
|
|
84
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', step);
|
|
85
|
-
const findDescriptor = step.primaryAction.toDescriptor();
|
|
86
|
-
seleniumStep.value = `[${step.getStepName()}] step with find type [${FindAction_1.findTypesToFormattedType[(!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(findDescriptor) &&
|
|
87
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(findDescriptor) &&
|
|
88
|
-
findDescriptor.findType) ||
|
|
89
|
-
'unknown']} is not supported for Selenium IDE export`;
|
|
90
|
-
return seleniumStep;
|
|
91
|
-
}
|
|
92
|
-
function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, assertAgainst, assertionType, step, caseInsensitive = false) {
|
|
93
|
-
const variableName = `assertVariable-${stepIndex}`;
|
|
94
|
-
let storeAttribute;
|
|
95
|
-
if (assertionAttribute !== 'innerText') {
|
|
96
|
-
storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
|
|
97
|
-
storeAttribute.target = `return document.evaluate('${xpath}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue['${assertionAttribute}']`;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeText', step);
|
|
101
|
-
storeAttribute.target = `xpath=${xpath}`;
|
|
102
|
-
}
|
|
103
|
-
storeAttribute.value = variableName;
|
|
104
|
-
let condition = '';
|
|
105
|
-
const toLowerCaseString = caseInsensitive
|
|
106
|
-
? '.toUpperCase().toLowerCase()'
|
|
107
|
-
: '';
|
|
108
|
-
switch (assertionType) {
|
|
109
|
-
case 'equals':
|
|
110
|
-
condition = `\${${variableName}}${toLowerCaseString} !== '${assertAgainst}'${toLowerCaseString}`;
|
|
111
|
-
break;
|
|
112
|
-
case 'does_not_equal':
|
|
113
|
-
condition = `\${${variableName}}${toLowerCaseString} === '${assertAgainst}'${toLowerCaseString}`;
|
|
114
|
-
break;
|
|
115
|
-
case 'contains':
|
|
116
|
-
condition = `!\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
117
|
-
break;
|
|
118
|
-
case 'does_not_contain':
|
|
119
|
-
condition = `\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
120
|
-
break;
|
|
121
|
-
case 'starts_with':
|
|
122
|
-
condition = `!\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
123
|
-
break;
|
|
124
|
-
case 'starts_without':
|
|
125
|
-
condition = `\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
126
|
-
break;
|
|
127
|
-
case 'ends_with':
|
|
128
|
-
condition = `!\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
129
|
-
break;
|
|
130
|
-
case 'ends_without':
|
|
131
|
-
condition = `\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
132
|
-
break;
|
|
133
|
-
case 'greater_than':
|
|
134
|
-
condition = `!\${${variableName}}${toLowerCaseString} > '${assertAgainst}'${toLowerCaseString}`;
|
|
135
|
-
break;
|
|
136
|
-
case 'less_than':
|
|
137
|
-
condition = `!\${${variableName}}${toLowerCaseString} < '${assertAgainst}'${toLowerCaseString}`;
|
|
138
|
-
break;
|
|
139
|
-
case 'greater_than_or_equals':
|
|
140
|
-
condition = `!\${${variableName}}${toLowerCaseString} >= '${assertAgainst}'${toLowerCaseString}`;
|
|
141
|
-
break;
|
|
142
|
-
case 'less_than_or_equals':
|
|
143
|
-
condition = `!\${${variableName}}${toLowerCaseString} <= '${assertAgainst}'${toLowerCaseString}`;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
const ifStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('if', step);
|
|
147
|
-
ifStep.target = condition;
|
|
148
|
-
const throwError = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
|
|
149
|
-
throwError.target = `throw new Error('${AssertStep_1.fieldToAssertionStep[assertionType]} step failure')`;
|
|
150
|
-
const endStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('end', step);
|
|
151
|
-
return [storeAttribute, ifStep, throwError, endStep];
|
|
152
|
-
}
|
|
153
|
-
function hoverStepToSeleniumSteps(step, _stepIndex) {
|
|
154
|
-
const hoverStep = step;
|
|
155
|
-
if (!hoverStep) {
|
|
156
|
-
throw new Error('Expected HoverStep');
|
|
157
|
-
}
|
|
158
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('mouseOver', hoverStep);
|
|
159
|
-
seleniumStep.target = findActionToSeleniumTarget(hoverStep.findAction);
|
|
160
|
-
return [seleniumStep];
|
|
161
|
-
}
|
|
162
|
-
exports.hoverStepToSeleniumSteps = hoverStepToSeleniumSteps;
|
|
163
|
-
function echoStepToSeleniumSteps(step, _stepIndex) {
|
|
164
|
-
const echoStep = step;
|
|
165
|
-
if (!echoStep) {
|
|
166
|
-
throw new Error(`Expected echo step`);
|
|
167
|
-
}
|
|
168
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', echoStep);
|
|
169
|
-
seleniumStep.target = (0, SeleniumIdeStep_1.substituteSeleniumVariable)(echoStep.echoValue);
|
|
170
|
-
return [seleniumStep];
|
|
171
|
-
}
|
|
172
|
-
exports.echoStepToSeleniumSteps = echoStepToSeleniumSteps;
|
|
173
|
-
function clickStepToSeleniumSteps(step, _stepIndex) {
|
|
174
|
-
const clickStep = step;
|
|
175
|
-
if (!clickStep) {
|
|
176
|
-
throw new Error('Expected a click step');
|
|
177
|
-
}
|
|
178
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('click', step);
|
|
179
|
-
seleniumStep.target = findActionToSeleniumTarget(clickStep.findAction);
|
|
180
|
-
return [seleniumStep];
|
|
181
|
-
}
|
|
182
|
-
exports.clickStepToSeleniumSteps = clickStepToSeleniumSteps;
|
|
183
|
-
function createVariableStepToSeleniumSteps(step, _stepIndex) {
|
|
184
|
-
let seleniumStep;
|
|
185
|
-
const createVariableStep = step;
|
|
186
|
-
if (!createVariableStep) {
|
|
187
|
-
throw new Error('Step is not a CreateVariableStep');
|
|
188
|
-
}
|
|
189
|
-
switch (createVariableStep.generationType) {
|
|
190
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
|
|
191
|
-
if (createVariableStep.actions[1].extractionAttribute ===
|
|
192
|
-
'innerText') {
|
|
193
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeText', createVariableStep);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeAttribute', createVariableStep);
|
|
197
|
-
}
|
|
198
|
-
seleniumStep.target = findActionToSeleniumTarget(createVariableStep.actions[0]);
|
|
199
|
-
seleniumStep.value = createVariableStep.variableName;
|
|
200
|
-
return [seleniumStep];
|
|
201
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.PATTERN:
|
|
202
|
-
const generateString = createVariableStep.actions[0].generateString;
|
|
203
|
-
const translated = generateString.replace(/{{([^{}]+)}}/g, (_match, p1) => {
|
|
204
|
-
let cleaned = p1;
|
|
205
|
-
if (cleaned[0] === '@') {
|
|
206
|
-
cleaned = cleaned.replace('@user.', '');
|
|
207
|
-
return '` + ${' + cleaned + '} + `';
|
|
208
|
-
}
|
|
209
|
-
const length = p1.split(':')[1];
|
|
210
|
-
return `\${Math.round((Math.pow(36, ${length} + 1) - Math.random() * Math.pow(36, ${length}))).toString(36).slice(1)}`;
|
|
211
|
-
});
|
|
212
|
-
const executeScript = 'return ' + '`' + translated + '`';
|
|
213
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', createVariableStep);
|
|
214
|
-
seleniumStep.target = executeScript;
|
|
215
|
-
seleniumStep.value = createVariableStep.variableName;
|
|
216
|
-
return [seleniumStep];
|
|
217
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
|
|
218
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', createVariableStep);
|
|
219
|
-
seleniumStep.value = `Generate email address for variable name '${createVariableStep.variableName} is not supported for Selenium IDE export`;
|
|
220
|
-
return [seleniumStep];
|
|
221
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
|
|
222
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', createVariableStep);
|
|
223
|
-
seleniumStep.value = `Find and store count of elements for variable name '${createVariableStep.variableName} is not supported for Selenium IDE export`;
|
|
224
|
-
return [seleniumStep];
|
|
225
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT:
|
|
226
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', createVariableStep);
|
|
227
|
-
seleniumStep.value = `[${createVariableStep.getStepName()}${createVariableStep.actions[0].javaScript
|
|
228
|
-
? ' from JavaScript'
|
|
229
|
-
: ''}] step for variable name '${createVariableStep.variableName} is not supported for Selenium IDE export`;
|
|
230
|
-
return [seleniumStep];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
exports.createVariableStepToSeleniumSteps = createVariableStepToSeleniumSteps;
|
|
234
|
-
function doubleClickStepToSeleniumSteps(step, _stepIndex) {
|
|
235
|
-
const doubleClickStep = step;
|
|
236
|
-
if (!doubleClickStep) {
|
|
237
|
-
throw new Error('Expected DoubleClickStep');
|
|
238
|
-
}
|
|
239
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('doubleClick', step);
|
|
240
|
-
seleniumStep.target = findActionToSeleniumTarget(doubleClickStep.findAction);
|
|
241
|
-
return [seleniumStep];
|
|
242
|
-
}
|
|
243
|
-
function enterTextStepToSeleniumSteps(step, _stepIndex) {
|
|
244
|
-
const enterTextStep = step;
|
|
245
|
-
if (!enterTextStep) {
|
|
246
|
-
throw new Error(`Expected EnterTextStep`);
|
|
247
|
-
}
|
|
248
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('type', enterTextStep);
|
|
249
|
-
seleniumStep.target = findActionToSeleniumTarget(enterTextStep.findAction);
|
|
250
|
-
seleniumStep.value = (0, SeleniumIdeStep_1.substituteSeleniumVariable)(enterTextStep.text);
|
|
251
|
-
return [seleniumStep];
|
|
252
|
-
}
|
|
253
|
-
exports.enterTextStepToSeleniumSteps = enterTextStepToSeleniumSteps;
|
|
254
|
-
function navigateStepToSeleniumSteps(step, _stepIndex) {
|
|
255
|
-
const navigateStep = step;
|
|
256
|
-
if (!navigateStep) {
|
|
257
|
-
throw new Error('Expected NavigateStep');
|
|
258
|
-
}
|
|
259
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', navigateStep);
|
|
260
|
-
seleniumStep.target = 'window.location.reload()';
|
|
261
|
-
return [seleniumStep];
|
|
262
|
-
}
|
|
263
|
-
function rightClickStepToSeleniumSteps(step, _stepIndex) {
|
|
264
|
-
const rightClickStep = step;
|
|
265
|
-
if (!rightClickStep) {
|
|
266
|
-
throw new Error('Expected RightClickStep');
|
|
267
|
-
}
|
|
268
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('contextClick', rightClickStep);
|
|
269
|
-
seleniumStep.target = findActionToSeleniumTarget(rightClickStep.findAction);
|
|
270
|
-
return [seleniumStep];
|
|
271
|
-
}
|
|
272
|
-
const SEL_IDE_KEYS = {
|
|
273
|
-
Alt: 'KEY_ALT',
|
|
274
|
-
ArrowDown: 'KEY_DOWN',
|
|
275
|
-
ArrowLeft: 'KEY_LEFT',
|
|
276
|
-
ArrowRight: 'KEY_RIGHT',
|
|
277
|
-
ArrowUp: 'KEY_UP',
|
|
278
|
-
Backspace: 'KEY_BACKSPACE',
|
|
279
|
-
Control: 'KEY_CTRL',
|
|
280
|
-
Delete: 'KEY_DELETE',
|
|
281
|
-
End: 'KEY_END',
|
|
282
|
-
Enter: 'KEY_ENTER',
|
|
283
|
-
Equals: 'KEY_EQUALS',
|
|
284
|
-
Escape: 'KEY_ESCAPE',
|
|
285
|
-
Home: 'KEY_HOME',
|
|
286
|
-
Insert: 'KEY_INSERT',
|
|
287
|
-
Meta: 'KEY_META',
|
|
288
|
-
PageDown: 'KEY_PAGE_DOWN',
|
|
289
|
-
PageUp: 'KEY_PAGE_UP',
|
|
290
|
-
Shift: 'KEY_SHIFT',
|
|
291
|
-
Space: 'KEY_SPACE',
|
|
292
|
-
Tab: 'KEY_TAB',
|
|
293
|
-
};
|
|
294
|
-
function sendKeyStepToSeleniumSteps(step, _stepIndex) {
|
|
295
|
-
const sendKeyStep = step;
|
|
296
|
-
if (!sendKeyStep) {
|
|
297
|
-
throw new Error('Expected SendKeyStep');
|
|
298
|
-
}
|
|
299
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('sendKeys', sendKeyStep);
|
|
300
|
-
seleniumStep.target = findActionToSeleniumTarget(sendKeyStep.findAction);
|
|
301
|
-
seleniumStep.value = sendKeyStep.keys
|
|
302
|
-
.map((keyPress) => {
|
|
303
|
-
if (Object.keys(SEL_IDE_KEYS).includes(keyPress.key)) {
|
|
304
|
-
return `\${${SEL_IDE_KEYS[keyPress.key]}}`;
|
|
305
|
-
}
|
|
306
|
-
return keyPress.key;
|
|
307
|
-
})
|
|
308
|
-
.join('');
|
|
309
|
-
return [seleniumStep];
|
|
310
|
-
}
|
|
311
|
-
function setViewportStepToSeleniumSteps(step, _stepIndex) {
|
|
312
|
-
const viewportStep = step;
|
|
313
|
-
if (!viewportStep) {
|
|
314
|
-
throw new Error('Expected SetViewportStep');
|
|
315
|
-
}
|
|
316
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('setWindowSize', viewportStep);
|
|
317
|
-
const width = viewportStep.size.width || 1920;
|
|
318
|
-
const height = viewportStep.size.height || 1080;
|
|
319
|
-
seleniumStep.target = (0, SeleniumIdeStep_1.substituteSeleniumVariable)(`${width}x${height}`);
|
|
320
|
-
return [seleniumStep];
|
|
321
|
-
}
|
|
322
|
-
function switchContextStepToSeleniumSteps(step, _stepIndex) {
|
|
323
|
-
const switchContextStep = step;
|
|
324
|
-
if (!switchContextStep) {
|
|
325
|
-
throw new Error('Expected SwitchContextStep');
|
|
326
|
-
}
|
|
327
|
-
if ((0, SwitchContextStepDescriptor_1.isSwitchRoot)(switchContextStep.switch) &&
|
|
328
|
-
switchContextStep.switch.frame === 'root') {
|
|
329
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectWindow', switchContextStep);
|
|
330
|
-
seleniumStep.target = 'window=0';
|
|
331
|
-
return [seleniumStep];
|
|
332
|
-
}
|
|
333
|
-
else if ((0, SwitchContextStepDescriptor_1.isSwitchTab)(switchContextStep.switch)) {
|
|
334
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectWindow', switchContextStep);
|
|
335
|
-
seleniumStep.target =
|
|
336
|
-
switchContextStep.switch.tab.findTarget === 'initial'
|
|
337
|
-
? 'tab=0'
|
|
338
|
-
: `title="${switchContextStep.switch.tab.findTarget.title}"`;
|
|
339
|
-
return [seleniumStep];
|
|
340
|
-
}
|
|
341
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectFrame', switchContextStep);
|
|
342
|
-
if (switchContextStep.findAction) {
|
|
343
|
-
seleniumStep.target = findActionToSeleniumTarget(switchContextStep.findAction);
|
|
344
|
-
}
|
|
345
|
-
return [seleniumStep];
|
|
346
|
-
}
|
|
347
|
-
function findActionToSeleniumTarget(action) {
|
|
348
|
-
switch (action.findDescriptor.findType) {
|
|
349
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
350
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
351
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
352
|
-
case domUtil_1.FindType.FIND_ALL:
|
|
353
|
-
if ((0, domUtil_1.isCssSelector)(action.findDescriptor.findTarget)) {
|
|
354
|
-
return `css=${action.findDescriptor.findTarget.css_query}`;
|
|
355
|
-
}
|
|
356
|
-
return `xpath=${action.findDescriptor.findTarget.xpath}`;
|
|
357
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
358
|
-
return `xpath=${action.findDescriptor.findTarget.selector.xpath}`;
|
|
359
|
-
default:
|
|
360
|
-
throw new Error(`Error generating SeleniumIDE target for ${action.getActionName()}: Unimplemented find type ${action.findDescriptor.findType}`);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function visitUrlStepToSeleniumSteps(step, _stepIndex) {
|
|
364
|
-
const visitUrlStep = step;
|
|
365
|
-
if (!visitUrlStep) {
|
|
366
|
-
throw new Error('Expected VisitUrlStep');
|
|
367
|
-
}
|
|
368
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('open', visitUrlStep);
|
|
369
|
-
seleniumStep.target = (0, SeleniumIdeStep_1.substituteSeleniumVariable)(visitUrlStep.url);
|
|
370
|
-
return [seleniumStep];
|
|
371
|
-
}
|
|
372
|
-
function waitStepToSeleniumSteps(step, _stepIndex) {
|
|
373
|
-
const waitStep = step;
|
|
374
|
-
if (!waitStep) {
|
|
375
|
-
throw new Error('Expected WaitStep');
|
|
376
|
-
}
|
|
377
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('pause', waitStep);
|
|
378
|
-
seleniumStep.target = `${waitStep.milliseconds}`;
|
|
379
|
-
return [seleniumStep];
|
|
380
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JourneyConfig = void 0;
|
|
4
|
-
const flowConfigGenerator_1 = require("./flowConfigGenerator");
|
|
5
|
-
class JourneyConfig {
|
|
6
|
-
constructor(journey, flows, includeLocatorInfo) {
|
|
7
|
-
this.journey = journey;
|
|
8
|
-
this.flows = flows;
|
|
9
|
-
this.includeLocatorInfo = includeLocatorInfo;
|
|
10
|
-
}
|
|
11
|
-
generateConfigFile() {
|
|
12
|
-
var _a;
|
|
13
|
-
const journeyConfig = {};
|
|
14
|
-
journeyConfig.configVersion = 1;
|
|
15
|
-
journeyConfig.journeyId = this.journey.id;
|
|
16
|
-
journeyConfig.journeyVersion = this.journey.version;
|
|
17
|
-
journeyConfig.workspaceId = this.journey.organization_id;
|
|
18
|
-
journeyConfig.name = this.journey.name;
|
|
19
|
-
journeyConfig.description = this.journey.description;
|
|
20
|
-
journeyConfig.tags = this.journey.tags;
|
|
21
|
-
journeyConfig.labels = (_a = this.journey.labels) === null || _a === void 0 ? void 0 : _a.map((label) => label.name);
|
|
22
|
-
journeyConfig.dataTables = this.journey.datatables;
|
|
23
|
-
journeyConfig.flows = this.flows.map((flow) => {
|
|
24
|
-
const flowConfigGenerator = new flowConfigGenerator_1.FlowConfig(flow, this.includeLocatorInfo);
|
|
25
|
-
return flowConfigGenerator.generateConfigFile();
|
|
26
|
-
});
|
|
27
|
-
convertUndefined(journeyConfig);
|
|
28
|
-
return journeyConfig;
|
|
29
|
-
}
|
|
30
|
-
generateSimpleFormat() {
|
|
31
|
-
const config = this.generateConfigFile();
|
|
32
|
-
let steps = [];
|
|
33
|
-
let apiSteps;
|
|
34
|
-
config.flows.forEach((flow) => {
|
|
35
|
-
if (flow.api_steps) {
|
|
36
|
-
apiSteps = flow.api_steps;
|
|
37
|
-
}
|
|
38
|
-
steps = steps.concat(flowConfigGenerator_1.FlowConfig.generateStepsSimpleFormat(flow.steps));
|
|
39
|
-
});
|
|
40
|
-
const output = {
|
|
41
|
-
id: this.journey.id,
|
|
42
|
-
name: this.journey.name,
|
|
43
|
-
description: this.journey.description || '',
|
|
44
|
-
steps,
|
|
45
|
-
};
|
|
46
|
-
if (apiSteps) {
|
|
47
|
-
output.api_steps = apiSteps;
|
|
48
|
-
}
|
|
49
|
-
return output;
|
|
50
|
-
}
|
|
51
|
-
generateSimpleCsv() {
|
|
52
|
-
const config = this.generateConfigFile();
|
|
53
|
-
const output = [
|
|
54
|
-
' ,Step Number, Step Type, Description, Annotation, Note',
|
|
55
|
-
];
|
|
56
|
-
let count = 0;
|
|
57
|
-
config.flows.forEach((flow) => {
|
|
58
|
-
flow.steps.forEach((step) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
const stepName = Object.keys(step)[0];
|
|
61
|
-
const stepObj = step;
|
|
62
|
-
const mablStep = stepObj[stepName];
|
|
63
|
-
output.push(`${count}, ${stepName}, ${mablStep.description}, ${((_a = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _a === void 0 ? void 0 : _a.note) || '-'}, ${((_b = mablStep === null || mablStep === void 0 ? void 0 : mablStep.annotation) === null || _b === void 0 ? void 0 : _b.description) || '-'}`);
|
|
64
|
-
count += 1;
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return output;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.JourneyConfig = JourneyConfig;
|
|
71
|
-
function convertUndefined(mablObjectConfigFile) {
|
|
72
|
-
Object.keys(mablObjectConfigFile).forEach((key) => {
|
|
73
|
-
if (mablObjectConfigFile[key] === undefined) {
|
|
74
|
-
mablObjectConfigFile[key] = null;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
package/util/csvUtil.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.desanitizeCellOutput = exports.sanitizeCellInput = void 0;
|
|
4
|
-
const MALICIOUS_LINE_PREFIX_MATCHER = /^([+\-@=])/;
|
|
5
|
-
const SANITIZED_LINE_PREFIX_MATCHER = /^(`[+\-@=])/;
|
|
6
|
-
function sanitizeCellInput(input) {
|
|
7
|
-
return MALICIOUS_LINE_PREFIX_MATCHER.test(input) ? `\`${input}` : input;
|
|
8
|
-
}
|
|
9
|
-
exports.sanitizeCellInput = sanitizeCellInput;
|
|
10
|
-
function desanitizeCellOutput(input) {
|
|
11
|
-
return SANITIZED_LINE_PREFIX_MATCHER.test(input) ? input.slice(1) : input;
|
|
12
|
-
}
|
|
13
|
-
exports.desanitizeCellOutput = desanitizeCellOutput;
|