artes 1.1.41 → 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.41",
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": {
@@ -167,8 +167,32 @@ const randomWord = random.lorem.word({min:from, max:to});
167
167
  await nthElement.fill(randomWord);
168
168
  });
169
169
 
170
- When('User types random {string} given characters in {string}', async (chars, input) => {
170
+ When('User types random characters from {string} in {string}', async (chars, input) => {
171
171
  const randomCharacters = random.string.fromCharacters(chars,10);
172
172
  input = await element(selector(input))
173
173
  await input.fill(randomCharacters)
174
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
+ })