artes 1.1.40 → 1.1.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- const { When } = require("../helper/imports/commons");
1
+ const { When, random, element, selector } = require("../helper/imports/commons");
2
2
  const { keyboard, frame } = require("../helper/stepFunctions/exporter");
3
3
 
4
4
  // User presses a key on a specific selector
@@ -93,3 +93,106 @@ When("User presses {string}", async function (key) {
93
93
  When("User types {string} with delay {int}", async function (key, delay) {
94
94
  await keyboard.keyboardType(key, delay);
95
95
  });
96
+
97
+
98
+
99
+ When('User types random word in {string}', async (input) => {
100
+ const randomWord = random.lorem.word();
101
+ await keyboard.fill(input, randomWord);
102
+ });
103
+
104
+ When('User types random word that has character between {int} and {int} in {string}', async (from,to, input) => {
105
+ const randomWord = random.lorem.word({min:from, max:to});
106
+ await keyboard.fill(input, randomWord);
107
+ });
108
+
109
+ When('User types random words in {string}', async (input) => {
110
+ const randomWord = random.lorem.words();
111
+ await keyboard.fill(input, randomWord);
112
+ });
113
+
114
+ When(
115
+ "User types random words that range between {int} and {int} in {string}",
116
+ async (from, to, input) => {
117
+ const words = random.lorem.words({ min: from, max: to });
118
+ await keyboard.fill(input, words);
119
+ },
120
+ );
121
+
122
+ When('User types random paragraph in {string}', async (input) => {
123
+ const randomParagraph = random.lorem.paragraph();
124
+ await keyboard.fill(input, randomParagraph);
125
+ });
126
+
127
+ When(
128
+ "User types random paragraph that range between {int} and {int} in {string}",
129
+ async (from, to, input) => {
130
+ const words = random.lorem.paragraph({ min: from, max: to });
131
+ await keyboard.fill(input, words);
132
+ },
133
+ );
134
+
135
+ When('User types random url in {string}', async (input) => {
136
+ const randomURL = random.internet.url();
137
+ await keyboard.fill(input, randomURL);
138
+ });
139
+
140
+ When('User types random number in {string}', async (input) => {
141
+ const randomNumber = random.number.int();
142
+ await keyboard.fill(input, randomNumber.toString());
143
+ });
144
+
145
+ When('User types random number that range between {int} and {int} in {string}', async (from, to, input) => {
146
+ const randomNumber = random.number.int({ min: from, max: to });
147
+ await keyboard.fill(input, randomNumber.toString());
148
+ });
149
+
150
+ When('User types random email in {string}', async (key) => {
151
+ const email = random.internet.email()
152
+ await keyboard.fill(key, email);
153
+ });
154
+
155
+ When(
156
+ "User types random word in {int} th of {string}",
157
+ async (th, inputs) => {
158
+ const nthElement = await frame.nth(th, inputs);
159
+ const randomWord = random.lorem.word();
160
+ await nthElement.fill(randomWord);
161
+ },
162
+ );
163
+
164
+ When('User types random word that has character between {int} and {int} in {int} th of {string}', async (from,to,th, inputs) => {
165
+ const nthElement = await frame.nth(th, inputs);
166
+ const randomWord = random.lorem.word({min:from, max:to});
167
+ await nthElement.fill(randomWord);
168
+ });
169
+
170
+ When('User types random characters from {string} in {string}', async (chars, input) => {
171
+ const randomCharacters = random.string.fromCharacters(chars,10);
172
+ input = await element(selector(input))
173
+ await input.fill(randomCharacters)
174
+ })
175
+
176
+ When('User types random number by hand in range from {int} to {int} in {string} with {int} ms delay', async (from,to, input, delay) => {
177
+ const randomNumber = Math.floor(Math.random() * (to - from + 1)) + from;
178
+ await keyboard.pressSequentiallyDelay(input, randomNumber.toString(), delay);
179
+ })
180
+
181
+ When('User types random alphanumeric in range from {int} to {int} in {string}', async (from,to, input) => {
182
+ const randomWords = await random.string.alphanumeric({length: { min: from, max: to }})
183
+ await element(input).fill(randomWords)
184
+ })
185
+
186
+ Given('User types random fullname in {string}', async (input) => {
187
+ const randomFullname = await random.person.fullName()
188
+ await element(input).fill(randomFullname)
189
+ })
190
+
191
+ Given('User types random date between {int} and {int} in {string}', async (fromYear, toYear, input) => {
192
+ const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear
193
+ const month = Math.floor(Math.random() * 12) + 1
194
+ const day = Math.floor(Math.random() * 28) + 1
195
+ const pad = (num) => num.toString().padStart(2, '0')
196
+ const dateStr = `${pad(day)}.${pad(month)}.${year}`
197
+ await element(input).fill(dateStr)
198
+ })
@@ -254,3 +254,22 @@ When("User scrolls {string} into view", async function (selector) {
254
254
  When("User uploads {string} file to {string}", async (filePath, fileInput) => {
255
255
  await mouse.upload(filePath, fileInput);
256
256
  });
257
+
258
+
259
+ When('User selects by text from {string} randomly', async ( select) => {
260
+ const optionsArray = await element(`${selector(select)} option`).evaluateAll(
261
+ options => options.map(option => option.text)
262
+ );
263
+ const randomOption = await optionsArray[Math.floor(Math.random() * optionsArray.length)];
264
+
265
+ await mouse.selectByText(select, randomOption);
266
+ })
267
+
268
+ When('User selects by value from {string} randomly', async ( select) => {
269
+ const optionsArray = await element(`${selector(select)} option`).evaluateAll(
270
+ options => options.map(option => option.value)
271
+ );
272
+ const randomOption = await optionsArray[Math.floor(Math.random() * optionsArray.length)];
273
+
274
+ await mouse.selectByValue(select, randomOption);
275
+ })