@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/api/basicApiClient.js
CHANGED
|
@@ -181,9 +181,15 @@ class BasicApiClient {
|
|
|
181
181
|
BasicApiClient.checkResponseStatusCode(response);
|
|
182
182
|
return response.data;
|
|
183
183
|
}
|
|
184
|
-
async makePatchRequest(path, requestBody, ifMatch) {
|
|
184
|
+
async makePatchRequest(path, requestBody, ifMatch, requestConfig) {
|
|
185
|
+
return this.patchRequest(path, requestBody, ifMatch, this.getNonRetryableRequestConfig(requestConfig));
|
|
186
|
+
}
|
|
187
|
+
async makePatchRequestWithRetries(path, requestBody, ifMatch, config) {
|
|
188
|
+
return this.retryWrappedRequest(`makePatchRequestWithRetries('${path}')`, () => this.patchRequest(path, requestBody, ifMatch, this.getRetryableRequestConfig(config)), config);
|
|
189
|
+
}
|
|
190
|
+
async patchRequest(path, requestBody, ifMatch, config) {
|
|
185
191
|
const extraConfig = ifMatch ? { headers: { 'If-Match': ifMatch } } : {};
|
|
186
|
-
const response = await this.debugRequest('PATCH', path, () => this.httpClient.patch(path, requestBody, extraConfig));
|
|
192
|
+
const response = await this.debugRequest('PATCH', path, () => this.httpClient.patch(path, requestBody, { ...config, ...extraConfig }));
|
|
187
193
|
BasicApiClient.checkResponseStatusCode(response);
|
|
188
194
|
return response.data;
|
|
189
195
|
}
|
package/api/mablApiClient.js
CHANGED
|
@@ -31,10 +31,6 @@ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
|
|
|
31
31
|
const basicApiClient_1 = require("./basicApiClient");
|
|
32
32
|
const queryString = __importStar(require("query-string"));
|
|
33
33
|
const featureSet_1 = require("./featureSet");
|
|
34
|
-
const DEPLOYMENT_EVENT_RETRY_CONFIG = {
|
|
35
|
-
requestTimeoutMillis: 0,
|
|
36
|
-
maxRetryTimeMillis: 1000 * 60 * 60,
|
|
37
|
-
};
|
|
38
34
|
class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
39
35
|
constructor(options) {
|
|
40
36
|
var _a;
|
|
@@ -258,7 +254,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
258
254
|
}
|
|
259
255
|
async getDeploymentResults(deploymentEventId) {
|
|
260
256
|
try {
|
|
261
|
-
return await this.makeGetRequest(`${this.baseApiUrl}/execution/result/event/${deploymentEventId}
|
|
257
|
+
return await this.makeGetRequest(`${this.baseApiUrl}/execution/result/event/${deploymentEventId}`);
|
|
262
258
|
}
|
|
263
259
|
catch (error) {
|
|
264
260
|
throw toApiError(`Failed to get deployment results`, error);
|
|
@@ -575,7 +571,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
575
571
|
async postDeploymentEvent(options) {
|
|
576
572
|
try {
|
|
577
573
|
const requestBody = this.buildDeploymentRequestBody(options);
|
|
578
|
-
return await this.makePostRequestWithRetries(`${this.baseApiUrl}/events/deployment/`, requestBody
|
|
574
|
+
return await this.makePostRequestWithRetries(`${this.baseApiUrl}/events/deployment/`, requestBody);
|
|
579
575
|
}
|
|
580
576
|
catch (error) {
|
|
581
577
|
throw toApiError(`Failed to create deployment`, error);
|
|
@@ -745,9 +741,11 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
745
741
|
throw toApiError(`Failed to get journey run info`, error);
|
|
746
742
|
}
|
|
747
743
|
}
|
|
748
|
-
async updateJourneyRun(journeyRunId, journeyRunUpdate, ifMatch) {
|
|
744
|
+
async updateJourneyRun(journeyRunId, journeyRunUpdate, ifMatch, retry) {
|
|
749
745
|
try {
|
|
750
|
-
const response =
|
|
746
|
+
const response = retry
|
|
747
|
+
? await this.makePatchRequestWithRetries(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`, journeyRunUpdate, ifMatch)
|
|
748
|
+
: await this.makePatchRequest(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`, journeyRunUpdate, ifMatch);
|
|
751
749
|
return response;
|
|
752
750
|
}
|
|
753
751
|
catch (error) {
|
|
@@ -19,8 +19,9 @@ class MablApiClientFactory {
|
|
|
19
19
|
}
|
|
20
20
|
return MablApiClientFactory.createApiClient();
|
|
21
21
|
}
|
|
22
|
-
static createApiClientFromApiKey(apiKey) {
|
|
22
|
+
static createApiClientFromApiKey(apiKey, apiUrl) {
|
|
23
23
|
return MablApiClientFactory.createApiClient({
|
|
24
|
+
apiUrl,
|
|
24
25
|
authType: types_1.AuthType.ApiKey,
|
|
25
26
|
token: apiKey,
|
|
26
27
|
});
|
|
@@ -246,6 +246,10 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
246
246
|
const result = await this.element.evaluate((el, attributeName) => el.getAttribute(attributeName), attributeName);
|
|
247
247
|
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
248
248
|
}
|
|
249
|
+
async getCSSProperty(propertyName) {
|
|
250
|
+
const result = await this.element.evaluate((el, propertyName) => globalThis.getComputedStyle(el).getPropertyValue(propertyName), propertyName);
|
|
251
|
+
return (0, pureUtil_1.isNullish)(result) ? undefined : result;
|
|
252
|
+
}
|
|
249
253
|
async getElementText() {
|
|
250
254
|
const innerText = await this.getInnerText();
|
|
251
255
|
return innerText ? innerText : this.getSlotText();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateIdForSeleniumEntity = exports.buildSeleniumIdeStep = void 0;
|
|
3
|
+
exports.substituteSeleniumVariable = exports.generateIdForSeleniumEntity = exports.buildSeleniumIdeStep = void 0;
|
|
4
|
+
const MablSymbol_1 = require("../../mablscript/MablSymbol");
|
|
4
5
|
const crypto = require('crypto');
|
|
5
6
|
function buildSeleniumIdeStep(commandName, mablscriptStep) {
|
|
6
7
|
let description = '';
|
|
@@ -30,3 +31,10 @@ function generateIdForSeleniumEntity(genValue) {
|
|
|
30
31
|
.digest('hex');
|
|
31
32
|
}
|
|
32
33
|
exports.generateIdForSeleniumEntity = generateIdForSeleniumEntity;
|
|
34
|
+
function substituteSeleniumVariable(argument) {
|
|
35
|
+
if (argument instanceof MablSymbol_1.MablSymbol) {
|
|
36
|
+
return '${' + argument.name + '}';
|
|
37
|
+
}
|
|
38
|
+
return argument.replace(/{{@?([^{}]+)}}/g, (_match, p1) => '${' + p1 + '}');
|
|
39
|
+
}
|
|
40
|
+
exports.substituteSeleniumVariable = substituteSeleniumVariable;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowConfig = void 0;
|
|
4
|
-
const importer_1 = require("
|
|
4
|
+
const importer_1 = require("../../mablscript/importer");
|
|
5
5
|
class FlowConfig {
|
|
6
6
|
constructor(flow, includeLocatorInfo) {
|
|
7
7
|
this.flow = flow;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelIdeConfig = void 0;
|
|
4
|
-
const SeleniumIdeStep_1 = require("
|
|
5
|
-
const importer_1 = require("
|
|
3
|
+
exports.seleniumIdeTheLoadedSteps = exports.SelIdeConfig = void 0;
|
|
4
|
+
const SeleniumIdeStep_1 = require("./SeleniumIdeStep");
|
|
5
|
+
const importer_1 = require("../../mablscript/importer");
|
|
6
|
+
const stepConverters_1 = require("./stepConverters");
|
|
6
7
|
class SelIdeConfig {
|
|
7
8
|
constructor(journey, flows) {
|
|
8
9
|
this.journey = journey;
|
|
@@ -19,7 +20,7 @@ class SelIdeConfig {
|
|
|
19
20
|
const loadedSteps = (0, importer_1.parseMablScriptIntoSteps)(flow);
|
|
20
21
|
steps = steps.concat(loadedSteps);
|
|
21
22
|
});
|
|
22
|
-
selIdeTest.commands =
|
|
23
|
+
selIdeTest.commands = seleniumIdeTheLoadedSteps(steps);
|
|
23
24
|
const storeDefaultUrl = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('store');
|
|
24
25
|
if (this.journey.url) {
|
|
25
26
|
storeDefaultUrl.target = this.journey.url;
|
|
@@ -45,3 +46,18 @@ class SelIdeConfig {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
exports.SelIdeConfig = SelIdeConfig;
|
|
49
|
+
function seleniumIdeTheLoadedSteps(translatedSteps) {
|
|
50
|
+
const selIdeSteps = translatedSteps.map((step, stepIndex) => {
|
|
51
|
+
const codeGenerator = stepConverters_1.stepGenerators.get(step.constructor.name);
|
|
52
|
+
if (codeGenerator) {
|
|
53
|
+
return codeGenerator(step, stepIndex);
|
|
54
|
+
}
|
|
55
|
+
const selIdeEcho = (0, SeleniumIdeStep_1.buildSeleniumIdeStep)('echo');
|
|
56
|
+
const unSupportedStepMessage = `[${step.getStepName()}] Step is not supported for Selenium IDE export`;
|
|
57
|
+
selIdeEcho.comment = unSupportedStepMessage;
|
|
58
|
+
selIdeEcho.target = unSupportedStepMessage;
|
|
59
|
+
return [selIdeEcho];
|
|
60
|
+
});
|
|
61
|
+
return [].concat.apply([], selIdeSteps);
|
|
62
|
+
}
|
|
63
|
+
exports.seleniumIdeTheLoadedSteps = seleniumIdeTheLoadedSteps;
|
|
@@ -0,0 +1,380 @@
|
|
|
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
|
+
}
|
|
@@ -4,7 +4,7 @@ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
|
4
4
|
const util_1 = require("../../commandUtil/util");
|
|
5
5
|
const js_yaml_1 = require("js-yaml");
|
|
6
6
|
const constants_1 = require("../../constants");
|
|
7
|
-
const flowConfigGenerator_1 = require("../../../
|
|
7
|
+
const flowConfigGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/flowConfigGenerator");
|
|
8
8
|
const fileUtil_1 = require("../../commandUtil/fileUtil");
|
|
9
9
|
const os = require('os');
|
|
10
10
|
const JSON_REPLACER = null;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const mablApi_1 = require("../../../mablApi");
|
|
4
4
|
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
5
|
-
const selIdeGenerator_1 = require("../../../
|
|
5
|
+
const selIdeGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/selIdeGenerator");
|
|
6
6
|
const util_1 = require("../../commandUtil/util");
|
|
7
|
-
const testConfigGenerator_1 = require("../../../
|
|
7
|
+
const testConfigGenerator_1 = require("../../../codeGenerators/seleniumConfigGenerators/testConfigGenerator");
|
|
8
8
|
const js_yaml_1 = require("js-yaml");
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
10
10
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|