@mablhq/mabl-cli 1.62.1 → 2.1.0
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 +10 -10
- package/api/mablApiClient.js +39 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +6 -6
- package/cli.js +1 -0
- package/commands/app-files/app-files.js +5 -0
- package/commands/app-files/app-files_cmds/create.js +98 -0
- package/commands/app-files/app-files_cmds/delete.js +31 -0
- package/commands/app-files/app-files_cmds/download.js +50 -0
- package/commands/app-files/app-files_cmds/list.js +72 -0
- package/commands/config/config_cmds/install.js +92 -0
- package/commands/constants.js +9 -2
- package/commands/tests/testsUtil.js +9 -1
- package/commands/tests/tests_cmds/run-mobile.js +218 -0
- package/commands/tests/tests_cmds/run.js +1 -1
- package/core/util.js +36 -2
- package/env/defaultEnv.js +2 -1
- package/env/dev.js +2 -1
- package/env/env.js +3 -1
- package/env/local.js +2 -1
- package/env/prod.js +2 -1
- package/execution/index.js +13 -1
- package/execution/runAppiumServer.js +133 -0
- package/http/MablHttpAgent.js +1 -4
- package/http/RequestFilteringHttpAgent.js +3 -3
- package/http/axiosProxyConfig.js +10 -7
- package/http/httpUtil.js +10 -6
- package/index.js +3 -2
- package/mablApi/index.js +1 -1
- package/mablscript/MablAction.js +6 -2
- package/mablscript/MablStep.js +41 -5
- package/mablscript/MablStepV2.js +57 -0
- package/mablscript/MablSymbol.js +6 -2
- package/mablscript/actions/AwaitDownloadAction.js +1 -1
- package/mablscript/actions/ConditionAction.js +1 -1
- package/mablscript/actions/CountAction.js +1 -1
- package/mablscript/actions/ExtractAction.js +12 -7
- package/mablscript/actions/FindAction.js +6 -6
- package/mablscript/actions/GenerateEmailAddressAction.js +1 -1
- package/mablscript/actions/GenerateRandomStringAction.js +1 -1
- package/mablscript/actions/GetUrlAction.js +1 -1
- package/mablscript/actions/GetVariableValue.js +1 -1
- package/mablscript/actions/JavaScriptAction.js +25 -14
- package/mablscript/importer.js +99 -16
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +53 -0
- package/mablscript/mobile/steps/EnterTextStep.js +41 -0
- package/mablscript/mobile/steps/NavigateBackStep.js +20 -0
- package/mablscript/mobile/steps/NavigateHomeStep.js +21 -0
- package/mablscript/mobile/steps/ScrollStep.js +37 -0
- package/mablscript/mobile/steps/SetOrientationStep.js +20 -0
- package/mablscript/mobile/steps/TapStep.js +37 -0
- package/mablscript/mobile/steps/actions/MobileFindAction.js +23 -0
- package/mablscript/mobile/steps/stepUtil.js +74 -0
- package/mablscript/mobile/tests/StepTestsUtil.js +20 -0
- package/mablscript/mobile/tests/TestMobileFindDescriptors.js +215 -0
- package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +298 -0
- package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +79 -0
- package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +167 -0
- package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +121 -0
- package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +32 -0
- package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +57 -0
- package/mablscript/steps/AccessibilityCheck.js +20 -9
- package/mablscript/steps/AssertStep.js +54 -39
- package/mablscript/steps/AssertStepOld.js +35 -4
- package/mablscript/steps/AwaitTabStep.js +5 -2
- package/mablscript/steps/AwaitUploadsStep.js +6 -4
- package/mablscript/steps/ClearCookiesStep.js +6 -4
- package/mablscript/steps/ClickAndHoldStep.js +10 -3
- package/mablscript/steps/ClickStep.js +10 -3
- package/mablscript/steps/CreateVariableStep.js +25 -8
- package/mablscript/steps/DoubleClickStep.js +10 -3
- package/mablscript/steps/DownloadStep.js +4 -2
- package/mablscript/steps/EchoStep.js +8 -5
- package/mablscript/steps/ElseIfConditionStep.js +14 -4
- package/mablscript/steps/ElseStep.js +8 -5
- package/mablscript/steps/EndStep.js +8 -5
- package/mablscript/steps/EnterAuthCodeStep.js +10 -3
- package/mablscript/steps/EnterTextStep.js +8 -2
- package/mablscript/steps/EvaluateFlowStep.js +5 -2
- package/mablscript/steps/EvaluateJavaScriptStep.js +15 -4
- package/mablscript/steps/HoverStep.js +10 -3
- package/mablscript/steps/IfConditionStep.js +25 -12
- package/mablscript/steps/NavigateStep.js +5 -2
- package/mablscript/steps/OpenEmailStep.js +5 -2
- package/mablscript/steps/ReleaseStep.js +10 -3
- package/mablscript/steps/RemoveCookieStep.js +5 -2
- package/mablscript/steps/RightClickStep.js +10 -3
- package/mablscript/steps/SelectStep.js +9 -3
- package/mablscript/steps/SendHttpRequestStep.js +8 -4
- package/mablscript/steps/SendKeyStep.js +10 -3
- package/mablscript/steps/SetCookieStep.js +5 -2
- package/mablscript/steps/SetFilesStep.js +9 -3
- package/mablscript/steps/SetViewportStep.js +5 -3
- package/mablscript/steps/SwitchContextStep.js +14 -3
- package/mablscript/steps/SyntheticStep.js +1 -1
- package/mablscript/steps/VisitUrlStep.js +5 -2
- package/mablscript/steps/WaitStep.js +8 -4
- package/mablscript/steps/WaitUntilStep.js +6 -3
- package/mablscript/types/GetVariableDescriptor.js +8 -3
- package/mablscript/types/mobile/CreateVariableMobileStepDescriptor.js +9 -0
- package/mablscript/types/mobile/EnterTextStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateBackStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateHomeStepDescriptor.js +2 -0
- package/mablscript/types/mobile/ScrollStepDescriptor.js +2 -0
- package/mablscript/types/mobile/SetOrientationStepDescriptor.js +8 -0
- package/mablscript/types/mobile/StepWithMobileFindDescriptor.js +2 -0
- package/mablscript/types/mobile/TapStepDescriptor.js +8 -0
- package/mablscriptFind/index.js +1 -1
- package/observers/ObserverBase.js +9 -0
- package/observers/mockObserver.js +3 -3
- package/package.json +11 -6
- package/resources/webdriver.js +21 -0
- package/upload/index.js +5 -0
- package/util/FileCache.js +180 -0
- package/util/Lazy.js +90 -0
- package/util/MobileAppFileCache.js +102 -0
- package/util/RichPromise.js +3 -1
- package/util/javaScriptStepMigration.js +1 -0
- package/webdriver/index.js +41 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ScrollStep_1 = require("../../steps/ScrollStep");
|
|
4
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
5
|
+
describe('Scroll steps parse correctly', () => {
|
|
6
|
+
it('Parses a Scroll step', () => {
|
|
7
|
+
const windowSize = { width: 1440, height: 2392 };
|
|
8
|
+
const scrollStepDescriptor = {
|
|
9
|
+
id: 'scrolliePolieOlie',
|
|
10
|
+
coordinates: {
|
|
11
|
+
from: {
|
|
12
|
+
xPercent: 1074 / windowSize.width,
|
|
13
|
+
yPercent: 2350 / windowSize.height,
|
|
14
|
+
},
|
|
15
|
+
to: {
|
|
16
|
+
xPercent: 1074 / windowSize.width,
|
|
17
|
+
yPercent: 100 / windowSize.height,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
actionCode: 'scroll',
|
|
21
|
+
};
|
|
22
|
+
const steps = [
|
|
23
|
+
{
|
|
24
|
+
Scroll: scrollStepDescriptor,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, ScrollStep_1.ScrollStep.stepName, scrollStepDescriptor);
|
|
28
|
+
const scrollStep = new ScrollStep_1.ScrollStep(scrollStepDescriptor);
|
|
29
|
+
expect(scrollStep.stepId()).toEqual(scrollStepDescriptor.id);
|
|
30
|
+
});
|
|
31
|
+
it('Humanizes a scroll step', () => {
|
|
32
|
+
const windowSize = { width: 1440, height: 2392 };
|
|
33
|
+
const stepYaml = {
|
|
34
|
+
Scroll: {
|
|
35
|
+
coordinates: {
|
|
36
|
+
from: {
|
|
37
|
+
xPercent: 1074 / windowSize.width,
|
|
38
|
+
yPercent: 2350 / windowSize.height,
|
|
39
|
+
},
|
|
40
|
+
to: {
|
|
41
|
+
xPercent: 1074 / windowSize.width,
|
|
42
|
+
yPercent: 100 / windowSize.height,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
actionCode: 'scroll',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
49
|
+
expect(step.stepDescription()).toEqual(`Scroll down 94.06% of the screen`);
|
|
50
|
+
});
|
|
51
|
+
it('Humanizes scroll directions as expected', () => {
|
|
52
|
+
const scrollUpStepYaml = {
|
|
53
|
+
Scroll: {
|
|
54
|
+
coordinates: {
|
|
55
|
+
from: {
|
|
56
|
+
xPercent: 0.109212,
|
|
57
|
+
yPercent: 0.241223,
|
|
58
|
+
},
|
|
59
|
+
to: {
|
|
60
|
+
xPercent: 0.145543,
|
|
61
|
+
yPercent: 0.865454,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
actionCode: 'scroll',
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
const scrollUpStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(scrollUpStepYaml);
|
|
68
|
+
expect(scrollUpStep.stepDescription()).toEqual(`Scroll up 62.42% of the screen`);
|
|
69
|
+
const scrollDownStepYaml = {
|
|
70
|
+
Scroll: {
|
|
71
|
+
coordinates: {
|
|
72
|
+
from: {
|
|
73
|
+
xPercent: 0.48351,
|
|
74
|
+
yPercent: 0.89123,
|
|
75
|
+
},
|
|
76
|
+
to: {
|
|
77
|
+
xPercent: 0.4515,
|
|
78
|
+
yPercent: 0.0874,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
actionCode: 'scroll',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const scrollDownStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(scrollDownStepYaml);
|
|
85
|
+
expect(scrollDownStep.stepDescription()).toEqual(`Scroll down 80.38% of the screen`);
|
|
86
|
+
const swipeRightStepYaml = {
|
|
87
|
+
Scroll: {
|
|
88
|
+
coordinates: {
|
|
89
|
+
from: {
|
|
90
|
+
xPercent: 0.08111,
|
|
91
|
+
yPercent: 0.46123,
|
|
92
|
+
},
|
|
93
|
+
to: {
|
|
94
|
+
xPercent: 0.90295,
|
|
95
|
+
yPercent: 0.4574,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
actionCode: 'scroll',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
const swipeRightStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(swipeRightStepYaml);
|
|
102
|
+
expect(swipeRightStep.stepDescription()).toEqual(`Swipe right 82.18% of the screen`);
|
|
103
|
+
const swipeLeftStepYaml = {
|
|
104
|
+
Scroll: {
|
|
105
|
+
coordinates: {
|
|
106
|
+
from: {
|
|
107
|
+
xPercent: 0.88111,
|
|
108
|
+
yPercent: 0.46123,
|
|
109
|
+
},
|
|
110
|
+
to: {
|
|
111
|
+
xPercent: 0.09295,
|
|
112
|
+
yPercent: 0.4574,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
actionCode: 'scroll',
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
const swipeLeftStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(swipeLeftStepYaml);
|
|
119
|
+
expect(swipeLeftStep.stepDescription()).toEqual(`Swipe left 78.82% of the screen`);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SetOrientationStep_1 = require("../../steps/SetOrientationStep");
|
|
4
|
+
const SetOrientationStepDescriptor_1 = require("../../../types/mobile/SetOrientationStepDescriptor");
|
|
5
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
6
|
+
describe('SetOrientation steps parse correctly', () => {
|
|
7
|
+
it('Parses a SetOrientation step', () => {
|
|
8
|
+
const setOrientationStepDescriptor = {
|
|
9
|
+
id: 'theOrientalExpress',
|
|
10
|
+
orientation: SetOrientationStepDescriptor_1.Orientation.Landscape,
|
|
11
|
+
actionCode: 'set_orientation',
|
|
12
|
+
};
|
|
13
|
+
const steps = [
|
|
14
|
+
{
|
|
15
|
+
SetOrientation: setOrientationStepDescriptor,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, SetOrientationStep_1.SetOrientationStep.stepName, setOrientationStepDescriptor);
|
|
19
|
+
const orientationStep = new SetOrientationStep_1.SetOrientationStep(setOrientationStepDescriptor);
|
|
20
|
+
expect(orientationStep.stepId()).toEqual(setOrientationStepDescriptor.id);
|
|
21
|
+
});
|
|
22
|
+
it('Humanizes a SetOrientation step', () => {
|
|
23
|
+
const stepYaml = {
|
|
24
|
+
SetOrientation: {
|
|
25
|
+
orientation: SetOrientationStepDescriptor_1.Orientation.Landscape,
|
|
26
|
+
actionCode: 'set_orientation',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
30
|
+
expect(step.stepDescription()).toEqual(`Set orientation of device to landscape`);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const TapStep_1 = require("../../steps/TapStep");
|
|
4
|
+
const domUtil_1 = require("../../../../domUtil");
|
|
5
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
6
|
+
const TapStepDescriptor_1 = require("../../../types/mobile/TapStepDescriptor");
|
|
7
|
+
const TestMobileFindDescriptors_1 = require("../TestMobileFindDescriptors");
|
|
8
|
+
describe('Tap steps parse correctly', () => {
|
|
9
|
+
it('Parses a Tap step with a Find One selector', () => {
|
|
10
|
+
const find = {
|
|
11
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
12
|
+
findTarget: {
|
|
13
|
+
selector: {
|
|
14
|
+
iOS: {
|
|
15
|
+
name: '{{@varInFind}}',
|
|
16
|
+
},
|
|
17
|
+
uuid: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const stepDescriptor = {
|
|
22
|
+
id: 'TappyMcTapperson',
|
|
23
|
+
find,
|
|
24
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
25
|
+
actionCode: 'tap',
|
|
26
|
+
};
|
|
27
|
+
const steps = [
|
|
28
|
+
{
|
|
29
|
+
Tap: stepDescriptor,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, TapStep_1.TapStep.stepName, stepDescriptor);
|
|
33
|
+
const tapStep = new TapStep_1.TapStep(stepDescriptor);
|
|
34
|
+
expect(tapStep.stepId()).toEqual(stepDescriptor.id);
|
|
35
|
+
expect(tapStep.getInputVariables()).toStrictEqual(['varInFind']);
|
|
36
|
+
});
|
|
37
|
+
it('Parses a WebView Tap step', () => {
|
|
38
|
+
const stepDescriptor = {
|
|
39
|
+
find: TestMobileFindDescriptors_1.iOSWebViewTextFieldMobileFindDescriptor,
|
|
40
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
41
|
+
actionCode: 'tap',
|
|
42
|
+
};
|
|
43
|
+
const steps = [
|
|
44
|
+
{
|
|
45
|
+
Tap: stepDescriptor,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, TapStep_1.TapStep.stepName, stepDescriptor);
|
|
49
|
+
});
|
|
50
|
+
it('Renders description for step without find', () => {
|
|
51
|
+
const stepDescriptor = {
|
|
52
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
53
|
+
};
|
|
54
|
+
const tapStep = new TapStep_1.TapStep(stepDescriptor);
|
|
55
|
+
expect(tapStep.stepDescription()).toEqual('Tap on unknown element');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -14,7 +14,7 @@ var AccessibilityCheckSeverity;
|
|
|
14
14
|
})(AccessibilityCheckSeverity = exports.AccessibilityCheckSeverity || (exports.AccessibilityCheckSeverity = {}));
|
|
15
15
|
class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
16
16
|
constructor(name, args, actions) {
|
|
17
|
-
super(name, args, actions);
|
|
17
|
+
super(name, args, actions, 'accessibility_check');
|
|
18
18
|
if (this.actions.length) {
|
|
19
19
|
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
20
20
|
}
|
|
@@ -40,6 +40,7 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
|
40
40
|
...this.checkConfig,
|
|
41
41
|
find,
|
|
42
42
|
descriptorToActionMap: new Map().set(find, this),
|
|
43
|
+
actionCode: this.actionCode,
|
|
43
44
|
};
|
|
44
45
|
default:
|
|
45
46
|
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
@@ -50,11 +51,13 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
|
50
51
|
rules: (_b = this.checkConfig) === null || _b === void 0 ? void 0 : _b.rules,
|
|
51
52
|
disabledRules: (_c = this.checkConfig) === null || _c === void 0 ? void 0 : _c.disabledRules,
|
|
52
53
|
failOn: (_d = this.checkConfig) === null || _d === void 0 ? void 0 : _d.failOn,
|
|
54
|
+
actionCode: this.actionCode,
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
getFormattedStep(_fullLocatorsOn) {
|
|
58
|
+
let finalStep;
|
|
56
59
|
if (this.findAction) {
|
|
57
|
-
|
|
60
|
+
finalStep = {
|
|
58
61
|
AccessibilityCheck: {
|
|
59
62
|
...super.annotationsAsYml(),
|
|
60
63
|
...this.findAction.toYaml(),
|
|
@@ -62,12 +65,18 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
|
62
65
|
},
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
else {
|
|
69
|
+
finalStep = {
|
|
70
|
+
AccessibilityCheck: {
|
|
71
|
+
...super.annotationsAsYml(),
|
|
72
|
+
...this.checkConfig,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (this.stepId()) {
|
|
77
|
+
finalStep.AccessibilityCheck.id = this.stepId();
|
|
78
|
+
}
|
|
79
|
+
return finalStep;
|
|
71
80
|
}
|
|
72
81
|
static fromYaml(_stepName, stepArgs) {
|
|
73
82
|
const actions = [];
|
|
@@ -80,7 +89,9 @@ class AccessibilityCheckStep extends MablStep_1.MablStep {
|
|
|
80
89
|
disabledRules: stepArgs.disabledRules,
|
|
81
90
|
failOn: stepArgs.failOn,
|
|
82
91
|
};
|
|
83
|
-
|
|
92
|
+
const step = new AccessibilityCheckStep(AccessibilityCheckStep.mablScriptStepNames[0], [checkConfig], actions);
|
|
93
|
+
step.setStepId(stepArgs.id);
|
|
94
|
+
return step;
|
|
84
95
|
}
|
|
85
96
|
toMablscript() {
|
|
86
97
|
var _a, _b, _c;
|
|
@@ -12,6 +12,7 @@ const GetCurrentLocationDescriptor_1 = require("../types/GetCurrentLocationDescr
|
|
|
12
12
|
const GetVariableValue_1 = require("../actions/GetVariableValue");
|
|
13
13
|
const GetVariableDescriptor_1 = require("../types/GetVariableDescriptor");
|
|
14
14
|
const CountAction_1 = require("../actions/CountAction");
|
|
15
|
+
const MobileFindAction_1 = require("../mobile/steps/actions/MobileFindAction");
|
|
15
16
|
var OnFailure;
|
|
16
17
|
(function (OnFailure) {
|
|
17
18
|
OnFailure["ContinueWithWarning"] = "continue";
|
|
@@ -44,15 +45,16 @@ Object.entries(exports.assertionStepToField).forEach(([stepType, field]) => (exp
|
|
|
44
45
|
class AssertStep extends MablStep_1.MablStep {
|
|
45
46
|
constructor(name, args, actions) {
|
|
46
47
|
var _a, _b;
|
|
47
|
-
super(name, args, actions);
|
|
48
|
+
super(name, args, actions, 'assert');
|
|
48
49
|
const firstAction = actions[0];
|
|
49
50
|
if (firstAction instanceof FindAction_1.FindAction ||
|
|
51
|
+
firstAction instanceof MobileFindAction_1.MobileFindAction ||
|
|
50
52
|
firstAction instanceof GetUrlAction_1.GetUrlAction ||
|
|
51
53
|
firstAction instanceof GetVariableValue_1.GetVariableValue) {
|
|
52
54
|
this.primaryAction = firstAction;
|
|
53
55
|
}
|
|
54
56
|
else {
|
|
55
|
-
throw new Error(`Unexpected action type. Expected FindAction|GetUrlAction|GetVariableValue but got: ${firstAction.constructor.name}`);
|
|
57
|
+
throw new Error(`Unexpected action type. Expected FindAction|MobileFindAction|GetUrlAction|GetVariableValue but got: ${firstAction.constructor.name}`);
|
|
56
58
|
}
|
|
57
59
|
if (actions.length === 3) {
|
|
58
60
|
if (actions[1] instanceof CountAction_1.CountAction) {
|
|
@@ -127,9 +129,11 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
127
129
|
onFailure: this.onFailure,
|
|
128
130
|
observationScope: this.observationScope,
|
|
129
131
|
descriptorToActionMap,
|
|
132
|
+
actionCode: this.actionCode,
|
|
130
133
|
};
|
|
131
134
|
}
|
|
132
135
|
getFormattedStep(_fullLocatorsOn) {
|
|
136
|
+
var _a, _b;
|
|
133
137
|
const result = {};
|
|
134
138
|
result[this.getStepName()] = { ...this.annotationsAsYml() };
|
|
135
139
|
const formatted = result[this.getStepName()];
|
|
@@ -144,49 +148,60 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
144
148
|
if (this.assertionValue !== undefined) {
|
|
145
149
|
formatted.assertionValue = this.assertionValue;
|
|
146
150
|
}
|
|
147
|
-
const
|
|
148
|
-
if ((0,
|
|
151
|
+
const targetDescriptor = this.primaryAction.toDescriptor();
|
|
152
|
+
if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
|
|
153
|
+
formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
|
|
149
154
|
}
|
|
150
155
|
else {
|
|
151
|
-
|
|
152
|
-
case domUtil_1.FindType.FIND_EMAIL:
|
|
153
|
-
formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
|
|
154
|
-
formatted.selector = find.findTarget.selector;
|
|
155
|
-
break;
|
|
156
|
-
case domUtil_1.FindType.FIND_COOKIE:
|
|
157
|
-
case domUtil_1.FindType.FIND_FIRST:
|
|
158
|
-
case domUtil_1.FindType.FIND_LAST:
|
|
159
|
-
case domUtil_1.FindType.FIND_ANY:
|
|
160
|
-
case domUtil_1.FindType.FIND_ALL:
|
|
161
|
-
formatted.findType = FindAction_1.findTypesToFormattedType[find.findType];
|
|
162
|
-
formatted.selector = find.findTarget;
|
|
163
|
-
break;
|
|
164
|
-
case domUtil_1.FindType.FIND_ONE:
|
|
165
|
-
formatted.selector = find.findTarget.selector;
|
|
166
|
-
if (find.findOptions) {
|
|
167
|
-
formatted.findOptions = find.findOptions;
|
|
168
|
-
}
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
172
|
-
}
|
|
156
|
+
formatted.target = targetDescriptor;
|
|
173
157
|
}
|
|
174
158
|
if (this.conditionAction.options) {
|
|
175
159
|
formatted.conditionOptions = this.conditionAction.options;
|
|
176
160
|
}
|
|
161
|
+
if (!!((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.observationScope) ||
|
|
162
|
+
!!((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.onFailure)) {
|
|
163
|
+
formatted.assertArguments = this.assertArguments;
|
|
164
|
+
}
|
|
165
|
+
result[this.getStepName()] =
|
|
166
|
+
MablStep_1.MablStep.cloneAndRemoveUndefinedEntriesFromObject(formatted);
|
|
167
|
+
if (this.stepId()) {
|
|
168
|
+
result[this.getStepName()].id = this.stepId();
|
|
169
|
+
}
|
|
177
170
|
return result;
|
|
178
171
|
}
|
|
179
172
|
static fromYaml(stepName, stepArgs) {
|
|
173
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
180
174
|
const actions = [];
|
|
181
175
|
const assertionType = exports.assertionStepToField[stepName];
|
|
182
176
|
const assertionValue = stepArgs.assertionValue;
|
|
183
177
|
const conditionOptions = stepArgs.conditionOptions;
|
|
184
178
|
let primaryAction;
|
|
185
|
-
if (stepArgs.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
179
|
+
if (((_a = stepArgs.target) === null || _a === void 0 ? void 0 : _a.kind) === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
186
180
|
primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
|
|
187
181
|
}
|
|
182
|
+
else if (((_b = stepArgs.target) === null || _b === void 0 ? void 0 : _b.kind) === GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
183
|
+
primaryAction = new GetVariableValue_1.GetVariableValue(GetVariableValue_1.GetVariableValue.mablScriptStepNames[0], [(_c = stepArgs.target) === null || _c === void 0 ? void 0 : _c.variable]);
|
|
184
|
+
}
|
|
185
|
+
else if ((0, domUtil_1.isNormalizedFindEmailDescriptor)((_d = stepArgs.target) === null || _d === void 0 ? void 0 : _d.findTarget) ||
|
|
186
|
+
(0, domUtil_1.isCookieSelector)((_e = stepArgs.target) === null || _e === void 0 ? void 0 : _e.findTarget) ||
|
|
187
|
+
(0, domUtil_1.isTabSelector)((_f = stepArgs.target) === null || _f === void 0 ? void 0 : _f.findTarget)) {
|
|
188
|
+
const { findTarget, findType } = stepArgs.target;
|
|
189
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget]);
|
|
190
|
+
}
|
|
191
|
+
else if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.target)) {
|
|
192
|
+
primaryAction = MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.target);
|
|
193
|
+
}
|
|
194
|
+
else if ((0, domUtil_1.isFindElementDescriptor)(stepArgs.target)) {
|
|
195
|
+
const { findOptions, findTarget, findType } = stepArgs.target;
|
|
196
|
+
if (findType === domUtil_1.FindType.FIND_ONE) {
|
|
197
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
188
203
|
else {
|
|
189
|
-
|
|
204
|
+
throw new Error(`Error parsing [${stepName}] with incompatible step arguments`);
|
|
190
205
|
}
|
|
191
206
|
actions.push(primaryAction);
|
|
192
207
|
if (assertionType === 'present' || assertionType === 'not_present') {
|
|
@@ -199,11 +214,8 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
199
214
|
if (stepArgs.attribute === 'count') {
|
|
200
215
|
actions.push(new CountAction_1.CountAction('count', [stepArgs.attribute]));
|
|
201
216
|
}
|
|
202
|
-
else {
|
|
203
|
-
|
|
204
|
-
? [stepArgs.attribute, stepArgs.extractionOptions]
|
|
205
|
-
: [stepArgs.attribute];
|
|
206
|
-
actions.push(new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(stepArgs.extractType), extractArgs));
|
|
217
|
+
else if (((_g = stepArgs.target) === null || _g === void 0 ? void 0 : _g.kind) !== GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
218
|
+
actions.push(new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(stepArgs.extractType), [stepArgs.attribute]));
|
|
207
219
|
}
|
|
208
220
|
actions.push(new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
209
221
|
assertionType,
|
|
@@ -211,15 +223,18 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
211
223
|
conditionOptions,
|
|
212
224
|
]));
|
|
213
225
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
226
|
+
const assertStep = new AssertStep('assert', [stepArgs.assertArguments], actions);
|
|
227
|
+
if (stepArgs.annotation) {
|
|
228
|
+
assertStep.setAnnotation(stepArgs.annotation);
|
|
229
|
+
}
|
|
230
|
+
assertStep.setStepId(stepArgs.id);
|
|
231
|
+
return assertStep;
|
|
220
232
|
}
|
|
221
233
|
toMablscript() {
|
|
222
234
|
var _a, _b, _c, _d;
|
|
235
|
+
if (this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
236
|
+
throw new Error('Mobile steps do not generate mablscript');
|
|
237
|
+
}
|
|
223
238
|
const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
|
|
224
239
|
((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
|
|
225
240
|
? (0, MablAction_1.convertObjectToMablscriptArgs)({
|
|
@@ -27,7 +27,7 @@ const oldToNewAssertionTypes = {
|
|
|
27
27
|
};
|
|
28
28
|
class AssertStepOld extends MablStep_1.MablStep {
|
|
29
29
|
constructor(name, args, actions) {
|
|
30
|
-
super(name, args, actions);
|
|
30
|
+
super(name, args, actions, name);
|
|
31
31
|
this.assertionType = '';
|
|
32
32
|
this.assertAttribute = '';
|
|
33
33
|
this.validate();
|
|
@@ -97,10 +97,41 @@ class AssertStepOld extends MablStep_1.MablStep {
|
|
|
97
97
|
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
formatted.
|
|
101
|
-
|
|
100
|
+
formatted.assertArguments = {
|
|
101
|
+
onFailure: this.onFailure,
|
|
102
|
+
observationScope: this.observationScope,
|
|
103
|
+
};
|
|
102
104
|
return formatted;
|
|
103
105
|
}
|
|
106
|
+
getFormattedStep(_fullLocatorsOn) {
|
|
107
|
+
const result = {};
|
|
108
|
+
result[this.getStepName()] = { ...this.annotationsAsYml() };
|
|
109
|
+
const formatted = result[this.getStepName()];
|
|
110
|
+
if (this.extractAction) {
|
|
111
|
+
formatted.attribute = this.extractAction.extractionAttribute;
|
|
112
|
+
formatted.extractType =
|
|
113
|
+
ExtractAction_1.ExtractAction.mablscriptToYamlType[this.extractAction.extractionType];
|
|
114
|
+
}
|
|
115
|
+
if (this.assertionType !== 'assert_present' &&
|
|
116
|
+
this.assertionType !== 'assert_not_present') {
|
|
117
|
+
formatted.assertionValue = this.assertAttribute;
|
|
118
|
+
}
|
|
119
|
+
const targetDescriptor = this.primaryAction.toDescriptor();
|
|
120
|
+
if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
|
|
121
|
+
formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
formatted.target = targetDescriptor;
|
|
125
|
+
}
|
|
126
|
+
formatted.assertArguments = {
|
|
127
|
+
onFailure: this.onFailure,
|
|
128
|
+
observationScope: this.observationScope,
|
|
129
|
+
};
|
|
130
|
+
if (this.stepId()) {
|
|
131
|
+
result[this.getStepName()].id = this.stepId();
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
104
135
|
getNewAssertionStep() {
|
|
105
136
|
const yamlified = (0, importer_1.yamlifyTheLoadedSteps)([this]);
|
|
106
137
|
const reloadedSteps = (0, importer_1.loadYamlSteps)(yamlified);
|
|
@@ -117,7 +148,7 @@ class AssertStepOld extends MablStep_1.MablStep {
|
|
|
117
148
|
return result;
|
|
118
149
|
}
|
|
119
150
|
static fromYaml(stepName, _stepArgs) {
|
|
120
|
-
return new MablStep_1.MablStep(stepName, [], []);
|
|
151
|
+
return new MablStep_1.MablStep(stepName, [], [], 'assert');
|
|
121
152
|
}
|
|
122
153
|
}
|
|
123
154
|
exports.AssertStepOld = AssertStepOld;
|
|
@@ -5,7 +5,7 @@ const domUtil_1 = require("../../domUtil");
|
|
|
5
5
|
const MablStep_1 = require("../MablStep");
|
|
6
6
|
class AwaitTabStep extends MablStep_1.MablStep {
|
|
7
7
|
constructor(name, args, actions) {
|
|
8
|
-
super(name, args, actions);
|
|
8
|
+
super(name, args, actions, 'await_tab');
|
|
9
9
|
this.tab = this.getActionArgs()[0];
|
|
10
10
|
}
|
|
11
11
|
getStepName() {
|
|
@@ -14,10 +14,13 @@ class AwaitTabStep extends MablStep_1.MablStep {
|
|
|
14
14
|
toStepDescriptor() {
|
|
15
15
|
return {
|
|
16
16
|
tab: this.tab,
|
|
17
|
+
actionCode: this.actionCode,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
static fromYaml(_stepName, stepArgs) {
|
|
20
|
-
|
|
21
|
+
const step = new AwaitTabStep('await_tab', [stepArgs.tab], []);
|
|
22
|
+
step.setStepId(stepArgs.id);
|
|
23
|
+
return step;
|
|
21
24
|
}
|
|
22
25
|
toMablscript() {
|
|
23
26
|
const mablscriptSelectorChunks = ['selector_type: "tab"'];
|
|
@@ -4,16 +4,18 @@ exports.AwaitUploadsStep = void 0;
|
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
5
|
class AwaitUploadsStep extends MablStep_1.MablStep {
|
|
6
6
|
constructor(name, args, actions) {
|
|
7
|
-
super(name, args, actions);
|
|
7
|
+
super(name, args, actions, 'await_uploads');
|
|
8
8
|
}
|
|
9
9
|
getStepName() {
|
|
10
10
|
return 'AwaitUploads';
|
|
11
11
|
}
|
|
12
12
|
toStepDescriptor() {
|
|
13
|
-
return {};
|
|
13
|
+
return { actionCode: this.actionCode };
|
|
14
14
|
}
|
|
15
|
-
static fromYaml(_stepName,
|
|
16
|
-
|
|
15
|
+
static fromYaml(_stepName, stepArgs) {
|
|
16
|
+
const step = new AwaitUploadsStep('await_uploads', [], []);
|
|
17
|
+
step.setStepId(stepArgs.id);
|
|
18
|
+
return step;
|
|
17
19
|
}
|
|
18
20
|
toMablscript() {
|
|
19
21
|
return `await_uploads()`;
|
|
@@ -4,16 +4,18 @@ exports.ClearCookiesStep = void 0;
|
|
|
4
4
|
const MablStep_1 = require("../MablStep");
|
|
5
5
|
class ClearCookiesStep extends MablStep_1.MablStep {
|
|
6
6
|
constructor(name, args, actions) {
|
|
7
|
-
super(name, args, actions);
|
|
7
|
+
super(name, args, actions, 'clear_cookies');
|
|
8
8
|
}
|
|
9
9
|
getStepName() {
|
|
10
10
|
return 'ClearCookies';
|
|
11
11
|
}
|
|
12
12
|
toStepDescriptor() {
|
|
13
|
-
return {};
|
|
13
|
+
return { actionCode: this.actionCode };
|
|
14
14
|
}
|
|
15
|
-
static fromYaml(_stepName,
|
|
16
|
-
|
|
15
|
+
static fromYaml(_stepName, stepArgs) {
|
|
16
|
+
const step = new ClearCookiesStep('clear_cookies', [], []);
|
|
17
|
+
step.setStepId(stepArgs.id);
|
|
18
|
+
return step;
|
|
17
19
|
}
|
|
18
20
|
toMablscript() {
|
|
19
21
|
return `clear_cookies()`;
|
|
@@ -8,7 +8,7 @@ const ActionsUtils_1 = require("./ActionsUtils");
|
|
|
8
8
|
class ClickAndHoldStep extends MablStep_1.MablStep {
|
|
9
9
|
constructor(name, args, actions) {
|
|
10
10
|
var _a;
|
|
11
|
-
super(name, args, actions);
|
|
11
|
+
super(name, args, actions, 'click_and_hold');
|
|
12
12
|
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
13
13
|
this.clickArgs = (_a = this.parseArgs(args)) !== null && _a !== void 0 ? _a : { isHtml5: false };
|
|
14
14
|
}
|
|
@@ -38,21 +38,28 @@ class ClickAndHoldStep extends MablStep_1.MablStep {
|
|
|
38
38
|
find,
|
|
39
39
|
isHtml5: this.clickArgs.isHtml5,
|
|
40
40
|
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
41
|
+
actionCode: this.actionCode,
|
|
41
42
|
};
|
|
42
43
|
default:
|
|
43
44
|
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
getFormattedStep(_fullLocatorsOn) {
|
|
47
|
-
|
|
48
|
+
const step = {
|
|
48
49
|
ClickAndHold: {
|
|
49
50
|
...super.annotationsAsYml(),
|
|
50
51
|
...this.findAction.toYaml(),
|
|
51
52
|
},
|
|
52
53
|
};
|
|
54
|
+
if (this.stepId()) {
|
|
55
|
+
step.ClickAndHold.id = this.stepId();
|
|
56
|
+
}
|
|
57
|
+
return step;
|
|
53
58
|
}
|
|
54
59
|
static fromYaml(_stepName, stepArgs) {
|
|
55
|
-
|
|
60
|
+
const step = new ClickAndHoldStep('click_and_hold', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
61
|
+
step.setStepId(stepArgs.id);
|
|
62
|
+
return step;
|
|
56
63
|
}
|
|
57
64
|
toMablscript() {
|
|
58
65
|
return `${this.findAction.toMablscript()}.click_and_hold({isHtml5:${this.clickArgs.isHtml5}})`;
|
|
@@ -7,7 +7,7 @@ const domUtil_1 = require("../../domUtil");
|
|
|
7
7
|
const ActionsUtils_1 = require("./ActionsUtils");
|
|
8
8
|
class ClickStep extends MablStep_1.MablStep {
|
|
9
9
|
constructor(name, args, actions) {
|
|
10
|
-
super(name, args, actions);
|
|
10
|
+
super(name, args, actions, 'click');
|
|
11
11
|
this.findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(this.actions);
|
|
12
12
|
}
|
|
13
13
|
getStepName() {
|
|
@@ -23,21 +23,28 @@ class ClickStep extends MablStep_1.MablStep {
|
|
|
23
23
|
return {
|
|
24
24
|
find,
|
|
25
25
|
descriptorToActionMap: new Map().set(find, this.findAction),
|
|
26
|
+
actionCode: this.actionCode,
|
|
26
27
|
};
|
|
27
28
|
default:
|
|
28
29
|
throw new Error(`Error generating step descriptor for ${this.getStepName()}: Unexpected find type ${find.findType}`);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
getFormattedStep(_fullLocatorsOn) {
|
|
32
|
-
|
|
33
|
+
const step = {
|
|
33
34
|
Click: {
|
|
34
35
|
...super.annotationsAsYml(),
|
|
35
36
|
...this.findAction.toYaml(),
|
|
36
37
|
},
|
|
37
38
|
};
|
|
39
|
+
if (this.stepId()) {
|
|
40
|
+
step.Click.id = this.stepId();
|
|
41
|
+
}
|
|
42
|
+
return step;
|
|
38
43
|
}
|
|
39
44
|
static fromYaml(_stepName, stepArgs) {
|
|
40
|
-
|
|
45
|
+
const step = new ClickStep('click', [], [FindAction_1.FindAction.findActionFromStepArgs(stepArgs)]);
|
|
46
|
+
step.setStepId(stepArgs.id);
|
|
47
|
+
return step;
|
|
41
48
|
}
|
|
42
49
|
toMablscript() {
|
|
43
50
|
return `${this.findAction.toMablscript()}.click()`;
|