@mablhq/mabl-cli 1.61.8 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Globals.js +11 -7
- package/api/basicApiClient.js +10 -10
- package/api/mablApiClient.js +39 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +6 -6
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +8 -0
- 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 +10 -3
- package/commands/tests/testsUtil.js +45 -15
- package/commands/tests/tests_cmds/run-mobile.js +218 -0
- package/commands/tests/tests_cmds/run.js +11 -9
- 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 +4 -1
- package/http/RequestFilteringHttpAgent.js +3 -3
- package/http/axiosProxyConfig.js +27 -22
- package/http/httpUtil.js +6 -10
- package/mablApi/index.js +1 -1
- package/mablscript/MablAction.js +1 -1
- package/mablscript/MablStep.js +28 -2
- package/mablscript/MablStepV2.js +51 -0
- package/mablscript/MablSymbol.js +6 -2
- package/mablscript/actions/ExtractAction.js +11 -6
- package/mablscript/actions/FindAction.js +5 -5
- package/mablscript/actions/JavaScriptAction.js +19 -12
- package/mablscript/importer.js +97 -14
- 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 +71 -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 +287 -0
- package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +74 -0
- package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +167 -0
- package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +22 -0
- package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +22 -0
- package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +112 -0
- package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +53 -0
- package/mablscript/steps/AssertStep.js +48 -38
- package/mablscript/steps/AssertStepOld.js +30 -2
- package/mablscript/steps/CreateVariableStep.js +9 -2
- package/mablscript/steps/EchoStep.js +4 -3
- package/mablscript/steps/ElseIfConditionStep.js +8 -2
- package/mablscript/steps/ElseStep.js +2 -1
- package/mablscript/steps/EndStep.js +2 -1
- package/mablscript/steps/EvaluateJavaScriptStep.js +6 -1
- package/mablscript/steps/IfConditionStep.js +17 -10
- package/mablscript/steps/SendHttpRequestStep.js +4 -3
- package/mablscript/steps/WaitStep.js +4 -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/package.json +13 -6
- package/resources/pdf-viewer/embeddedPdfDetection.js +1 -14
- 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/webdriver/index.js +41 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const EnterTextStep_1 = require("../../steps/EnterTextStep");
|
|
4
|
+
const domUtil_1 = require("../../../../domUtil");
|
|
5
|
+
const MablSymbol_1 = require("../../../MablSymbol");
|
|
6
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
7
|
+
const TestMobileFindDescriptors_1 = require("../TestMobileFindDescriptors");
|
|
8
|
+
describe('EnterText steps parse correctly', () => {
|
|
9
|
+
it('Parses an EnterText step with a Find One selector', () => {
|
|
10
|
+
const find = {
|
|
11
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
12
|
+
findTarget: {
|
|
13
|
+
selector: {
|
|
14
|
+
iOS: {
|
|
15
|
+
name: 'Name field',
|
|
16
|
+
},
|
|
17
|
+
uuid: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const enterTextStepDescriptor = {
|
|
22
|
+
find,
|
|
23
|
+
text: 'Mauro',
|
|
24
|
+
};
|
|
25
|
+
const steps = [
|
|
26
|
+
{
|
|
27
|
+
EnterText: enterTextStepDescriptor,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, EnterTextStep_1.EnterTextStep.stepName, enterTextStepDescriptor);
|
|
31
|
+
const enterTextStep = new EnterTextStep_1.EnterTextStep(enterTextStepDescriptor);
|
|
32
|
+
expect(enterTextStep.getInputVariables()).toHaveLength(0);
|
|
33
|
+
});
|
|
34
|
+
it('Parses an EnterText step with a Find One selector and a variable', () => {
|
|
35
|
+
const find = {
|
|
36
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
37
|
+
findTarget: {
|
|
38
|
+
selector: {
|
|
39
|
+
iOS: {
|
|
40
|
+
name: '{{@varInFind}}',
|
|
41
|
+
},
|
|
42
|
+
uuid: '',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const enterTextStepDescriptor = {
|
|
47
|
+
find,
|
|
48
|
+
text: new MablSymbol_1.MablSymbol('user.input'),
|
|
49
|
+
};
|
|
50
|
+
const steps = [
|
|
51
|
+
{
|
|
52
|
+
EnterText: enterTextStepDescriptor,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, EnterTextStep_1.EnterTextStep.stepName, enterTextStepDescriptor);
|
|
56
|
+
const enterTextStep = new EnterTextStep_1.EnterTextStep(enterTextStepDescriptor);
|
|
57
|
+
expect(enterTextStep.getInputVariables()).toStrictEqual([
|
|
58
|
+
'varInFind',
|
|
59
|
+
'user.input',
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
it('Parses a WebView EnterText step with a Find One selector and a variable', () => {
|
|
63
|
+
const enterTextStepDescriptor = {
|
|
64
|
+
find: TestMobileFindDescriptors_1.iOSWebViewTextFieldMobileFindDescriptor,
|
|
65
|
+
text: new MablSymbol_1.MablSymbol('user.input'),
|
|
66
|
+
};
|
|
67
|
+
const steps = [
|
|
68
|
+
{
|
|
69
|
+
EnterText: enterTextStepDescriptor,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, EnterTextStep_1.EnterTextStep.stepName, enterTextStepDescriptor);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const domUtil_1 = require("../../../../domUtil");
|
|
4
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
5
|
+
describe('Humanization of steps work', () => {
|
|
6
|
+
it('Humanizes an iOS Tap step properly for accessibility ID', () => {
|
|
7
|
+
const stepYaml = {
|
|
8
|
+
Tap: {
|
|
9
|
+
find: {
|
|
10
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
11
|
+
findTarget: {
|
|
12
|
+
selector: {
|
|
13
|
+
iOS: {
|
|
14
|
+
name: 'Name field',
|
|
15
|
+
type: 'XCUIElementTypeButton',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
type: 'tap',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
24
|
+
expect(step.stepDescription()).toEqual(`Tap on "Name field" element`);
|
|
25
|
+
});
|
|
26
|
+
it('Humanizes an iOS Tap step properly for label', () => {
|
|
27
|
+
const stepYaml = {
|
|
28
|
+
Tap: {
|
|
29
|
+
find: {
|
|
30
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
31
|
+
findTarget: {
|
|
32
|
+
selector: {
|
|
33
|
+
iOS: {
|
|
34
|
+
type: 'XCUIElementTypeButton',
|
|
35
|
+
label: 'Click here for more',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
type: 'tap',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
44
|
+
expect(step.stepDescription()).toEqual(`Tap on element with text "Click here for more"`);
|
|
45
|
+
});
|
|
46
|
+
it('Humanizes an iOS Tap step properly when only type is available', () => {
|
|
47
|
+
const stepYaml = {
|
|
48
|
+
Tap: {
|
|
49
|
+
find: {
|
|
50
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
51
|
+
findTarget: {
|
|
52
|
+
selector: {
|
|
53
|
+
android: {},
|
|
54
|
+
iOS: {
|
|
55
|
+
type: 'XCUIElementTypeButton',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
type: 'tap',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
64
|
+
expect(step.stepDescription()).toEqual(`Tap on the "Button" element`);
|
|
65
|
+
});
|
|
66
|
+
it('Humanizes an android Tap step properly when text is available', () => {
|
|
67
|
+
const stepYaml = {
|
|
68
|
+
Tap: {
|
|
69
|
+
find: {
|
|
70
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
71
|
+
findTarget: {
|
|
72
|
+
selector: {
|
|
73
|
+
android: {
|
|
74
|
+
class: 'android.widget.Button',
|
|
75
|
+
text: 'submit form',
|
|
76
|
+
},
|
|
77
|
+
iOS: {},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
type: 'tap',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
85
|
+
expect(step.stepDescription()).toEqual(`Tap on element with text "submit form"`);
|
|
86
|
+
});
|
|
87
|
+
it('Humanizes an android Tap step properly when only class is available', () => {
|
|
88
|
+
const stepYaml = {
|
|
89
|
+
Tap: {
|
|
90
|
+
find: {
|
|
91
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
92
|
+
findTarget: {
|
|
93
|
+
selector: {
|
|
94
|
+
android: {
|
|
95
|
+
class: 'android.widget.Button',
|
|
96
|
+
},
|
|
97
|
+
iOS: {},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
type: 'tap',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
105
|
+
expect(step.stepDescription()).toEqual(`Tap on "Button" element`);
|
|
106
|
+
});
|
|
107
|
+
it('Humanizes an iOS Enter Text step properly for accessibility ID', () => {
|
|
108
|
+
const stepYaml = {
|
|
109
|
+
EnterText: {
|
|
110
|
+
text: 'Bailey',
|
|
111
|
+
find: {
|
|
112
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
113
|
+
findTarget: {
|
|
114
|
+
selector: {
|
|
115
|
+
iOS: {
|
|
116
|
+
name: 'Name field',
|
|
117
|
+
type: 'XCUIElementTypeButton',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
125
|
+
expect(step.stepDescription()).toEqual(`Enter text "Bailey" in "Name field" element`);
|
|
126
|
+
});
|
|
127
|
+
it('Humanizes an iOS Enter Text step properly for label', () => {
|
|
128
|
+
const stepYaml = {
|
|
129
|
+
EnterText: {
|
|
130
|
+
text: 'Bailey',
|
|
131
|
+
find: {
|
|
132
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
133
|
+
findTarget: {
|
|
134
|
+
selector: {
|
|
135
|
+
iOS: {
|
|
136
|
+
type: 'XCUIElementTypeButton',
|
|
137
|
+
label: 'add name here',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
145
|
+
expect(step.stepDescription()).toEqual(`Enter text "Bailey" in element with text "add name here"`);
|
|
146
|
+
});
|
|
147
|
+
it('Humanizes an android Enter Text step properly using android text', () => {
|
|
148
|
+
const stepYaml = {
|
|
149
|
+
EnterText: {
|
|
150
|
+
text: 'Bailey',
|
|
151
|
+
find: {
|
|
152
|
+
findType: domUtil_1.FindType.FIND_ONE,
|
|
153
|
+
findTarget: {
|
|
154
|
+
selector: {
|
|
155
|
+
android: {
|
|
156
|
+
class: 'android.widget.Button',
|
|
157
|
+
text: 'submit form',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
165
|
+
expect(step.stepDescription()).toEqual(`Enter text "Bailey" in element with text "submit form"`);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const NavigateBackStep_1 = require("../../steps/NavigateBackStep");
|
|
4
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
5
|
+
describe('NavigateBack steps parse correctly', () => {
|
|
6
|
+
it('Parses a NavigateBack step', () => {
|
|
7
|
+
const navigateBackStepDescriptor = {};
|
|
8
|
+
const steps = [
|
|
9
|
+
{
|
|
10
|
+
NavigateBack: navigateBackStepDescriptor,
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, NavigateBackStep_1.NavigateBackStep.stepName, navigateBackStepDescriptor);
|
|
14
|
+
});
|
|
15
|
+
it('Humanizes a NavigateHome back', () => {
|
|
16
|
+
const stepYaml = {
|
|
17
|
+
NavigateBack: {},
|
|
18
|
+
};
|
|
19
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
20
|
+
expect(step.stepDescription()).toEqual(`Navigate back`);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const NavigateHomeStep_1 = require("../../steps/NavigateHomeStep");
|
|
4
|
+
const StepTestsUtil_1 = require("../StepTestsUtil");
|
|
5
|
+
describe('NavigateHome steps parse correctly', () => {
|
|
6
|
+
it('Parses a NavigateHome step', () => {
|
|
7
|
+
const navigateHomeStepDescriptor = {};
|
|
8
|
+
const steps = [
|
|
9
|
+
{
|
|
10
|
+
NavigateHome: navigateHomeStepDescriptor,
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, NavigateHomeStep_1.NavigateHomeStep.stepName, navigateHomeStepDescriptor);
|
|
14
|
+
});
|
|
15
|
+
it('Humanizes a NavigateHome step', () => {
|
|
16
|
+
const stepYaml = {
|
|
17
|
+
NavigateHome: {},
|
|
18
|
+
};
|
|
19
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
20
|
+
expect(step.stepDescription()).toEqual(`Navigate home`);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
coordinates: {
|
|
10
|
+
from: {
|
|
11
|
+
xPercent: 1074 / windowSize.width,
|
|
12
|
+
yPercent: 2350 / windowSize.height,
|
|
13
|
+
},
|
|
14
|
+
to: {
|
|
15
|
+
xPercent: 1074 / windowSize.width,
|
|
16
|
+
yPercent: 100 / windowSize.height,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const steps = [
|
|
21
|
+
{
|
|
22
|
+
Scroll: scrollStepDescriptor,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, ScrollStep_1.ScrollStep.stepName, scrollStepDescriptor);
|
|
26
|
+
});
|
|
27
|
+
it('Humanizes a scroll step', () => {
|
|
28
|
+
const windowSize = { width: 1440, height: 2392 };
|
|
29
|
+
const stepYaml = {
|
|
30
|
+
Scroll: {
|
|
31
|
+
coordinates: {
|
|
32
|
+
from: {
|
|
33
|
+
xPercent: 1074 / windowSize.width,
|
|
34
|
+
yPercent: 2350 / windowSize.height,
|
|
35
|
+
},
|
|
36
|
+
to: {
|
|
37
|
+
xPercent: 1074 / windowSize.width,
|
|
38
|
+
yPercent: 100 / windowSize.height,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
44
|
+
expect(step.stepDescription()).toEqual(`Scroll down 94.06% of the screen`);
|
|
45
|
+
});
|
|
46
|
+
it('Humanizes scroll directions as expected', () => {
|
|
47
|
+
const scrollUpStepYaml = {
|
|
48
|
+
Scroll: {
|
|
49
|
+
coordinates: {
|
|
50
|
+
from: {
|
|
51
|
+
xPercent: 0.109212,
|
|
52
|
+
yPercent: 0.241223,
|
|
53
|
+
},
|
|
54
|
+
to: {
|
|
55
|
+
xPercent: 0.145543,
|
|
56
|
+
yPercent: 0.865454,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const scrollUpStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(scrollUpStepYaml);
|
|
62
|
+
expect(scrollUpStep.stepDescription()).toEqual(`Scroll up 62.42% of the screen`);
|
|
63
|
+
const scrollDownStepYaml = {
|
|
64
|
+
Scroll: {
|
|
65
|
+
coordinates: {
|
|
66
|
+
from: {
|
|
67
|
+
xPercent: 0.48351,
|
|
68
|
+
yPercent: 0.89123,
|
|
69
|
+
},
|
|
70
|
+
to: {
|
|
71
|
+
xPercent: 0.4515,
|
|
72
|
+
yPercent: 0.0874,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const scrollDownStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(scrollDownStepYaml);
|
|
78
|
+
expect(scrollDownStep.stepDescription()).toEqual(`Scroll down 80.38% of the screen`);
|
|
79
|
+
const swipeRightStepYaml = {
|
|
80
|
+
Scroll: {
|
|
81
|
+
coordinates: {
|
|
82
|
+
from: {
|
|
83
|
+
xPercent: 0.08111,
|
|
84
|
+
yPercent: 0.46123,
|
|
85
|
+
},
|
|
86
|
+
to: {
|
|
87
|
+
xPercent: 0.90295,
|
|
88
|
+
yPercent: 0.4574,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
const swipeRightStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(swipeRightStepYaml);
|
|
94
|
+
expect(swipeRightStep.stepDescription()).toEqual(`Swipe right 82.18% of the screen`);
|
|
95
|
+
const swipeLeftStepYaml = {
|
|
96
|
+
Scroll: {
|
|
97
|
+
coordinates: {
|
|
98
|
+
from: {
|
|
99
|
+
xPercent: 0.88111,
|
|
100
|
+
yPercent: 0.46123,
|
|
101
|
+
},
|
|
102
|
+
to: {
|
|
103
|
+
xPercent: 0.09295,
|
|
104
|
+
yPercent: 0.4574,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const swipeLeftStep = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(swipeLeftStepYaml);
|
|
110
|
+
expect(swipeLeftStep.stepDescription()).toEqual(`Swipe left 78.82% of the screen`);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
orientation: SetOrientationStepDescriptor_1.Orientation.Landscape,
|
|
10
|
+
};
|
|
11
|
+
const steps = [
|
|
12
|
+
{
|
|
13
|
+
SetOrientation: setOrientationStepDescriptor,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, SetOrientationStep_1.SetOrientationStep.stepName, setOrientationStepDescriptor);
|
|
17
|
+
});
|
|
18
|
+
it('Humanizes a SetOrientation step', () => {
|
|
19
|
+
const stepYaml = {
|
|
20
|
+
SetOrientation: {
|
|
21
|
+
orientation: SetOrientationStepDescriptor_1.Orientation.Landscape,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const step = (0, StepTestsUtil_1.loadRawStepIntoMablStep)(stepYaml);
|
|
25
|
+
expect(step.stepDescription()).toEqual(`Set orientation of device to landscape`);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
find,
|
|
23
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
24
|
+
};
|
|
25
|
+
const steps = [
|
|
26
|
+
{
|
|
27
|
+
Tap: stepDescriptor,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, TapStep_1.TapStep.stepName, stepDescriptor);
|
|
31
|
+
const tapStep = new TapStep_1.TapStep(stepDescriptor);
|
|
32
|
+
expect(tapStep.getInputVariables()).toStrictEqual(['varInFind']);
|
|
33
|
+
});
|
|
34
|
+
it('Parses a WebView Tap step', () => {
|
|
35
|
+
const stepDescriptor = {
|
|
36
|
+
find: TestMobileFindDescriptors_1.iOSWebViewTextFieldMobileFindDescriptor,
|
|
37
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
38
|
+
};
|
|
39
|
+
const steps = [
|
|
40
|
+
{
|
|
41
|
+
Tap: stepDescriptor,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
(0, StepTestsUtil_1.parseAndValidateYamlConversion)(steps, TapStep_1.TapStep.stepName, stepDescriptor);
|
|
45
|
+
});
|
|
46
|
+
it('Renders description for step without find', () => {
|
|
47
|
+
const stepDescriptor = {
|
|
48
|
+
type: TapStepDescriptor_1.TapType.tap,
|
|
49
|
+
};
|
|
50
|
+
const tapStep = new TapStep_1.TapStep(stepDescriptor);
|
|
51
|
+
expect(tapStep.stepDescription()).toEqual('Tap on unknown element');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -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";
|
|
@@ -47,12 +48,13 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
47
48
|
super(name, args, actions);
|
|
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) {
|
|
@@ -130,6 +132,7 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
getFormattedStep(_fullLocatorsOn) {
|
|
135
|
+
var _a, _b;
|
|
133
136
|
const result = {};
|
|
134
137
|
result[this.getStepName()] = { ...this.annotationsAsYml() };
|
|
135
138
|
const formatted = result[this.getStepName()];
|
|
@@ -144,49 +147,57 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
144
147
|
if (this.assertionValue !== undefined) {
|
|
145
148
|
formatted.assertionValue = this.assertionValue;
|
|
146
149
|
}
|
|
147
|
-
const
|
|
148
|
-
if ((0,
|
|
150
|
+
const targetDescriptor = this.primaryAction.toDescriptor();
|
|
151
|
+
if ((0, GetVariableDescriptor_1.isGetVariableDescriptor)(targetDescriptor)) {
|
|
152
|
+
formatted.target = (0, GetVariableDescriptor_1.convertGetVariableDescriptorToYaml)(targetDescriptor);
|
|
149
153
|
}
|
|
150
154
|
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
|
-
}
|
|
155
|
+
formatted.target = targetDescriptor;
|
|
173
156
|
}
|
|
174
157
|
if (this.conditionAction.options) {
|
|
175
158
|
formatted.conditionOptions = this.conditionAction.options;
|
|
176
159
|
}
|
|
160
|
+
if (!!((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.observationScope) ||
|
|
161
|
+
!!((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.onFailure)) {
|
|
162
|
+
formatted.assertArguments = this.assertArguments;
|
|
163
|
+
}
|
|
164
|
+
result[this.getStepName()] =
|
|
165
|
+
MablStep_1.MablStep.cloneAndRemoveUndefinedEntriesFromObject(formatted);
|
|
177
166
|
return result;
|
|
178
167
|
}
|
|
179
168
|
static fromYaml(stepName, stepArgs) {
|
|
169
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
180
170
|
const actions = [];
|
|
181
171
|
const assertionType = exports.assertionStepToField[stepName];
|
|
182
172
|
const assertionValue = stepArgs.assertionValue;
|
|
183
173
|
const conditionOptions = stepArgs.conditionOptions;
|
|
184
174
|
let primaryAction;
|
|
185
|
-
if (stepArgs.kind === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
175
|
+
if (((_a = stepArgs.target) === null || _a === void 0 ? void 0 : _a.kind) === GetCurrentLocationDescriptor_1.GET_CURRENT_LOCATION_KIND) {
|
|
186
176
|
primaryAction = new GetUrlAction_1.GetUrlAction(GetUrlAction_1.GetUrlAction.mablScriptStepNames[0], []);
|
|
187
177
|
}
|
|
178
|
+
else if (((_b = stepArgs.target) === null || _b === void 0 ? void 0 : _b.kind) === GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
179
|
+
primaryAction = new GetVariableValue_1.GetVariableValue(GetVariableValue_1.GetVariableValue.mablScriptStepNames[0], [(_c = stepArgs.target) === null || _c === void 0 ? void 0 : _c.variable]);
|
|
180
|
+
}
|
|
181
|
+
else if ((0, domUtil_1.isNormalizedFindEmailDescriptor)((_d = stepArgs.target) === null || _d === void 0 ? void 0 : _d.findTarget) ||
|
|
182
|
+
(0, domUtil_1.isCookieSelector)((_e = stepArgs.target) === null || _e === void 0 ? void 0 : _e.findTarget) ||
|
|
183
|
+
(0, domUtil_1.isTabSelector)((_f = stepArgs.target) === null || _f === void 0 ? void 0 : _f.findTarget)) {
|
|
184
|
+
const { findTarget, findType } = stepArgs.target;
|
|
185
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget]);
|
|
186
|
+
}
|
|
187
|
+
else if ((0, domUtil_1.isMobileFindDescriptor)(stepArgs.target)) {
|
|
188
|
+
primaryAction = MobileFindAction_1.MobileFindAction.fromDescriptor(stepArgs.target);
|
|
189
|
+
}
|
|
190
|
+
else if ((0, domUtil_1.isFindElementDescriptor)(stepArgs.target)) {
|
|
191
|
+
const { findOptions, findTarget, findType } = stepArgs.target;
|
|
192
|
+
if (findType === domUtil_1.FindType.FIND_ONE) {
|
|
193
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
primaryAction = new FindAction_1.FindAction(findType, [findTarget, findOptions]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
188
199
|
else {
|
|
189
|
-
|
|
200
|
+
throw new Error(`Error parsing [${stepName}] with incompatible step arguments`);
|
|
190
201
|
}
|
|
191
202
|
actions.push(primaryAction);
|
|
192
203
|
if (assertionType === 'present' || assertionType === 'not_present') {
|
|
@@ -199,11 +210,8 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
199
210
|
if (stepArgs.attribute === 'count') {
|
|
200
211
|
actions.push(new CountAction_1.CountAction('count', [stepArgs.attribute]));
|
|
201
212
|
}
|
|
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));
|
|
213
|
+
else if (((_g = stepArgs.target) === null || _g === void 0 ? void 0 : _g.kind) !== GetVariableDescriptor_1.GET_VARIABLE_VALUE) {
|
|
214
|
+
actions.push(new ExtractAction_1.ExtractAction(ExtractAction_1.ExtractAction.mablScriptTypeFromYamlType(stepArgs.extractType), [stepArgs.attribute]));
|
|
207
215
|
}
|
|
208
216
|
actions.push(new ConditionAction_1.ConditionAction('evaluate_condition', [
|
|
209
217
|
assertionType,
|
|
@@ -211,15 +219,17 @@ class AssertStep extends MablStep_1.MablStep {
|
|
|
211
219
|
conditionOptions,
|
|
212
220
|
]));
|
|
213
221
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
], actions);
|
|
222
|
+
const assertStep = new AssertStep('assert', [stepArgs.assertArguments], actions);
|
|
223
|
+
if (stepArgs.annotation) {
|
|
224
|
+
assertStep.setAnnotation(stepArgs.annotation);
|
|
225
|
+
}
|
|
226
|
+
return assertStep;
|
|
220
227
|
}
|
|
221
228
|
toMablscript() {
|
|
222
229
|
var _a, _b, _c, _d;
|
|
230
|
+
if (this.primaryAction instanceof MobileFindAction_1.MobileFindAction) {
|
|
231
|
+
throw new Error('Mobile steps do not generate mablscript');
|
|
232
|
+
}
|
|
223
233
|
const assertAction = `.assert(${!!(((_a = this.assertArguments) === null || _a === void 0 ? void 0 : _a.onFailure) ||
|
|
224
234
|
((_b = this.assertArguments) === null || _b === void 0 ? void 0 : _b.observationScope))
|
|
225
235
|
? (0, MablAction_1.convertObjectToMablscriptArgs)({
|
|
@@ -97,10 +97,38 @@ 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
|
+
return result;
|
|
131
|
+
}
|
|
104
132
|
getNewAssertionStep() {
|
|
105
133
|
const yamlified = (0, importer_1.yamlifyTheLoadedSteps)([this]);
|
|
106
134
|
const reloadedSteps = (0, importer_1.loadYamlSteps)(yamlified);
|