@mablhq/mabl-cli 1.48.41 → 1.48.47
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/basicApiClient.js +8 -2
- package/api/mablApiClient.js +6 -8
- package/api/mablApiClientFactory.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +4 -0
- package/{mablscript/steps → codeGenerators/seleniumConfigGenerators}/SeleniumIdeStep.js +9 -1
- package/{configGenerators → codeGenerators/seleniumConfigGenerators}/flowConfigGenerator.js +1 -1
- package/{configGenerators → codeGenerators/seleniumConfigGenerators}/selIdeGenerator.js +20 -4
- package/codeGenerators/seleniumConfigGenerators/stepConverters.js +380 -0
- package/commands/flows/flows_cmds/export.js +1 -1
- package/commands/tests/tests_cmds/export.js +2 -2
- package/execution/index.js +1 -1
- package/mablscript/MablStep.js +0 -14
- package/mablscript/actions/ExtractAction.js +23 -4
- package/mablscript/actions/FindAction.js +0 -16
- package/mablscript/importer.js +1 -6
- package/mablscript/steps/AssertStep.js +4 -109
- package/mablscript/steps/ClickStep.js +0 -6
- package/mablscript/steps/CreateVariableStep.js +4 -47
- package/mablscript/steps/DoubleClickStep.js +0 -6
- package/mablscript/steps/EchoStep.js +0 -6
- package/mablscript/steps/EnterTextStep.js +0 -7
- package/mablscript/steps/HoverStep.js +0 -6
- package/mablscript/steps/IfConditionStep.js +4 -1
- package/mablscript/steps/NavigateStep.js +0 -6
- package/mablscript/steps/RightClickStep.js +0 -6
- package/mablscript/steps/SendKeyStep.js +0 -36
- package/mablscript/steps/SetViewportStep.js +0 -8
- package/mablscript/steps/SwitchContextStep.js +0 -21
- package/mablscript/steps/VisitUrlStep.js +0 -6
- package/mablscript/steps/WaitStep.js +0 -6
- package/mablscript/types/ExtractDescriptor.js +1 -0
- package/package.json +1 -1
- /package/{configGenerators → codeGenerators/seleniumConfigGenerators}/testConfigGenerator.js +0 -0
package/mablscript/MablStep.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.buildObjectString = exports.buildSourceRepresentationOfObject = exports.
|
|
|
7
7
|
const domUtil_1 = require("../domUtil");
|
|
8
8
|
const MablAction_1 = require("./MablAction");
|
|
9
9
|
const MablSymbol_1 = require("./MablSymbol");
|
|
10
|
-
const SeleniumIdeStep_1 = require("./steps/SeleniumIdeStep");
|
|
11
10
|
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
12
11
|
class MablStep extends MablAction_1.MablAction {
|
|
13
12
|
constructor(name, args, actions) {
|
|
@@ -56,12 +55,6 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
56
55
|
}
|
|
57
56
|
return `"${argument}"`;
|
|
58
57
|
}
|
|
59
|
-
substituteSeleniumVariable(argument) {
|
|
60
|
-
if (argument instanceof MablSymbol_1.MablSymbol) {
|
|
61
|
-
return '${' + argument.name + '}';
|
|
62
|
-
}
|
|
63
|
-
return argument.replace(/{{@?([^{}]+)}}/g, (_match, p1) => '${' + p1 + '}');
|
|
64
|
-
}
|
|
65
58
|
toStepDescriptor(_fullLocatorsOn) {
|
|
66
59
|
const formatted = {
|
|
67
60
|
names: this.actions.map((action) => action.getActionName()),
|
|
@@ -93,13 +86,6 @@ class MablStep extends MablAction_1.MablAction {
|
|
|
93
86
|
Object.assign(formatted[this.getStepName()], this.toStepDescriptor(fullLocatorsOn));
|
|
94
87
|
return formatted;
|
|
95
88
|
}
|
|
96
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
97
|
-
const selIdeEcho = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo');
|
|
98
|
-
const unSupportedStepMessage = `[${this.getStepName()}] Step is not supported for Selenium IDE export`;
|
|
99
|
-
selIdeEcho.comment = unSupportedStepMessage;
|
|
100
|
-
selIdeEcho.target = unSupportedStepMessage;
|
|
101
|
-
return [selIdeEcho];
|
|
102
|
-
}
|
|
103
89
|
toMablscript() {
|
|
104
90
|
return '';
|
|
105
91
|
}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractAction = void 0;
|
|
3
|
+
exports.ExtractAction = exports.CSS_EXTRACTION_VALUE = exports.EXTRACTION_TYPE_KEY = void 0;
|
|
4
4
|
const MablAction_1 = require("../MablAction");
|
|
5
5
|
const ExtractDescriptor_1 = require("../types/ExtractDescriptor");
|
|
6
|
+
exports.EXTRACTION_TYPE_KEY = 'extraction_type';
|
|
7
|
+
exports.CSS_EXTRACTION_VALUE = 'css';
|
|
6
8
|
class ExtractAction extends MablAction_1.MablAction {
|
|
7
9
|
constructor(name, args) {
|
|
8
10
|
super(name, args);
|
|
9
11
|
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_INNER_TEXT) {
|
|
10
|
-
this.name =
|
|
12
|
+
this.name = ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE;
|
|
11
13
|
this.extractionAttribute = 'innerText';
|
|
12
14
|
}
|
|
13
15
|
else {
|
|
14
16
|
this.extractionAttribute = this.getActionArgs()[0];
|
|
15
17
|
}
|
|
16
|
-
this.
|
|
18
|
+
if (this.name === ExtractDescriptor_1.ExtractType.EXTRACT_ATTRIBUTE && this.args.length > 1) {
|
|
19
|
+
const extractionOptions = this.args[1];
|
|
20
|
+
const metaExtractionType = extractionOptions.extraction_type;
|
|
21
|
+
if (metaExtractionType &&
|
|
22
|
+
metaExtractionType.toLowerCase() === exports.CSS_EXTRACTION_VALUE) {
|
|
23
|
+
this.extractionType = ExtractDescriptor_1.ExtractType.EXTRACT_CSS_PROPERTIES.toString();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.extractionType = this.name;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.extractionType = this.name;
|
|
31
|
+
}
|
|
17
32
|
this.extractDescriptor = this.getExtractDescriptor();
|
|
18
33
|
}
|
|
19
34
|
getExtractDescriptor() {
|
|
@@ -24,11 +39,14 @@ class ExtractAction extends MablAction_1.MablAction {
|
|
|
24
39
|
throw new Error(`Invalid attribute provided for extract attribute extractor: ${this.extractionAttribute}`);
|
|
25
40
|
}
|
|
26
41
|
return {
|
|
27
|
-
extractType: ExtractDescriptor_1.ExtractType.fromString(this.
|
|
42
|
+
extractType: ExtractDescriptor_1.ExtractType.fromString(this.extractionType),
|
|
28
43
|
attributeName: this.extractionAttribute,
|
|
29
44
|
};
|
|
30
45
|
}
|
|
31
46
|
toMablscript() {
|
|
47
|
+
if (this.extractionType === ExtractDescriptor_1.ExtractType.EXTRACT_CSS_PROPERTIES) {
|
|
48
|
+
return `extract_attribute("${this.extractionAttribute}", {${exports.EXTRACTION_TYPE_KEY}: "${exports.CSS_EXTRACTION_VALUE}"})`;
|
|
49
|
+
}
|
|
32
50
|
return `${this.extractionType}("${this.extractionAttribute}")`;
|
|
33
51
|
}
|
|
34
52
|
static mablScriptTypeFromYamlType(yamlType) {
|
|
@@ -43,5 +61,6 @@ ExtractAction.mablScriptStepNames = [
|
|
|
43
61
|
];
|
|
44
62
|
ExtractAction.mablscriptToYamlType = {
|
|
45
63
|
extract_attribute: 'ElementAttribute',
|
|
64
|
+
extract_css_property: 'CssProperty',
|
|
46
65
|
extract_email_attribute: 'EmailAttribute',
|
|
47
66
|
};
|
|
@@ -153,22 +153,6 @@ class FindAction extends MablAction_1.MablAction {
|
|
|
153
153
|
}
|
|
154
154
|
return result;
|
|
155
155
|
}
|
|
156
|
-
getSelIdeTarget() {
|
|
157
|
-
switch (this.findDescriptor.findType) {
|
|
158
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
159
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
160
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
161
|
-
case domUtil_1.FindType.FIND_ALL:
|
|
162
|
-
if ((0, domUtil_1.isCssSelector)(this.findDescriptor.findTarget)) {
|
|
163
|
-
return `css=${this.findDescriptor.findTarget.css_query}`;
|
|
164
|
-
}
|
|
165
|
-
return `xpath=${this.findDescriptor.findTarget.xpath}`;
|
|
166
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
167
|
-
return `xpath=${this.findDescriptor.findTarget.selector.xpath}`;
|
|
168
|
-
default:
|
|
169
|
-
throw new Error(`Error generating SeleniumIDE target for ${this.getActionName()}: Unimplemented find type ${this.findDescriptor.findType}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
156
|
toMablscript() {
|
|
173
157
|
return this.generateFindMablscript();
|
|
174
158
|
}
|
package/mablscript/importer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractOutputVariables = exports.extractInputVariables = exports.parseMablScriptIntoSteps = exports.mablscriptTheLoadedSteps = exports.
|
|
3
|
+
exports.extractOutputVariables = exports.extractInputVariables = exports.parseMablScriptIntoSteps = exports.mablscriptTheLoadedSteps = exports.loadYamlSteps = exports.yamlifyTheLoadedSteps = exports.loadMablScriptIntoSteps = exports.parseMablScript = void 0;
|
|
4
4
|
const esprima_1 = require("esprima");
|
|
5
5
|
const estraverse_1 = require("estraverse");
|
|
6
6
|
const AssertStep_1 = require("./steps/AssertStep");
|
|
@@ -197,11 +197,6 @@ function loadYamlSteps(yamlSteps) {
|
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
exports.loadYamlSteps = loadYamlSteps;
|
|
200
|
-
function seleniumIdeTheLoadedSteps(translatedSteps) {
|
|
201
|
-
const selIdeSteps = translatedSteps.map((step, stepIndex) => step.produceSelIdeFormattedSteps(stepIndex));
|
|
202
|
-
return [].concat.apply([], selIdeSteps);
|
|
203
|
-
}
|
|
204
|
-
exports.seleniumIdeTheLoadedSteps = seleniumIdeTheLoadedSteps;
|
|
205
200
|
function getMablscriptMaybeWithComment(step) {
|
|
206
201
|
return `${step.isDisabled() ? '//' : ''}${step.toMablscript()}`;
|
|
207
202
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssertStep = exports.fieldToAssertionStep = exports.assertionStepToField = void 0;
|
|
4
4
|
const ConditionAction_1 = require("../actions/ConditionAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const FindAction_1 = require("../actions/FindAction");
|
|
7
6
|
const MablStep_1 = require("../MablStep");
|
|
8
7
|
const MablAction_1 = require("../MablAction");
|
|
@@ -187,7 +186,10 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
187
186
|
actions.push(new CountAction_1.CountAction('count', [stepArgs.attribute]));
|
|
188
187
|
}
|
|
189
188
|
else {
|
|
190
|
-
|
|
189
|
+
const extractArgs = stepArgs.extractionOptions
|
|
190
|
+
? [stepArgs.attribute, stepArgs.extractionOptions]
|
|
191
|
+
: [stepArgs.attribute];
|
|
192
|
+
actions.push(new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(stepArgs.extractType), extractArgs));
|
|
191
193
|
}
|
|
192
194
|
actions.push(new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
193
195
|
assertionType,
|
|
@@ -202,52 +204,6 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
202
204
|
},
|
|
203
205
|
], actions);
|
|
204
206
|
}
|
|
205
|
-
produceSelIdeFormattedSteps(stepIndex) {
|
|
206
|
-
var _a;
|
|
207
|
-
const find = this.primaryAction.toDescriptor();
|
|
208
|
-
if (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
|
|
209
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
210
|
-
(find.findType === domUtil_1.FindType.FIND_EMAIL ||
|
|
211
|
-
find.findType === domUtil_1.FindType.FIND_COOKIE)) {
|
|
212
|
-
return [this.unsupportedSelIdeExportStep()];
|
|
213
|
-
}
|
|
214
|
-
if (this.assertionType === 'present') {
|
|
215
|
-
if (this.primaryAction instanceof GetUrlAction_1.GetUrlAction) {
|
|
216
|
-
throw new Error('Invalid state. You cannot assert presence against URL properties.');
|
|
217
|
-
}
|
|
218
|
-
if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
219
|
-
throw new Error('Invalid state. You cannot assert presence against variable properties.');
|
|
220
|
-
}
|
|
221
|
-
const assertPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementPresent', this);
|
|
222
|
-
assertPresentStep.target = this.primaryAction.getSelIdeTarget();
|
|
223
|
-
return [assertPresentStep];
|
|
224
|
-
}
|
|
225
|
-
else if (this.assertionType === 'not_present') {
|
|
226
|
-
if (this.primaryAction instanceof GetUrlAction_1.GetUrlAction) {
|
|
227
|
-
throw new Error('Invalid state. You cannot assert presence against URL properties.');
|
|
228
|
-
}
|
|
229
|
-
if (this.primaryAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
230
|
-
throw new Error('Invalid state. You cannot assert presence against variable properties.');
|
|
231
|
-
}
|
|
232
|
-
const assertNotPresentStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('assertElementNotPresent', this);
|
|
233
|
-
assertNotPresentStep.target = this.primaryAction.getSelIdeTarget();
|
|
234
|
-
return [assertNotPresentStep];
|
|
235
|
-
}
|
|
236
|
-
return buildSeleniumIdeJsAssertion(stepIndex, (!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(find) &&
|
|
237
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(find) &&
|
|
238
|
-
find.findType === domUtil_1.FindType.FIND_ONE &&
|
|
239
|
-
find.findTarget.selector.xpath) ||
|
|
240
|
-
'', this.extractAction ? this.extractAction.extractionAttribute : '', this.substituteSeleniumVariable(this.conditionAction.conditionValueAttribute || ''), this.assertionType, this, (_a = this.conditionAction.options) === null || _a === void 0 ? void 0 : _a.caseInsensitive);
|
|
241
|
-
}
|
|
242
|
-
unsupportedSelIdeExportStep() {
|
|
243
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
244
|
-
const findDescriptor = this.primaryAction.toDescriptor();
|
|
245
|
-
seleniumStep.value = `[${this.getStepName()}] step with find type [${FindAction_1.findTypesToFormattedType[(!(0, GetCurrentLocationDescriptor_1.isGetCurrentLocationDescriptor)(findDescriptor) &&
|
|
246
|
-
!(0, GetVariableDescriptor_1.isGetVariableDescriptor)(findDescriptor) &&
|
|
247
|
-
findDescriptor.findType) ||
|
|
248
|
-
'unknown']} is not supported for Selenium IDE export`;
|
|
249
|
-
return seleniumStep;
|
|
250
|
-
}
|
|
251
207
|
toMablscript() {
|
|
252
208
|
var _a, _b;
|
|
253
209
|
const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
|
|
@@ -279,64 +235,3 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
279
235
|
exports.AssertStep = AssertStep;
|
|
280
236
|
AssertStep.mablScriptStepNames = ['assert'];
|
|
281
237
|
AssertStep.yamlMablScriptNames = yamlMablScriptNames();
|
|
282
|
-
function buildSeleniumIdeJsAssertion(stepIndex, xpath, assertionAttribute, assertAgainst, assertionType, step, caseInsensitive = false) {
|
|
283
|
-
const variableName = `assertVariable-${stepIndex}`;
|
|
284
|
-
let storeAttribute;
|
|
285
|
-
if (assertionAttribute !== 'innerText') {
|
|
286
|
-
storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
|
|
287
|
-
storeAttribute.target = `return document.evaluate('${xpath}', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue['${assertionAttribute}']`;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
storeAttribute = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeText', step);
|
|
291
|
-
storeAttribute.target = `xpath=${xpath}`;
|
|
292
|
-
}
|
|
293
|
-
storeAttribute.value = variableName;
|
|
294
|
-
let condition = '';
|
|
295
|
-
const toLowerCaseString = caseInsensitive
|
|
296
|
-
? '.toUpperCase().toLowerCase()'
|
|
297
|
-
: '';
|
|
298
|
-
switch (assertionType) {
|
|
299
|
-
case 'equals':
|
|
300
|
-
condition = `\${${variableName}}${toLowerCaseString} !== '${assertAgainst}'${toLowerCaseString}`;
|
|
301
|
-
break;
|
|
302
|
-
case 'does_not_equal':
|
|
303
|
-
condition = `\${${variableName}}${toLowerCaseString} === '${assertAgainst}'${toLowerCaseString}`;
|
|
304
|
-
break;
|
|
305
|
-
case 'contains':
|
|
306
|
-
condition = `!\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
307
|
-
break;
|
|
308
|
-
case 'does_not_contain':
|
|
309
|
-
condition = `\${${variableName}}${toLowerCaseString}.includes('${assertAgainst}'${toLowerCaseString})`;
|
|
310
|
-
break;
|
|
311
|
-
case 'starts_with':
|
|
312
|
-
condition = `!\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
313
|
-
break;
|
|
314
|
-
case 'starts_without':
|
|
315
|
-
condition = `\${${variableName}}${toLowerCaseString}.startsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
316
|
-
break;
|
|
317
|
-
case 'ends_with':
|
|
318
|
-
condition = `!\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
319
|
-
break;
|
|
320
|
-
case 'ends_without':
|
|
321
|
-
condition = `\${${variableName}}${toLowerCaseString}.endsWith('${assertAgainst}'${toLowerCaseString})`;
|
|
322
|
-
break;
|
|
323
|
-
case 'greater_than':
|
|
324
|
-
condition = `!\${${variableName}}${toLowerCaseString} > '${assertAgainst}'${toLowerCaseString}`;
|
|
325
|
-
break;
|
|
326
|
-
case 'less_than':
|
|
327
|
-
condition = `!\${${variableName}}${toLowerCaseString} < '${assertAgainst}'${toLowerCaseString}`;
|
|
328
|
-
break;
|
|
329
|
-
case 'greater_than_or_equals':
|
|
330
|
-
condition = `!\${${variableName}}${toLowerCaseString} >= '${assertAgainst}'${toLowerCaseString}`;
|
|
331
|
-
break;
|
|
332
|
-
case 'less_than_or_equals':
|
|
333
|
-
condition = `!\${${variableName}}${toLowerCaseString} <= '${assertAgainst}'${toLowerCaseString}`;
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
const ifStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('if', step);
|
|
337
|
-
ifStep.target = condition;
|
|
338
|
-
const throwError = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', step);
|
|
339
|
-
throwError.target = `throw new Error('${exports.fieldToAssertionStep[assertionType]} step failure')`;
|
|
340
|
-
const endStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('end', step);
|
|
341
|
-
return [storeAttribute, ifStep, throwError, endStep];
|
|
342
|
-
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClickStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
8
7
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
@@ -37,11 +36,6 @@ class ClickStep extends MablStep_1.MablStep {
|
|
|
37
36
|
},
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
41
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('click', this);
|
|
42
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
43
|
-
return [seleniumStep];
|
|
44
|
-
}
|
|
45
39
|
static fromYaml(_stepName, stepArgs) {
|
|
46
40
|
return new ClickStep('click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
47
41
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CreateVariableStep = void 0;
|
|
4
4
|
const ExtractAction_1 = require("../actions/ExtractAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const FindAction_1 = require("../actions/FindAction");
|
|
8
7
|
const GenerateEmailAddressAction_1 = require("../actions/GenerateEmailAddressAction");
|
|
@@ -151,51 +150,6 @@ class CreateVariableStep extends MablStep_1.MablStep {
|
|
|
151
150
|
}
|
|
152
151
|
return formatted;
|
|
153
152
|
}
|
|
154
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
155
|
-
let seleniumStep;
|
|
156
|
-
switch (this.generationType) {
|
|
157
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
|
|
158
|
-
if (this.actions[1].extractionAttribute === 'innerText') {
|
|
159
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeText', this);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('storeAttribute', this);
|
|
163
|
-
}
|
|
164
|
-
seleniumStep.target = this.actions[0].getSelIdeTarget();
|
|
165
|
-
seleniumStep.value = this.variableName;
|
|
166
|
-
return [seleniumStep];
|
|
167
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.PATTERN:
|
|
168
|
-
const generateString = this.actions[0].generateString;
|
|
169
|
-
const translated = generateString.replace(/{{([^{}]+)}}/g, (_match, p1) => {
|
|
170
|
-
let cleaned = p1;
|
|
171
|
-
if (cleaned[0] === '@') {
|
|
172
|
-
cleaned = cleaned.replace('@user.', '');
|
|
173
|
-
return '` + ${' + cleaned + '} + `';
|
|
174
|
-
}
|
|
175
|
-
const length = p1.split(':')[1];
|
|
176
|
-
return `\${Math.round((Math.pow(36, ${length} + 1) - Math.random() * Math.pow(36, ${length}))).toString(36).slice(1)}`;
|
|
177
|
-
});
|
|
178
|
-
const executeScript = 'return ' + '`' + translated + '`';
|
|
179
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', this);
|
|
180
|
-
seleniumStep.target = executeScript;
|
|
181
|
-
seleniumStep.value = this.variableName;
|
|
182
|
-
return [seleniumStep];
|
|
183
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.EMAIL:
|
|
184
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
185
|
-
seleniumStep.value = `Generate email address for variable name '${this.variableName} is not supported for Selenium IDE export`;
|
|
186
|
-
return [seleniumStep];
|
|
187
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
|
|
188
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
189
|
-
seleniumStep.value = `Find and store count of elements for variable name '${this.variableName} is not supported for Selenium IDE export`;
|
|
190
|
-
return [seleniumStep];
|
|
191
|
-
case CreateVariableStepDescriptor_1.VariableGenerator.JAVASCRIPT:
|
|
192
|
-
seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
193
|
-
seleniumStep.value = `[${this.getStepName()}${this.actions[0].javaScript
|
|
194
|
-
? ' from JavaScript'
|
|
195
|
-
: ''}] step for variable name '${this.variableName} is not supported for Selenium IDE export`;
|
|
196
|
-
return [seleniumStep];
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
153
|
static fromYaml(_stepName, stepArgs) {
|
|
200
154
|
const variableName = stepArgs.name;
|
|
201
155
|
const generator = stepArgs.generator;
|
|
@@ -204,7 +158,10 @@ class CreateVariableStep extends MablStep_1.MablStep {
|
|
|
204
158
|
switch (generationType) {
|
|
205
159
|
case CreateVariableStepDescriptor_1.VariableGenerator.ATTRIBUTE:
|
|
206
160
|
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs));
|
|
207
|
-
|
|
161
|
+
const extractArgs = generator.metadata
|
|
162
|
+
? [generator.attribute, generator.metadata]
|
|
163
|
+
: [generator.attribute];
|
|
164
|
+
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
208
165
|
break;
|
|
209
166
|
case CreateVariableStepDescriptor_1.VariableGenerator.ELEMENT_COUNT:
|
|
210
167
|
actions.push(FindAction_1.FindAction.findActionFromStepArgs(stepArgs, domUtil_1.FindType.FIND_ALL));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DoubleClickStep = void 0;
|
|
4
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
5
4
|
const MablStep_1 = require("../MablStep");
|
|
6
5
|
const FindAction_1 = require("../actions/FindAction");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
@@ -46,11 +45,6 @@ class DoubleClickStep extends MablStep_1.MablStep {
|
|
|
46
45
|
static fromYaml(_stepName, stepArgs) {
|
|
47
46
|
return new DoubleClickStep('double_click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
48
47
|
}
|
|
49
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
50
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('doubleClick', this);
|
|
51
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
52
|
-
return [seleniumStep];
|
|
53
|
-
}
|
|
54
48
|
toMablscript() {
|
|
55
49
|
return `${this.findAction.toMablscript()}.double_click()`;
|
|
56
50
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EchoStep = void 0;
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
5
|
const domUtil_1 = require("../../domUtil");
|
|
6
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
7
6
|
const MablAction_1 = require("../MablAction");
|
|
8
7
|
class EchoStep extends MablStep_1.MablStep {
|
|
9
8
|
constructor(name, args, actions) {
|
|
@@ -16,11 +15,6 @@ class EchoStep extends MablStep_1.MablStep {
|
|
|
16
15
|
toStepDescriptor() {
|
|
17
16
|
return { value: this.echoValue.toString() };
|
|
18
17
|
}
|
|
19
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
20
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo', this);
|
|
21
|
-
seleniumStep.target = this.substituteSeleniumVariable(this.echoValue);
|
|
22
|
-
return [seleniumStep];
|
|
23
|
-
}
|
|
24
18
|
static fromYaml(_stepName, stepArgs) {
|
|
25
19
|
return new EchoStep('echo', [stepArgs.value], []);
|
|
26
20
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnterTextStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablAction_1 = require("../MablAction");
|
|
7
6
|
const MablStep_1 = require("../MablStep");
|
|
8
7
|
const domUtil_1 = require("../../domUtil");
|
|
@@ -70,12 +69,6 @@ class EnterTextStep extends MablStep_1.MablStep {
|
|
|
70
69
|
formatted[stepName].text = this.text.toString();
|
|
71
70
|
return formatted;
|
|
72
71
|
}
|
|
73
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
74
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('type', this);
|
|
75
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
76
|
-
seleniumStep.value = this.substituteSeleniumVariable(this.text);
|
|
77
|
-
return [seleniumStep];
|
|
78
|
-
}
|
|
79
72
|
static fromYaml(_stepName, stepArgs) {
|
|
80
73
|
return new EnterTextStep('enter_text', [stepArgs.text], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
81
74
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HoverStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
8
7
|
class HoverStep extends MablStep_1.MablStep {
|
|
@@ -45,11 +44,6 @@ class HoverStep extends MablStep_1.MablStep {
|
|
|
45
44
|
static fromYaml(_stepName, stepArgs) {
|
|
46
45
|
return new HoverStep('hover', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
47
46
|
}
|
|
48
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
49
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('mouseOver', this);
|
|
50
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
51
|
-
return [seleniumStep];
|
|
52
|
-
}
|
|
53
47
|
toMablscript() {
|
|
54
48
|
return `${this.findAction.toMablscript()}.hover()`;
|
|
55
49
|
}
|
|
@@ -104,7 +104,10 @@ class IfConditionStep extends MablStep_1.MablStep {
|
|
|
104
104
|
actions.push(findAction);
|
|
105
105
|
}
|
|
106
106
|
if (stepArgs.attribute) {
|
|
107
|
-
|
|
107
|
+
const extractArgs = stepArgs.metadata
|
|
108
|
+
? [stepArgs.attribute, stepArgs.metadata]
|
|
109
|
+
: [stepArgs.attribute];
|
|
110
|
+
actions.push(new ExtractAction_1.ExtractAction('extract_attribute', extractArgs));
|
|
108
111
|
}
|
|
109
112
|
if (stepArgs.variableName) {
|
|
110
113
|
actions.push(new GetVariableValue_1.GetVariableValue('get_variable_value', [
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NavigateStep = void 0;
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
class NavigateStep extends MablStep_1.MablStep {
|
|
7
6
|
constructor(name, args, actions) {
|
|
8
7
|
super(name, args, actions);
|
|
@@ -16,11 +15,6 @@ class NavigateStep extends MablStep_1.MablStep {
|
|
|
16
15
|
navigation: this.navigation,
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
20
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('executeScript', this);
|
|
21
|
-
seleniumStep.target = 'window.location.reload()';
|
|
22
|
-
return [seleniumStep];
|
|
23
|
-
}
|
|
24
18
|
static fromYaml(_stepName, stepArgs) {
|
|
25
19
|
return new NavigateStep('navigate', [stepArgs.navigation], []);
|
|
26
20
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RightClickStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
8
7
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
@@ -37,11 +36,6 @@ class RightClickStep extends MablStep_1.MablStep {
|
|
|
37
36
|
},
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
41
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('contextClick', this);
|
|
42
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
43
|
-
return [seleniumStep];
|
|
44
|
-
}
|
|
45
39
|
static fromYaml(_stepName, stepArgs) {
|
|
46
40
|
return new RightClickStep('right_click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
47
41
|
}
|
|
@@ -2,33 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SendKeyStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
8
7
|
const SendKeyStepDescriptor_1 = require("../types/SendKeyStepDescriptor");
|
|
9
8
|
const STEP_NAME = 'SendKeys';
|
|
10
|
-
const SEL_IDE_KEYS = {
|
|
11
|
-
Alt: 'KEY_ALT',
|
|
12
|
-
ArrowDown: 'KEY_DOWN',
|
|
13
|
-
ArrowLeft: 'KEY_LEFT',
|
|
14
|
-
ArrowRight: 'KEY_RIGHT',
|
|
15
|
-
ArrowUp: 'KEY_UP',
|
|
16
|
-
Backspace: 'KEY_BACKSPACE',
|
|
17
|
-
Control: 'KEY_CTRL',
|
|
18
|
-
Delete: 'KEY_DELETE',
|
|
19
|
-
End: 'KEY_END',
|
|
20
|
-
Enter: 'KEY_ENTER',
|
|
21
|
-
Equals: 'KEY_EQUALS',
|
|
22
|
-
Escape: 'KEY_ESCAPE',
|
|
23
|
-
Home: 'KEY_HOME',
|
|
24
|
-
Insert: 'KEY_INSERT',
|
|
25
|
-
Meta: 'KEY_META',
|
|
26
|
-
PageDown: 'KEY_PAGE_DOWN',
|
|
27
|
-
PageUp: 'KEY_PAGE_UP',
|
|
28
|
-
Shift: 'KEY_SHIFT',
|
|
29
|
-
Space: 'KEY_SPACE',
|
|
30
|
-
Tab: 'KEY_TAB',
|
|
31
|
-
};
|
|
32
9
|
class SendKeyStep extends MablStep_1.MablStep {
|
|
33
10
|
constructor(name, args, actions) {
|
|
34
11
|
super(name, args, actions);
|
|
@@ -80,19 +57,6 @@ class SendKeyStep extends MablStep_1.MablStep {
|
|
|
80
57
|
},
|
|
81
58
|
};
|
|
82
59
|
}
|
|
83
|
-
produceSelIdeFormattedSteps() {
|
|
84
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('sendKeys', this);
|
|
85
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
86
|
-
seleniumStep.value = this.keys
|
|
87
|
-
.map((keyPress) => {
|
|
88
|
-
if (Object.keys(SEL_IDE_KEYS).includes(keyPress.key)) {
|
|
89
|
-
return `\${${SEL_IDE_KEYS[keyPress.key]}}`;
|
|
90
|
-
}
|
|
91
|
-
return keyPress.key;
|
|
92
|
-
})
|
|
93
|
-
.join('');
|
|
94
|
-
return [seleniumStep];
|
|
95
|
-
}
|
|
96
60
|
static fromYaml(_stepName, stepArgs) {
|
|
97
61
|
return new SendKeyStep('send_keys', stepArgs.sendKeys, [
|
|
98
62
|
FindAction_1.FindAction.findActionFromStepArgs(stepArgs),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetViewportStep = void 0;
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
class SetViewportStep extends MablStep_1.MablStep {
|
|
7
6
|
constructor(name, args, actions) {
|
|
8
7
|
super(name, args, actions);
|
|
@@ -15,13 +14,6 @@ class SetViewportStep extends MablStep_1.MablStep {
|
|
|
15
14
|
toStepDescriptor() {
|
|
16
15
|
return { size: this.size };
|
|
17
16
|
}
|
|
18
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
19
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('setWindowSize', this);
|
|
20
|
-
const width = this.size.width || 1920;
|
|
21
|
-
const height = this.size.height || 1080;
|
|
22
|
-
seleniumStep.target = this.substituteSeleniumVariable(`${width}x${height}`);
|
|
23
|
-
return [seleniumStep];
|
|
24
|
-
}
|
|
25
17
|
static fromYaml(_stepName, stepArgs) {
|
|
26
18
|
return new SetViewportStep('set_viewport', [stepArgs], []);
|
|
27
19
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwitchContextStep = void 0;
|
|
4
4
|
const FindAction_1 = require("../actions/FindAction");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablStep_1 = require("../MablStep");
|
|
7
6
|
const SwitchContextStepDescriptor_1 = require("../types/SwitchContextStepDescriptor");
|
|
8
7
|
const domUtil_1 = require("../../domUtil");
|
|
@@ -89,26 +88,6 @@ class SwitchContextStep extends MablStep_1.MablStep {
|
|
|
89
88
|
}
|
|
90
89
|
return formatted;
|
|
91
90
|
}
|
|
92
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
93
|
-
if ((0, SwitchContextStepDescriptor_1.isSwitchRoot)(this.switch) && this.switch.frame === 'root') {
|
|
94
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectWindow', this);
|
|
95
|
-
seleniumStep.target = 'window=0';
|
|
96
|
-
return [seleniumStep];
|
|
97
|
-
}
|
|
98
|
-
else if ((0, SwitchContextStepDescriptor_1.isSwitchTab)(this.switch)) {
|
|
99
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectWindow', this);
|
|
100
|
-
seleniumStep.target =
|
|
101
|
-
this.switch.tab.findTarget === 'initial'
|
|
102
|
-
? 'tab=0'
|
|
103
|
-
: `title="${this.switch.tab.findTarget.title}"`;
|
|
104
|
-
return [seleniumStep];
|
|
105
|
-
}
|
|
106
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('selectFrame', this);
|
|
107
|
-
if (this.findAction) {
|
|
108
|
-
seleniumStep.target = this.findAction.getSelIdeTarget();
|
|
109
|
-
}
|
|
110
|
-
return [seleniumStep];
|
|
111
|
-
}
|
|
112
91
|
static fromYaml(_stepName, stepArgs) {
|
|
113
92
|
if (stepArgs.switch) {
|
|
114
93
|
return new SwitchContextStep('switch_context_to', [stepArgs.switch], []);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VisitUrlStep = void 0;
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
|
-
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
6
5
|
const MablAction_1 = require("../MablAction");
|
|
7
6
|
const domUtil_1 = require("../../domUtil");
|
|
8
7
|
class VisitUrlStep extends MablStep_1.MablStep {
|
|
@@ -19,11 +18,6 @@ class VisitUrlStep extends MablStep_1.MablStep {
|
|
|
19
18
|
url: this.url,
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
|
-
produceSelIdeFormattedSteps(_stepIndex) {
|
|
23
|
-
const seleniumStep = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('open', this);
|
|
24
|
-
seleniumStep.target = this.substituteSeleniumVariable(this.url);
|
|
25
|
-
return [seleniumStep];
|
|
26
|
-
}
|
|
27
21
|
static fromYaml(_stepName, stepArgs) {
|
|
28
22
|
return new VisitUrlStep('visit_url', [stepArgs.url], []);
|
|
29
23
|
}
|