artes 1.2.18 → 1.2.20
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/README.md +24 -10
- package/cucumber.config.js +16 -5
- package/docs/functionDefinitions.md +0 -3
- package/docs/stepDefinitions.md +11 -1
- package/executer.js +10 -6
- package/package.json +1 -1
- package/src/helper/contextManager/browserManager.js +1 -1
- package/src/helper/contextManager/requestManager.js +2 -2
- package/src/helper/executers/helper.js +3 -0
- package/src/helper/executers/projectCreator.js +11 -7
- package/src/helper/executers/reportGenerator.js +26 -10
- package/src/helper/imports/commons.js +2 -1
- package/src/helper/stepFunctions/APIActions.js +2 -3
- package/src/hooks/hooks.js +4 -4
- package/src/stepDefinitions/API.steps.js +31 -31
- package/src/stepDefinitions/assertions.steps.js +17 -15
- package/src/stepDefinitions/keyboardActions.steps.js +136 -102
- package/src/stepDefinitions/mouseActions.steps.js +12 -12
- package/src/stepDefinitions/random.steps.js +84 -65
|
@@ -3,7 +3,8 @@ const {
|
|
|
3
3
|
context,
|
|
4
4
|
extractVarsFromResponse,
|
|
5
5
|
saveVar,
|
|
6
|
-
time,
|
|
6
|
+
time,
|
|
7
|
+
random,
|
|
7
8
|
} = require("../helper/imports/commons");
|
|
8
9
|
const { api } = require("../helper/stepFunctions/exporter");
|
|
9
10
|
const Ajv = require("ajv");
|
|
@@ -16,7 +17,7 @@ When(
|
|
|
16
17
|
"User sends GET request to {string} with payload:",
|
|
17
18
|
async function (url, payload) {
|
|
18
19
|
await api.get(url, payload);
|
|
19
|
-
}
|
|
20
|
+
},
|
|
20
21
|
);
|
|
21
22
|
|
|
22
23
|
When(
|
|
@@ -24,7 +25,7 @@ When(
|
|
|
24
25
|
async function (url, vars) {
|
|
25
26
|
await api.get(url);
|
|
26
27
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
27
|
-
}
|
|
28
|
+
},
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
When(
|
|
@@ -32,7 +33,7 @@ When(
|
|
|
32
33
|
async function (url, vars, payload) {
|
|
33
34
|
await api.get(url, payload);
|
|
34
35
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
35
|
-
}
|
|
36
|
+
},
|
|
36
37
|
);
|
|
37
38
|
|
|
38
39
|
When("User sends HEAD request to {string}", async function (url) {
|
|
@@ -43,7 +44,7 @@ When(
|
|
|
43
44
|
"User sends POST request to {string} with payload:",
|
|
44
45
|
async function (url, payload) {
|
|
45
46
|
await api.post(url, payload);
|
|
46
|
-
}
|
|
47
|
+
},
|
|
47
48
|
);
|
|
48
49
|
|
|
49
50
|
When(
|
|
@@ -51,14 +52,14 @@ When(
|
|
|
51
52
|
async function (url, vars, payload) {
|
|
52
53
|
await api.post(url, payload);
|
|
53
54
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
54
|
-
}
|
|
55
|
+
},
|
|
55
56
|
);
|
|
56
57
|
|
|
57
58
|
When(
|
|
58
59
|
"User sends multipart POST request to {string} with payload:",
|
|
59
60
|
async (url, payload) => {
|
|
60
61
|
await api.post(url, payload, "multipart");
|
|
61
|
-
}
|
|
62
|
+
},
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
When(
|
|
@@ -66,14 +67,14 @@ When(
|
|
|
66
67
|
async (url, vars, payload) => {
|
|
67
68
|
await api.post(url, payload, "multipart");
|
|
68
69
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
69
|
-
}
|
|
70
|
+
},
|
|
70
71
|
);
|
|
71
72
|
|
|
72
73
|
When(
|
|
73
74
|
"User sends x-www-form-urlencoded POST request to {string} with payload:",
|
|
74
75
|
async (url, payload) => {
|
|
75
76
|
await api.post(url, payload, "application/x-www-form-urlencoded");
|
|
76
|
-
}
|
|
77
|
+
},
|
|
77
78
|
);
|
|
78
79
|
|
|
79
80
|
When(
|
|
@@ -81,14 +82,14 @@ When(
|
|
|
81
82
|
async (url, vars, payload) => {
|
|
82
83
|
await api.post(url, payload, "application/x-www-form-urlencoded");
|
|
83
84
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
84
|
-
}
|
|
85
|
+
},
|
|
85
86
|
);
|
|
86
87
|
|
|
87
88
|
When(
|
|
88
89
|
"User sends PUT request to {string} with payload:",
|
|
89
90
|
async function (url, payload) {
|
|
90
91
|
await api.put(url, payload);
|
|
91
|
-
}
|
|
92
|
+
},
|
|
92
93
|
);
|
|
93
94
|
|
|
94
95
|
When(
|
|
@@ -96,14 +97,14 @@ When(
|
|
|
96
97
|
async function (url, vars, payload) {
|
|
97
98
|
await api.put(url, payload);
|
|
98
99
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
99
|
-
}
|
|
100
|
+
},
|
|
100
101
|
);
|
|
101
102
|
|
|
102
103
|
When(
|
|
103
104
|
"User sends multipart PUT request to {string} with payload:",
|
|
104
105
|
async function (url, payload) {
|
|
105
106
|
await api.put(url, payload, "multipart");
|
|
106
|
-
}
|
|
107
|
+
},
|
|
107
108
|
);
|
|
108
109
|
|
|
109
110
|
When(
|
|
@@ -111,14 +112,14 @@ When(
|
|
|
111
112
|
async function (url, vars, payload) {
|
|
112
113
|
await api.put(url, payload, "multipart");
|
|
113
114
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
114
|
-
}
|
|
115
|
+
},
|
|
115
116
|
);
|
|
116
117
|
|
|
117
118
|
When(
|
|
118
119
|
"User sends x-www-form-urlencoded PUT request to {string} with payload:",
|
|
119
120
|
async (url, payload) => {
|
|
120
121
|
await api.put(url, payload, "application/x-www-form-urlencoded");
|
|
121
|
-
}
|
|
122
|
+
},
|
|
122
123
|
);
|
|
123
124
|
|
|
124
125
|
When(
|
|
@@ -126,14 +127,14 @@ When(
|
|
|
126
127
|
async (url, vars, payload) => {
|
|
127
128
|
await api.put(url, payload, "application/x-www-form-urlencoded");
|
|
128
129
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
129
|
-
}
|
|
130
|
+
},
|
|
130
131
|
);
|
|
131
132
|
|
|
132
133
|
When(
|
|
133
134
|
"User sends PATCH request to {string} with payload:",
|
|
134
135
|
async function (url, payload) {
|
|
135
136
|
await api.patch(url, payload);
|
|
136
|
-
}
|
|
137
|
+
},
|
|
137
138
|
);
|
|
138
139
|
|
|
139
140
|
When(
|
|
@@ -141,14 +142,14 @@ When(
|
|
|
141
142
|
async function (url, vars, payload) {
|
|
142
143
|
await api.patch(url, payload);
|
|
143
144
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
144
|
-
}
|
|
145
|
+
},
|
|
145
146
|
);
|
|
146
147
|
|
|
147
148
|
When(
|
|
148
149
|
"User sends multipart PATCH request to {string} with payload:",
|
|
149
150
|
async function (url, payload) {
|
|
150
151
|
await api.patch(url, payload, "multipart");
|
|
151
|
-
}
|
|
152
|
+
},
|
|
152
153
|
);
|
|
153
154
|
|
|
154
155
|
When(
|
|
@@ -156,14 +157,14 @@ When(
|
|
|
156
157
|
async function (url, vars, payload) {
|
|
157
158
|
await api.patch(url, payload, "multipart");
|
|
158
159
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
159
|
-
}
|
|
160
|
+
},
|
|
160
161
|
);
|
|
161
162
|
|
|
162
163
|
When(
|
|
163
164
|
"User sends x-www-form-urlencoded PATCH request to {string} with payload:",
|
|
164
|
-
async (url,
|
|
165
|
+
async (url, payload) => {
|
|
165
166
|
await api.patch(url, payload, "application/x-www-form-urlencoded");
|
|
166
|
-
}
|
|
167
|
+
},
|
|
167
168
|
);
|
|
168
169
|
|
|
169
170
|
When(
|
|
@@ -171,7 +172,7 @@ When(
|
|
|
171
172
|
async (url, vars, payload) => {
|
|
172
173
|
await api.patch(url, payload, "application/x-www-form-urlencoded");
|
|
173
174
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
174
|
-
}
|
|
175
|
+
},
|
|
175
176
|
);
|
|
176
177
|
|
|
177
178
|
When("User sends DELETE request to {string}", async function (url) {
|
|
@@ -183,14 +184,14 @@ When(
|
|
|
183
184
|
async function (url, vars) {
|
|
184
185
|
await api.delete(url);
|
|
185
186
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
186
|
-
}
|
|
187
|
+
},
|
|
187
188
|
);
|
|
188
189
|
|
|
189
190
|
When(
|
|
190
191
|
"User sends DELETE request to {string} with payload:",
|
|
191
192
|
async function (url, payload) {
|
|
192
193
|
await api.delete(url, payload);
|
|
193
|
-
}
|
|
194
|
+
},
|
|
194
195
|
);
|
|
195
196
|
|
|
196
197
|
When(
|
|
@@ -198,7 +199,7 @@ When(
|
|
|
198
199
|
async function (url, vars, payload) {
|
|
199
200
|
await api.delete(url, payload);
|
|
200
201
|
await extractVarsFromResponse(context.response["Response Body"], vars);
|
|
201
|
-
}
|
|
202
|
+
},
|
|
202
203
|
);
|
|
203
204
|
|
|
204
205
|
When(
|
|
@@ -209,14 +210,14 @@ When(
|
|
|
209
210
|
vars,
|
|
210
211
|
customVarName,
|
|
211
212
|
);
|
|
212
|
-
}
|
|
213
|
+
},
|
|
213
214
|
);
|
|
214
215
|
|
|
215
216
|
When(
|
|
216
217
|
"User saves {string} variable as {string}",
|
|
217
218
|
async function (value, customVarName) {
|
|
218
219
|
saveVar(value, customVarName);
|
|
219
|
-
}
|
|
220
|
+
},
|
|
220
221
|
);
|
|
221
222
|
|
|
222
223
|
When("User wants to see saved variables", async function () {
|
|
@@ -267,7 +268,7 @@ When(
|
|
|
267
268
|
default:
|
|
268
269
|
throw new Error(`Unsupported HTTP method: ${httpMethod}`);
|
|
269
270
|
}
|
|
270
|
-
}
|
|
271
|
+
},
|
|
271
272
|
);
|
|
272
273
|
|
|
273
274
|
When(
|
|
@@ -286,7 +287,6 @@ When(
|
|
|
286
287
|
},
|
|
287
288
|
);
|
|
288
289
|
|
|
289
|
-
|
|
290
290
|
When(
|
|
291
291
|
"User sets {string} date {int} days from today",
|
|
292
292
|
async function (dateName, days) {
|
|
@@ -297,4 +297,4 @@ When(
|
|
|
297
297
|
|
|
298
298
|
context.vars[dateName] = expiresAt;
|
|
299
299
|
},
|
|
300
|
-
);
|
|
300
|
+
);
|
|
@@ -826,31 +826,33 @@ Then(
|
|
|
826
826
|
},
|
|
827
827
|
);
|
|
828
828
|
|
|
829
|
-
Then(
|
|
830
|
-
|
|
831
|
-
|
|
829
|
+
Then(
|
|
830
|
+
"User expects that {string} should match {string}",
|
|
831
|
+
async (value1, value2) => {
|
|
832
|
+
await expect(resolveVariable(value1)).toBe(value2);
|
|
833
|
+
},
|
|
834
|
+
);
|
|
832
835
|
|
|
833
836
|
Then(
|
|
834
837
|
"User expects that response body should match {string} schema",
|
|
835
838
|
async function (expectedSchema) {
|
|
836
|
-
if(expectedSchema !=""
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
839
|
+
if (expectedSchema != "") {
|
|
840
|
+
const schema = await selector(expectedSchema);
|
|
841
|
+
const ajv = await new Ajv();
|
|
842
|
+
const validate = await ajv.compile(schema);
|
|
843
|
+
const responseBody = await context.response["Response Body"];
|
|
844
|
+
const valid = await validate(responseBody);
|
|
845
|
+
await expect(valid).toBe(true);
|
|
843
846
|
}
|
|
844
|
-
}
|
|
847
|
+
},
|
|
845
848
|
);
|
|
846
849
|
|
|
847
|
-
|
|
848
850
|
Then(
|
|
849
851
|
"User expects that request should have {int} status code",
|
|
850
852
|
async function (expectedStatusCode) {
|
|
851
853
|
const actualStatusCode = await context.response.Response.status();
|
|
852
854
|
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
853
|
-
}
|
|
855
|
+
},
|
|
854
856
|
);
|
|
855
857
|
|
|
856
858
|
Then(
|
|
@@ -858,5 +860,5 @@ Then(
|
|
|
858
860
|
async function (expectedStatusCode) {
|
|
859
861
|
const actualStatusCode = await context.response.Response.status();
|
|
860
862
|
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
861
|
-
}
|
|
862
|
-
);
|
|
863
|
+
},
|
|
864
|
+
);
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
When,
|
|
3
|
+
random,
|
|
4
|
+
element,
|
|
5
|
+
selector,
|
|
6
|
+
time,
|
|
7
|
+
} = require("../helper/imports/commons");
|
|
2
8
|
const { keyboard, frame } = require("../helper/stepFunctions/exporter");
|
|
3
9
|
|
|
4
10
|
// User presses a key on a specific selector
|
|
@@ -94,134 +100,162 @@ When("User types {string} with delay {int}", async function (key, delay) {
|
|
|
94
100
|
await keyboard.keyboardType(key, delay);
|
|
95
101
|
});
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
When('User types random word in {string}', async (input) => {
|
|
103
|
+
When("User types random word in {string}", async (input) => {
|
|
100
104
|
const randomWord = random.lorem.word();
|
|
101
105
|
await keyboard.fill(input, randomWord);
|
|
102
106
|
});
|
|
103
107
|
|
|
104
|
-
When(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
+
When(
|
|
109
|
+
"User types random word that has character between {int} and {int} in {string}",
|
|
110
|
+
async (from, to, input) => {
|
|
111
|
+
const randomWord = random.lorem.word({ min: from, max: to });
|
|
112
|
+
await keyboard.fill(input, randomWord);
|
|
113
|
+
},
|
|
114
|
+
);
|
|
108
115
|
|
|
109
|
-
When(
|
|
110
|
-
const randomWord = random.lorem.words();
|
|
111
|
-
await keyboard.fill(input, randomWord);
|
|
116
|
+
When("User types random words in {string}", async (input) => {
|
|
117
|
+
const randomWord = random.lorem.words();
|
|
118
|
+
await keyboard.fill(input, randomWord);
|
|
112
119
|
});
|
|
113
120
|
|
|
114
121
|
When(
|
|
115
|
-
"User types random words that range between {int} and {int} in {string}",
|
|
116
|
-
async (from, to, input) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
122
|
+
"User types random words that range between {int} and {int} in {string}",
|
|
123
|
+
async (from, to, input) => {
|
|
124
|
+
const words = random.lorem.words({ min: from, max: to });
|
|
125
|
+
await keyboard.fill(input, words);
|
|
126
|
+
},
|
|
120
127
|
);
|
|
121
128
|
|
|
122
|
-
When(
|
|
129
|
+
When("User types random paragraph in {string}", async (input) => {
|
|
123
130
|
const randomParagraph = random.lorem.paragraph();
|
|
124
131
|
await keyboard.fill(input, randomParagraph);
|
|
125
132
|
});
|
|
126
133
|
|
|
127
134
|
When(
|
|
128
|
-
"User types random paragraph that range between {int} and {int} in {string}",
|
|
129
|
-
async (from, to, input) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
},
|
|
135
|
+
"User types random paragraph that range between {int} and {int} in {string}",
|
|
136
|
+
async (from, to, input) => {
|
|
137
|
+
const words = random.lorem.paragraph({ min: from, max: to });
|
|
138
|
+
await keyboard.fill(input, words);
|
|
139
|
+
},
|
|
133
140
|
);
|
|
134
141
|
|
|
135
|
-
When(
|
|
142
|
+
When("User types random url in {string}", async (input) => {
|
|
136
143
|
const randomURL = random.internet.url();
|
|
137
144
|
await keyboard.fill(input, randomURL);
|
|
138
145
|
});
|
|
139
146
|
|
|
140
|
-
When(
|
|
141
|
-
|
|
147
|
+
When("User types random number in {string}", async (input) => {
|
|
148
|
+
const randomNumber = random.number.int();
|
|
142
149
|
await keyboard.fill(input, randomNumber.toString());
|
|
143
150
|
});
|
|
144
151
|
|
|
145
|
-
When(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
152
|
+
When(
|
|
153
|
+
"User types random number that range between {int} and {int} in {string}",
|
|
154
|
+
async (from, to, input) => {
|
|
155
|
+
const randomNumber = random.number.int({ min: from, max: to });
|
|
156
|
+
await keyboard.fill(input, randomNumber.toString());
|
|
157
|
+
},
|
|
158
|
+
);
|
|
149
159
|
|
|
150
|
-
When(
|
|
151
|
-
const email = random.internet.email()
|
|
152
|
-
await keyboard.fill(key, email);
|
|
160
|
+
When("User types random email in {string}", async (key) => {
|
|
161
|
+
const email = random.internet.email();
|
|
162
|
+
await keyboard.fill(key, email);
|
|
153
163
|
});
|
|
154
164
|
|
|
155
|
-
When(
|
|
156
|
-
"User types random word in {int} th of {string}",
|
|
157
|
-
async (th, inputs) => {
|
|
165
|
+
When("User types random word in {int} th of {string}", async (th, inputs) => {
|
|
158
166
|
const nthElement = await frame.nth(th, inputs);
|
|
159
167
|
const randomWord = random.lorem.word();
|
|
160
168
|
await nthElement.fill(randomWord);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
When(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
When(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
When(
|
|
204
|
-
const
|
|
205
|
-
await
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
When(
|
|
172
|
+
"User types random word that has character between {int} and {int} in {int} th of {string}",
|
|
173
|
+
async (from, to, th, inputs) => {
|
|
174
|
+
const nthElement = await frame.nth(th, inputs);
|
|
175
|
+
const randomWord = random.lorem.word({ min: from, max: to });
|
|
176
|
+
await nthElement.fill(randomWord);
|
|
177
|
+
},
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
When(
|
|
181
|
+
"User types random characters from {string} in {string}",
|
|
182
|
+
async (chars, input) => {
|
|
183
|
+
const randomCharacters = random.string.fromCharacters(chars, 10);
|
|
184
|
+
input = await element(selector(input));
|
|
185
|
+
await input.fill(randomCharacters);
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
When(
|
|
190
|
+
"User types random number by hand in range from {int} to {int} in {string} with {int} ms delay",
|
|
191
|
+
async (from, to, input, delay) => {
|
|
192
|
+
const randomNumber = Math.floor(Math.random() * (to - from + 1)) + from;
|
|
193
|
+
await keyboard.pressSequentiallyDelay(
|
|
194
|
+
input,
|
|
195
|
+
randomNumber.toString(),
|
|
196
|
+
delay,
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
When(
|
|
202
|
+
"User types random alphanumeric in range from {int} to {int} in {string}",
|
|
203
|
+
async (from, to, input) => {
|
|
204
|
+
const randomWords = await random.string.alphanumeric({
|
|
205
|
+
length: { min: from, max: to },
|
|
206
|
+
});
|
|
207
|
+
await element(input).fill(randomWords);
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
When("User types random fullname in {string}", async (input) => {
|
|
212
|
+
const randomFirstName = await random.person.firstName();
|
|
213
|
+
const randomLastName = await random.person.lastName();
|
|
214
|
+
|
|
215
|
+
await element(input).fill(`${randomFirstName} ${randomLastName}`);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
When("User types random first name in {string}", async (input) => {
|
|
219
|
+
const randomFirstName = await random.person.firstName();
|
|
220
|
+
await element(input).fill(randomFirstName);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
When("User types random last name in {string}", async (input) => {
|
|
224
|
+
const randomLastName = await random.person.lastName();
|
|
225
|
+
await element(input).fill(randomLastName);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
When("User types random middle name in {string}", async (input) => {
|
|
229
|
+
const randomMiddleName = await random.person.middleName();
|
|
230
|
+
await element(input).fill(randomMiddleName);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
When(
|
|
234
|
+
"User types random date between {int} and {int} in {string}",
|
|
235
|
+
async (fromYear, toYear, input) => {
|
|
236
|
+
const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear;
|
|
237
|
+
const month = Math.floor(Math.random() * 12) + 1;
|
|
238
|
+
const day = Math.floor(Math.random() * 28) + 1;
|
|
239
|
+
const pad = (num) => num.toString().padStart(2, "0");
|
|
240
|
+
const dateStr = `${pad(day)}.${pad(month)}.${year}`;
|
|
241
|
+
await element(input).fill(dateStr);
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
When(
|
|
246
|
+
"User types date {int} days after today in {string}",
|
|
247
|
+
async (day, input) => {
|
|
248
|
+
const now = new time();
|
|
249
|
+
const afterDate = now.add(day, "day").format("DD-MM-YYYY");
|
|
250
|
+
await element(input).fill(afterDate);
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
When(
|
|
255
|
+
"User types date {int} days before today in {string}",
|
|
256
|
+
async (day, input) => {
|
|
257
|
+
const now = new time();
|
|
258
|
+
const beforeDate = now.subtract(day, "day").format("DD-MM-YYYY");
|
|
259
|
+
await element(input).fill(beforeDate);
|
|
260
|
+
},
|
|
261
|
+
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { When, element, selector } = require("../helper/imports/commons");
|
|
2
2
|
const { mouse, frame } = require("../helper/stepFunctions/exporter");
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
// User clicks on a selector
|
|
6
5
|
When("User clicks {string}", async function (selector) {
|
|
7
6
|
await mouse.click(selector);
|
|
@@ -256,21 +255,22 @@ When("User uploads {string} file to {string}", async (filePath, fileInput) => {
|
|
|
256
255
|
await mouse.upload(filePath, fileInput);
|
|
257
256
|
});
|
|
258
257
|
|
|
259
|
-
|
|
260
|
-
When('User selects by text from {string} randomly', async ( select) => {
|
|
258
|
+
When("User selects by text from {string} randomly", async (select) => {
|
|
261
259
|
const optionsArray = await element(`${selector(select)} option`).evaluateAll(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const randomOption =
|
|
260
|
+
(options) => options.map((option) => option.text),
|
|
261
|
+
);
|
|
262
|
+
const randomOption =
|
|
263
|
+
await optionsArray[Math.floor(Math.random() * optionsArray.length)];
|
|
265
264
|
|
|
266
265
|
await mouse.selectByText(select, randomOption);
|
|
267
|
-
})
|
|
266
|
+
});
|
|
268
267
|
|
|
269
|
-
When(
|
|
268
|
+
When("User selects by value from {string} randomly", async (select) => {
|
|
270
269
|
const optionsArray = await element(`${selector(select)} option`).evaluateAll(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
const randomOption =
|
|
270
|
+
(options) => options.map((option) => option.value),
|
|
271
|
+
);
|
|
272
|
+
const randomOption =
|
|
273
|
+
await optionsArray[Math.floor(Math.random() * optionsArray.length)];
|
|
274
274
|
|
|
275
275
|
await mouse.selectByValue(select, randomOption);
|
|
276
|
-
})
|
|
276
|
+
});
|