artes 1.1.41 → 1.1.44

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.44",
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, random, element, selector } = require("../helper/imports/commons");
1
+ const { When, random, element, selector, time } = 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
@@ -167,8 +167,44 @@ 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
+ When('User types random fullname in {string}', async (input) => {
187
+ const randomFullname = await random.person.fullName()
188
+ await element(input).fill(randomFullname)
189
+ })
190
+
191
+ When('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
+ })
199
+
200
+ When('User types date {int} days after today in {string}', async (day, input) => {
201
+ const now = new time();
202
+ const afterDate = now.add(day, 'day').format("DD-MM-YYYY");
203
+ await element(input).fill(afterDate)
204
+ })
205
+
206
+ When('User types date {int} days before today in {string}', async (day, input) => {
207
+ const now = new time();
208
+ const beforeDate = now.subtract(day, 'day').format("DD-MM-YYYY");
209
+ await element(input).fill(beforeDate)
210
+ })
@@ -1,6 +1,7 @@
1
- const { When } = require("../helper/imports/commons");
1
+ const { When, element, selector } = require("../helper/imports/commons");
2
2
  const { mouse, frame } = require("../helper/stepFunctions/exporter");
3
3
 
4
+
4
5
  // User clicks on a selector
5
6
  When("User clicks {string}", async function (selector) {
6
7
  await mouse.click(selector);
@@ -254,3 +255,22 @@ When("User scrolls {string} into view", async function (selector) {
254
255
  When("User uploads {string} file to {string}", async (filePath, fileInput) => {
255
256
  await mouse.upload(filePath, fileInput);
256
257
  });
258
+
259
+
260
+ When('User selects by text from {string} randomly', async ( select) => {
261
+ const optionsArray = await element(`${selector(select)} option`).evaluateAll(
262
+ options => options.map(option => option.text)
263
+ );
264
+ const randomOption = await optionsArray[Math.floor(Math.random() * optionsArray.length)];
265
+
266
+ await mouse.selectByText(select, randomOption);
267
+ })
268
+
269
+ When('User selects by value from {string} randomly', async ( select) => {
270
+ const optionsArray = await element(`${selector(select)} option`).evaluateAll(
271
+ options => options.map(option => option.value)
272
+ );
273
+ const randomOption = await optionsArray[Math.floor(Math.random() * optionsArray.length)];
274
+
275
+ await mouse.selectByValue(select, randomOption);
276
+ })