artes 1.1.30 → 1.1.31

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.
Files changed (38) hide show
  1. package/README.md +458 -458
  2. package/cucumber.config.js +162 -162
  3. package/docs/functionDefinitions.md +2401 -2401
  4. package/docs/stepDefinitions.md +352 -352
  5. package/executer.js +162 -148
  6. package/index.js +48 -48
  7. package/package.json +54 -54
  8. package/src/helper/contextManager/browserManager.js +68 -68
  9. package/src/helper/contextManager/requestManager.js +28 -28
  10. package/src/helper/controller/elementController.js +157 -157
  11. package/src/helper/controller/pomCollector.js +24 -24
  12. package/src/helper/executers/cleaner.js +19 -19
  13. package/src/helper/executers/exporter.js +15 -15
  14. package/src/helper/executers/helper.js +89 -89
  15. package/src/helper/executers/projectCreator.js +168 -168
  16. package/src/helper/executers/reportGenerator.js +25 -25
  17. package/src/helper/executers/testRunner.js +30 -30
  18. package/src/helper/executers/versionChecker.js +31 -31
  19. package/src/helper/imports/commons.js +57 -57
  20. package/src/helper/stepFunctions/APIActions.js +298 -298
  21. package/src/helper/stepFunctions/assertions.js +523 -523
  22. package/src/helper/stepFunctions/browserActions.js +21 -21
  23. package/src/helper/stepFunctions/elementInteractions.js +38 -38
  24. package/src/helper/stepFunctions/exporter.js +19 -19
  25. package/src/helper/stepFunctions/frameActions.js +50 -50
  26. package/src/helper/stepFunctions/keyboardActions.js +41 -41
  27. package/src/helper/stepFunctions/mouseActions.js +145 -145
  28. package/src/helper/stepFunctions/pageActions.js +27 -27
  29. package/src/hooks/context.js +15 -15
  30. package/src/hooks/hooks.js +216 -216
  31. package/src/stepDefinitions/API.steps.js +247 -247
  32. package/src/stepDefinitions/assertions.steps.js +826 -826
  33. package/src/stepDefinitions/browser.steps.js +7 -7
  34. package/src/stepDefinitions/frameActions.steps.js +76 -76
  35. package/src/stepDefinitions/keyboardActions.steps.js +95 -95
  36. package/src/stepDefinitions/mouseActions.steps.js +256 -256
  37. package/src/stepDefinitions/page.steps.js +71 -71
  38. package/src/stepDefinitions/random.steps.js +68 -68
package/README.md CHANGED
@@ -1,459 +1,459 @@
1
- <p align="center">
2
- <img alt="artesLogo" src="https://github.com/user-attachments/assets/e0641011-0e96-4330-8ad5-935b395b0838" width="280">
3
- </p>
4
-
5
- <h1 align="center">Artes</h1>
6
-
7
- ## 🚀 Summary
8
-
9
- Artes is a test runner for Playwright that executes [predefined Cucumber tests](./docs/stepDefinitions.md) and can generate Allure reports for test results. It simplifies setting up Playwright with Cucumber in your automation workflow. With Artes, you can easily run tests without writing step definitions, generate reports, and customize your testing environment.
10
-
11
- ![artes demonstration](https://github.com/user-attachments/assets/c46172f7-103d-45d1-a37d-8d4267df0967)
12
-
13
- ## 🧑‍💻 Installation
14
-
15
- You can install **Artes** via npm. To install it globally**(RECOMMENDED)**, run the following command:
16
-
17
- ```bash
18
- npm install -g artes
19
- ```
20
-
21
- To install it locally in your project, run:
22
-
23
- ```bash
24
- npm install artes
25
- ```
26
-
27
- Once installed, you can run **Artes** using:
28
-
29
- ```bash
30
- npx artes [options]
31
- ```
32
-
33
- ---
34
-
35
- ## 💡 Usage
36
-
37
- **Artes** has following CLI options:
38
-
39
- ```bash
40
- npx artes [options]
41
- ```
42
-
43
- ### Options
44
-
45
- | Option | Description | Usage Example |
46
- | ------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
47
- | 🆘 `-h, --help` | Show the usage options | `artes -h` or `artes --help` |
48
- | 🏷️ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version` |
49
- | 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
50
- | ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
51
- | 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
52
- | `--reportSuccess` | Add screenshots and video records for also Success test cases | `artes --reportSuccess` |
53
- | `--trace` | Enable tracing | `artes --trace ` |
54
- | `-rwt, --reportWithTrace` | Add trace to the report | `artes -rwt` or `artes --reportWithTrace` |
55
- | 📁 `--features` | Specify one or more feature files' relative paths to run (comma-separated) | `artes --features "tests/features/Alma,tests/features/Banan.feature"` |
56
- | 📜 `--stepDef` | Specify one or more step definition files' relative paths to use (comma-separated) | `artes --stepDef "tests/steps/login.js,tests/steps/home.js"` |
57
- | 🔖 `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
58
- | 🌐 `--env` | Set the environment for the test run | `artes --env "dev"` |
59
- | 🕶️ `--headless` | Run browser in headless mode | `artes --headless` |
60
- | ⚡ `--parallel` | Run tests in parallel mode | `artes --parallel 2` |
61
- | 🔁 `--retry` | Retry failed tests | `artes --retry 3` |
62
- | 🎭 `--dryRun` | Perform a dry run without executing tests | `artes --dryRun` |
63
- | 📈 `--percentage` | Set minimum success percentage to pass test run (default is 0) | `artes --percentage 85` |
64
- | 🌍 `--browser` | Specify browser to use (`chromium`, `firefox`, or `webkit`) | `artes --browser chromium` |
65
- | 🔗 `--baseURL` | Set base URL for the tests | `artes --baseURL "https://example.com"` |
66
- | 🖥️ `--maxScreen` | Maximize browser window on launch | `artes --maxScreen` |
67
- | 📏 `--width` | Set browser width (default is 1280) | `artes --width 1920` |
68
- | 📐 `--height` | Set browser height (default is 720) | `artes --height 1080` |
69
- | ⏱️ `--timeout` | Set timeout for each test step in seconds (default is 30 seconds) | `artes --timeout 10` |
70
- | 🐢 `--slowMo` | Slow down text execution for clear view (default: 0 seconds) | `artes --slowMo 1` |
71
-
72
- \*\* To just run the tests: <br>
73
- Globally: artes <br>
74
- Locally: npx artes
75
-
76
- ---
77
-
78
- ## 🎯 Best Practices
79
-
80
- - **Global Installation:**
81
- For ease of use, it's recommended that Artes be installed globally. You can do this by running the following command:
82
-
83
- ```bash
84
- npm install -g artes
85
- ```
86
-
87
- - **Project Creation (Recommended):**
88
- To create a new project with Artes, use the `-c` flag. This will automatically set up the folder structure and configuration for you. Run the command:
89
-
90
- ```bash
91
- artes -c
92
- ```
93
-
94
- 🗂️ Example Project Structure: <br/>
95
- After running the `-c` flag to create a new project, the structure will look like this:
96
-
97
- ```
98
- /artes (Project Name)
99
- /tests
100
- /features
101
- (Your feature files here)
102
- /POMs // Optional
103
- (POM JSON file here)
104
- /steps // For custom steps
105
- (Your step definition JS files here)
106
- artes.config.js
107
- /report
108
- (Generated Allure report HTML here)
109
- ```
110
-
111
- **If you choose not to use the `-c` flag**, you can still download Artes to your testing project and use the prepared steps by running:
112
-
113
- ```bash
114
- npx artes
115
- ```
116
-
117
- You must customize the paths of features, steps, and other configurations by editing the `artes.config.js` file located inside your project folder (or create it).
118
-
119
- For example:
120
-
121
- ```javascript
122
- module.exports = {
123
- paths: ["tests/features/"], // Custom path for feature files
124
- require: ["tests/steps/*.js"], // Custom path for step definitions files
125
- pomPath: "tests/POMS/*.js", // Custom path for POM files
126
- };
127
- ```
128
-
129
- ---
130
-
131
- ## 📝 Writing Feature Files and POM Files
132
-
133
- Artes simplifies your test writing with structured feature files and organized Page Object Models (POM). Here’s how you can create them:
134
-
135
- ### 1. 📄 Feature File Structure
136
-
137
- ```gherkin
138
- Feature: Searching on Google 🔍
139
- Scenario Outline: Search for a term on Google
140
- Given User is on "https://www.google.com/" page
141
- When User types "alma" in "google_search_input"
142
- And User clicks "google_search_button"
143
- And User waits 10 seconds
144
- Then "google_text" should have "Alma" text
145
- ```
146
-
147
- - **Feature**: Describes the main feature being tested (e.g., Google search).
148
- - **Scenario Outline**: Defines a test case with steps.
149
- - **Steps**: Use `Given`, `When`, `And`, `Then` keywords to describe actions and expectations.
150
- - **Selectors**: The element names (e.g., `google_search_input`, `google_search_button`) map to the POM file or can be defined directly.
151
-
152
- ### 2. 📂 POM File Example
153
-
154
- ```json
155
- {
156
- "google_search_input": { "selector": "#APjFqb" },
157
- "google_search_button": {
158
- "selector": "input.gNO89b"
159
- },
160
- "google_text": {
161
- "selector": "#rso div h3",
162
- "waitTime": 5 //seconds
163
- }
164
- }
165
- ```
166
-
167
- - 📑 Using POM File is optional but it is **RECOMMENDED**
168
- - 🔗 Using Selector in Feature File is possible
169
- ```gherkin
170
- When User types "alma" in "#APjFqb"
171
- ```
172
- - 🐍 It is good to use snake_case for element names
173
- - ⏳ "waitTime" is to define custom wait for elements, but the feature currently under development
174
- "selector" must be used if "waitTime" is used, but when using only selector is not needed mention in "selector"
175
-
176
- ---
177
-
178
- ## 🛠️ Customization
179
-
180
- ## ✍️ Writing Custom Step Definitions
181
-
182
- Artes allows you to extend its functionality by writing custom step definitions. Here's how you can do it:
183
-
184
- ### Import Required APIs
185
-
186
- ```javascript
187
- const {
188
- expect,
189
- Given,
190
- When,
191
- Then,
192
- element,
193
- context,
194
- keyboard,
195
- mouse,
196
- frame,
197
- assert,
198
- elementInteractions,
199
- } = require("artes"); // Common JS
200
- import { expect, Given, When, Then, element, context } from "artes"; // ES Modules (Do not RECOMMENDED)
201
- ```
202
-
203
- - **`Given`, `When`, `Then`**: These define your steps in Cucumber syntax. Example:
204
-
205
- ```javascript
206
- Given("User is on the login page", async () => {
207
- await context.page.navigateTo("https://example.com/login");
208
- });
209
- ```
210
-
211
- - **`page`**: Provides higher-level page actions such as navigation and waiting(Same as PlayWright). Examples:
212
- - Navigate to a URL:
213
- ```javascript
214
- await context.page.navigate("https://example.com");
215
- ```
216
- - Wait for a selector:
217
- ```javascript
218
- await context.page.waitForSelector("#loadingSpinner");
219
- ```
220
- - **`request`**: Use for sending HTTP requests. _(Note: This feature is currently under development.)_
221
-
222
- - **`element`**: Use for interacting with elements on the web page. Examples:
223
- - Clicking a button:
224
- ```javascript
225
- await element("#submitButton").click();
226
- ```
227
- - Filling an input:
228
- ```javascript
229
- await element("#username").fill("testUser");
230
- ```
231
- - **`expect`**: Use for assertions in your steps. For example:
232
- ```javascript
233
- expect(actualValue).toBe(expectedValue);
234
- expect(element("Page_Title")).toHaveText(expectedValue);
235
- ```
236
-
237
- ## 📋 Simplified Functions
238
-
239
- If you don't want to deal with Playwright methods directly, you can simply use the following predefined actions methods by import them:
240
-
241
- ```javascript
242
- const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
243
- ```
244
-
245
- - **Mouse Actions:**
246
- `mouse.click(element)`
247
-
248
- - **Keyboard Actions:**
249
- `keyboard.press(key)`
250
-
251
- - **Element Interactions:**
252
- `elementInteractions.isChecked()`
253
-
254
- - **Assertions:**
255
- `assert.shouldBeTruthy(element)`
256
-
257
- - **Frame Actions:**
258
- `frame.first()`
259
-
260
- - **API Actions:**
261
- `api.post(url, payload, requestDataType)`
262
-
263
- ---
264
-
265
- For a detailed explanation of each function, please refer to the [function definitions](./docs/functionDefinitions.md).
266
-
267
- ---
268
-
269
- ### Example of a Custom Step Definition
270
-
271
- ```javascript
272
- const { Given, When, Then, expect, element, page } = require("artes");
273
-
274
- Given("User is on the home page", async () => {
275
- await page.navigate("https://example.com");
276
- });
277
-
278
- When("User clicks the login button", async () => {
279
- await element("#loginButton").click();
280
- });
281
-
282
- Then("User should see the login form", async () => {
283
- expect(element("#loginForm")).toBeVisible(true);
284
- });
285
- ```
286
-
287
- ## ⚙️ Configuration
288
-
289
- You can configure Artes by editing the `artes.config.js` file. Below are the default configuration options with explanations:
290
-
291
- | **Option** | **Default Value** | **Description** |
292
- | ----------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------- |
293
- | `timeout` | `30` | Default timeout in seconds. |
294
- | `slowMo` | `0` | Default slow motion in seconds |
295
- | `paths` | `[moduleConfig.featuresPath]` | Paths to feature files. |
296
- | `require` | `[moduleConfig.stepsPath, "src/stepDefinitions/*.js", "src/hooks/hooks.js"]` | Support code paths (CommonJS). |
297
- | `pomPath` | `moduleConfig.pomPath` | Path to Page Object Models. |
298
- | `import` | `[]` | Support code paths. |
299
- | `testPercentage` | `0` | Define test coverage percentage |
300
- | `report` | `false` | Generate report |
301
- | `reportSuccess` | `false` | Add screenshots and video records for also success test cases |
302
- | `trace` | `false` | Enable trace |
303
- | `reportWithTrace` | `false` | Add trace to the report |
304
- | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Formatter names/paths. |
305
- | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
306
- | `parallel` | `1` | Number of parallel workers. |
307
- | `dryRun` | `false` | Prepare test run without execution. |
308
- | `failFast` | `false` | Stop on first test failure. |
309
- | `forceExit` | `false` | Force `process.exit()` after tests. |
310
- | `strict` | `true` | Fail on pending steps. |
311
- | `backtrace` | `false` | Show full backtrace for errors. |
312
- | `tags` | `""` | Tag expression to filter scenarios. |
313
- | `name` | `[]` | Run scenarios matching regex. |
314
- | `order` | `"defined"` | Run order (defined/random). |
315
- | `language` | `"en"` | Default feature file language. |
316
- | `loader` | `[]` | Module loader specifications. |
317
- | `requireModule` | `[]` | Transpilation module names. |
318
- | `retry` | `0` | Retry attempts for failing tests. |
319
- | `retryTagFilter` | `""` | Tag expression for retries. |
320
- | `publish` | `false` | Publish to cucumber.io. |
321
- | `worldParameters` | `{}` | Custom world parameters. |
322
-
323
- ---
324
-
325
- ## 🌍 Environment Configuration
326
-
327
- | **Option** | **Default Value** | **Description** |
328
- | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
329
- | `env` | `""` | Environment configuration. Should match the name with the baseURL object, like "dev" |
330
- | `baseURL` | `""` | Base URL for API requests. Can be object {"dev":"dev-api.com", "pre":"pre-api.com"}, or string "dev-api.com" |
331
-
332
-
333
- ### Environment Variables Configuration
334
-
335
- Artes supports environment-specific configurations through environment variables. This feature allows to manage different settings for environments.
336
-
337
- ### Setting Up Environment Variables
338
-
339
- 1. **Configure Environment in artes.config.js:**
340
- ```javascript
341
- module.exports = {
342
- baseURL: {
343
- dev: "https://dev.alma.az",
344
- pre: "https://pre.alma.az",
345
- prod: "https://api.alma.az"
346
- },
347
- env: "dev", // Specify which environment to use
348
- };
349
- ```
350
-
351
- **Alternative single URL configuration:**
352
- ```javascript
353
- module.exports = {
354
- baseURL: "https://api.alma.az", // Direct string URL
355
- };
356
- ```
357
-
358
- 2. **Create Environment Variable Files:**
359
- Create JSON files under `src/tests/environment-variables/` folder with names matching your environment:
360
-
361
- **dev.env.json:**
362
- ```json
363
- {
364
- "api_key": "dev-api-key-12345",
365
- "auth_token": "dev-auth-token",
366
- "database_url": "dev-db.example.com",
367
- "timeout": 5000,
368
- "headers": {
369
- "Authorization": "Bearer dev-token",
370
- "Content-Type": "application/json"
371
- }
372
- }
373
- ```
374
-
375
- ### How It Works
376
-
377
- 1. **Environment Detection:** When Artes runs, it reads the `env` value from `artes.config.js`
378
- 2. **Base URL Resolution:** If `baseURL` is an object, it uses the environment key to find the corresponding URL. If `baseURL` is a string, it uses it directly
379
- 3. **Variable Loading:** Artes looks for a JSON file matching the environment name in `src/tests/environment-variables/`
380
- 4. **Runtime Access:** All variables from the environment file become available during test execution
381
-
382
- ### Important Notes
383
-
384
- - ⚠️ **Base URLs must be defined in `artes.config.js`** - they cannot be set in the environment variable JSON files
385
- - 📁 Environment variable files should be placed in `src/tests/environment-variables/`
386
- - 🏷️ File names must follow the format `{env}.env.json` (e.g., `dev.env.json` for `env: "dev"`)
387
- - 🔄 Variables are loaded into variable storage and can be accessed during test runs
388
- - 🌐 Use environment variables for headers, API keys, timeouts, and other environment-specific configurations
389
-
390
- ---
391
-
392
- ### Browser Configuration
393
-
394
- | Option | Default Value | Description |
395
- | ------------- | ------------------------------ | ------------------------------------------------------ |
396
- | `browserType` | `"chrome"` | Browser type (`"chrome"`, `"firefox"`, or `"webkit"`). |
397
- | `viewport` | `{ width: 1280, height: 720 }` | Browser viewport size. |
398
- | `headless` | `true` | Run browser in headless mode (`true` or `false`). |
399
-
400
- ## 📊 Report Generation
401
-
402
- Artes can generate Allure reports. After running tests with the `-r` flag, the reports will be stored in the `report` folder in HTML format. You can view them in your browser after the tests complete.
403
-
404
- ---
405
-
406
- ## 🐳 Docker Image for CI/CD
407
-
408
- A Docker image `vahidaghayev/artes` is available for running Artes in CI/CD pipelines. This image includes:
409
-
410
- - **Playwright Browsers**: Pre-installed to support UI testing.
411
- - **Xvfb**: Enables running UI tests with video recording in a virtual display.
412
-
413
- ### Recommended Settings for Best Quality
414
-
415
- To achieve the best video recording quality, use the following command:
416
-
417
- ```bash
418
- xvfb-run -a --server-args="-screen 0 3840x1180x24" --auto-servernum npx artes --width 1600 --height 900
419
- ```
420
-
421
- ### Playwright Version
422
-
423
- The Docker image uses Playwright version `1.52.0`.
424
-
425
- This setup ensures smooth execution of tests CI/CD environments.
426
-
427
- ---
428
-
429
- ## 👍 Good To Use
430
-
431
- If you don't use the -c or --create option that the package offers, save the file below under the `.vscode` folder:
432
-
433
- - Those configurations will help autocomplete both predefined and custom step definitions in your features file
434
-
435
- **extensions.json**
436
-
437
- ```json
438
- {
439
- "recommendations": ["CucumberOpen.cucumber-official"]
440
- }
441
- ```
442
-
443
- **settings.json**
444
-
445
- ```json
446
- {
447
- "cucumber.glue": [
448
- "tests/steps/*.{ts,js}",
449
- "node_modules/artes/src/tests/stepDefinitions/*.{ts,js}"
450
- ],
451
- "cucumber.features": ["tests/features/*.features"],
452
- "cucumberautocomplete.syncfeatures": true,
453
- "cucumberautocomplete.strictGherkinCompletion": true
454
- }
455
- ```
456
-
457
- ---
458
-
1
+ <p align="center">
2
+ <img alt="artesLogo" src="https://github.com/user-attachments/assets/e0641011-0e96-4330-8ad5-935b395b0838" width="280">
3
+ </p>
4
+
5
+ <h1 align="center">Artes</h1>
6
+
7
+ ## 🚀 Summary
8
+
9
+ Artes is a test runner for Playwright that executes [predefined Cucumber tests](./docs/stepDefinitions.md) and can generate Allure reports for test results. It simplifies setting up Playwright with Cucumber in your automation workflow. With Artes, you can easily run tests without writing step definitions, generate reports, and customize your testing environment.
10
+
11
+ ![artes demonstration](https://github.com/user-attachments/assets/c46172f7-103d-45d1-a37d-8d4267df0967)
12
+
13
+ ## 🧑‍💻 Installation
14
+
15
+ You can install **Artes** via npm. To install it globally**(RECOMMENDED)**, run the following command:
16
+
17
+ ```bash
18
+ npm install -g artes
19
+ ```
20
+
21
+ To install it locally in your project, run:
22
+
23
+ ```bash
24
+ npm install artes
25
+ ```
26
+
27
+ Once installed, you can run **Artes** using:
28
+
29
+ ```bash
30
+ npx artes [options]
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 💡 Usage
36
+
37
+ **Artes** has following CLI options:
38
+
39
+ ```bash
40
+ npx artes [options]
41
+ ```
42
+
43
+ ### Options
44
+
45
+ | Option | Description | Usage Example |
46
+ | ------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
47
+ | 🆘 `-h, --help` | Show the usage options | `artes -h` or `artes --help` |
48
+ | 🏷️ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version` |
49
+ | 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
50
+ | ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
51
+ | 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
52
+ | `--reportSuccess` | Add screenshots and video records for also Success test cases | `artes --reportSuccess` |
53
+ | `--trace` | Enable tracing | `artes --trace ` |
54
+ | `-rwt, --reportWithTrace` | Add trace to the report | `artes -rwt` or `artes --reportWithTrace` |
55
+ | 📁 `--features` | Specify one or more feature files' relative paths to run (comma-separated) | `artes --features "tests/features/Alma,tests/features/Banan.feature"` |
56
+ | 📜 `--stepDef` | Specify one or more step definition files' relative paths to use (comma-separated) | `artes --stepDef "tests/steps/login.js,tests/steps/home.js"` |
57
+ | 🔖 `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
58
+ | 🌐 `--env` | Set the environment for the test run | `artes --env "dev"` |
59
+ | 🕶️ `--headless` | Run browser in headless mode | `artes --headless` |
60
+ | ⚡ `--parallel` | Run tests in parallel mode | `artes --parallel 2` |
61
+ | 🔁 `--retry` | Retry failed tests | `artes --retry 3` |
62
+ | 🎭 `--dryRun` | Perform a dry run without executing tests | `artes --dryRun` |
63
+ | 📈 `--percentage` | Set minimum success percentage to pass test run (default is 0) | `artes --percentage 85` |
64
+ | 🌍 `--browser` | Specify browser to use (`chromium`, `firefox`, or `webkit`) | `artes --browser chromium` |
65
+ | 🔗 `--baseURL` | Set base URL for the tests | `artes --baseURL "https://example.com"` |
66
+ | 🖥️ `--maxScreen` | Maximize browser window on launch | `artes --maxScreen` |
67
+ | 📏 `--width` | Set browser width (default is 1280) | `artes --width 1920` |
68
+ | 📐 `--height` | Set browser height (default is 720) | `artes --height 1080` |
69
+ | ⏱️ `--timeout` | Set timeout for each test step in seconds (default is 30 seconds) | `artes --timeout 10` |
70
+ | 🐢 `--slowMo` | Slow down text execution for clear view (default: 0 seconds) | `artes --slowMo 1` |
71
+
72
+ \*\* To just run the tests: <br>
73
+ Globally: artes <br>
74
+ Locally: npx artes
75
+
76
+ ---
77
+
78
+ ## 🎯 Best Practices
79
+
80
+ - **Global Installation:**
81
+ For ease of use, it's recommended that Artes be installed globally. You can do this by running the following command:
82
+
83
+ ```bash
84
+ npm install -g artes
85
+ ```
86
+
87
+ - **Project Creation (Recommended):**
88
+ To create a new project with Artes, use the `-c` flag. This will automatically set up the folder structure and configuration for you. Run the command:
89
+
90
+ ```bash
91
+ artes -c
92
+ ```
93
+
94
+ 🗂️ Example Project Structure: <br/>
95
+ After running the `-c` flag to create a new project, the structure will look like this:
96
+
97
+ ```
98
+ /artes (Project Name)
99
+ /tests
100
+ /features
101
+ (Your feature files here)
102
+ /POMs // Optional
103
+ (POM JSON file here)
104
+ /steps // For custom steps
105
+ (Your step definition JS files here)
106
+ artes.config.js
107
+ /report
108
+ (Generated Allure report HTML here)
109
+ ```
110
+
111
+ **If you choose not to use the `-c` flag**, you can still download Artes to your testing project and use the prepared steps by running:
112
+
113
+ ```bash
114
+ npx artes
115
+ ```
116
+
117
+ You must customize the paths of features, steps, and other configurations by editing the `artes.config.js` file located inside your project folder (or create it).
118
+
119
+ For example:
120
+
121
+ ```javascript
122
+ module.exports = {
123
+ paths: ["tests/features/"], // Custom path for feature files
124
+ require: ["tests/steps/*.js"], // Custom path for step definitions files
125
+ pomPath: "tests/POMS/*.js", // Custom path for POM files
126
+ };
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 📝 Writing Feature Files and POM Files
132
+
133
+ Artes simplifies your test writing with structured feature files and organized Page Object Models (POM). Here’s how you can create them:
134
+
135
+ ### 1. 📄 Feature File Structure
136
+
137
+ ```gherkin
138
+ Feature: Searching on Google 🔍
139
+ Scenario Outline: Search for a term on Google
140
+ Given User is on "https://www.google.com/" page
141
+ When User types "alma" in "google_search_input"
142
+ And User clicks "google_search_button"
143
+ And User waits 10 seconds
144
+ Then "google_text" should have "Alma" text
145
+ ```
146
+
147
+ - **Feature**: Describes the main feature being tested (e.g., Google search).
148
+ - **Scenario Outline**: Defines a test case with steps.
149
+ - **Steps**: Use `Given`, `When`, `And`, `Then` keywords to describe actions and expectations.
150
+ - **Selectors**: The element names (e.g., `google_search_input`, `google_search_button`) map to the POM file or can be defined directly.
151
+
152
+ ### 2. 📂 POM File Example
153
+
154
+ ```json
155
+ {
156
+ "google_search_input": { "selector": "#APjFqb" },
157
+ "google_search_button": {
158
+ "selector": "input.gNO89b"
159
+ },
160
+ "google_text": {
161
+ "selector": "#rso div h3",
162
+ "waitTime": 5 //seconds
163
+ }
164
+ }
165
+ ```
166
+
167
+ - 📑 Using POM File is optional but it is **RECOMMENDED**
168
+ - 🔗 Using Selector in Feature File is possible
169
+ ```gherkin
170
+ When User types "alma" in "#APjFqb"
171
+ ```
172
+ - 🐍 It is good to use snake_case for element names
173
+ - ⏳ "waitTime" is to define custom wait for elements, but the feature currently under development
174
+ "selector" must be used if "waitTime" is used, but when using only selector is not needed mention in "selector"
175
+
176
+ ---
177
+
178
+ ## 🛠️ Customization
179
+
180
+ ## ✍️ Writing Custom Step Definitions
181
+
182
+ Artes allows you to extend its functionality by writing custom step definitions. Here's how you can do it:
183
+
184
+ ### Import Required APIs
185
+
186
+ ```javascript
187
+ const {
188
+ expect,
189
+ Given,
190
+ When,
191
+ Then,
192
+ element,
193
+ context,
194
+ keyboard,
195
+ mouse,
196
+ frame,
197
+ assert,
198
+ elementInteractions,
199
+ } = require("artes"); // Common JS
200
+ import { expect, Given, When, Then, element, context } from "artes"; // ES Modules (Do not RECOMMENDED)
201
+ ```
202
+
203
+ - **`Given`, `When`, `Then`**: These define your steps in Cucumber syntax. Example:
204
+
205
+ ```javascript
206
+ Given("User is on the login page", async () => {
207
+ await context.page.navigateTo("https://example.com/login");
208
+ });
209
+ ```
210
+
211
+ - **`page`**: Provides higher-level page actions such as navigation and waiting(Same as PlayWright). Examples:
212
+ - Navigate to a URL:
213
+ ```javascript
214
+ await context.page.navigate("https://example.com");
215
+ ```
216
+ - Wait for a selector:
217
+ ```javascript
218
+ await context.page.waitForSelector("#loadingSpinner");
219
+ ```
220
+ - **`request`**: Use for sending HTTP requests. _(Note: This feature is currently under development.)_
221
+
222
+ - **`element`**: Use for interacting with elements on the web page. Examples:
223
+ - Clicking a button:
224
+ ```javascript
225
+ await element("#submitButton").click();
226
+ ```
227
+ - Filling an input:
228
+ ```javascript
229
+ await element("#username").fill("testUser");
230
+ ```
231
+ - **`expect`**: Use for assertions in your steps. For example:
232
+ ```javascript
233
+ expect(actualValue).toBe(expectedValue);
234
+ expect(element("Page_Title")).toHaveText(expectedValue);
235
+ ```
236
+
237
+ ## 📋 Simplified Functions
238
+
239
+ If you don't want to deal with Playwright methods directly, you can simply use the following predefined actions methods by import them:
240
+
241
+ ```javascript
242
+ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
243
+ ```
244
+
245
+ - **Mouse Actions:**
246
+ `mouse.click(element)`
247
+
248
+ - **Keyboard Actions:**
249
+ `keyboard.press(key)`
250
+
251
+ - **Element Interactions:**
252
+ `elementInteractions.isChecked()`
253
+
254
+ - **Assertions:**
255
+ `assert.shouldBeTruthy(element)`
256
+
257
+ - **Frame Actions:**
258
+ `frame.first()`
259
+
260
+ - **API Actions:**
261
+ `api.post(url, payload, requestDataType)`
262
+
263
+ ---
264
+
265
+ For a detailed explanation of each function, please refer to the [function definitions](./docs/functionDefinitions.md).
266
+
267
+ ---
268
+
269
+ ### Example of a Custom Step Definition
270
+
271
+ ```javascript
272
+ const { Given, When, Then, expect, element, page } = require("artes");
273
+
274
+ Given("User is on the home page", async () => {
275
+ await page.navigate("https://example.com");
276
+ });
277
+
278
+ When("User clicks the login button", async () => {
279
+ await element("#loginButton").click();
280
+ });
281
+
282
+ Then("User should see the login form", async () => {
283
+ expect(element("#loginForm")).toBeVisible(true);
284
+ });
285
+ ```
286
+
287
+ ## ⚙️ Configuration
288
+
289
+ You can configure Artes by editing the `artes.config.js` file. Below are the default configuration options with explanations:
290
+
291
+ | **Option** | **Default Value** | **Description** |
292
+ | ----------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------- |
293
+ | `timeout` | `30` | Default timeout in seconds. |
294
+ | `slowMo` | `0` | Default slow motion in seconds |
295
+ | `paths` | `[moduleConfig.featuresPath]` | Paths to feature files. |
296
+ | `require` | `[moduleConfig.stepsPath, "src/stepDefinitions/*.js", "src/hooks/hooks.js"]` | Support code paths (CommonJS). |
297
+ | `pomPath` | `moduleConfig.pomPath` | Path to Page Object Models. |
298
+ | `import` | `[]` | Support code paths. |
299
+ | `testPercentage` | `0` | Define test coverage percentage |
300
+ | `report` | `false` | Generate report |
301
+ | `reportSuccess` | `false` | Add screenshots and video records for also success test cases |
302
+ | `trace` | `false` | Enable trace |
303
+ | `reportWithTrace` | `false` | Add trace to the report |
304
+ | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Formatter names/paths. |
305
+ | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
306
+ | `parallel` | `1` | Number of parallel workers. |
307
+ | `dryRun` | `false` | Prepare test run without execution. |
308
+ | `failFast` | `false` | Stop on first test failure. |
309
+ | `forceExit` | `false` | Force `process.exit()` after tests. |
310
+ | `strict` | `true` | Fail on pending steps. |
311
+ | `backtrace` | `false` | Show full backtrace for errors. |
312
+ | `tags` | `""` | Tag expression to filter scenarios. |
313
+ | `name` | `[]` | Run scenarios matching regex. |
314
+ | `order` | `"defined"` | Run order (defined/random). |
315
+ | `language` | `"en"` | Default feature file language. |
316
+ | `loader` | `[]` | Module loader specifications. |
317
+ | `requireModule` | `[]` | Transpilation module names. |
318
+ | `retry` | `0` | Retry attempts for failing tests. |
319
+ | `retryTagFilter` | `""` | Tag expression for retries. |
320
+ | `publish` | `false` | Publish to cucumber.io. |
321
+ | `worldParameters` | `{}` | Custom world parameters. |
322
+
323
+ ---
324
+
325
+ ## 🌍 Environment Configuration
326
+
327
+ | **Option** | **Default Value** | **Description** |
328
+ | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
329
+ | `env` | `""` | Environment configuration. Should match the name with the baseURL object, like "dev" |
330
+ | `baseURL` | `""` | Base URL for API requests. Can be object {"dev":"dev-api.com", "pre":"pre-api.com"}, or string "dev-api.com" |
331
+
332
+
333
+ ### Environment Variables Configuration
334
+
335
+ Artes supports environment-specific configurations through environment variables. This feature allows to manage different settings for environments.
336
+
337
+ ### Setting Up Environment Variables
338
+
339
+ 1. **Configure Environment in artes.config.js:**
340
+ ```javascript
341
+ module.exports = {
342
+ baseURL: {
343
+ dev: "https://dev.alma.az",
344
+ pre: "https://pre.alma.az",
345
+ prod: "https://api.alma.az"
346
+ },
347
+ env: "dev", // Specify which environment to use
348
+ };
349
+ ```
350
+
351
+ **Alternative single URL configuration:**
352
+ ```javascript
353
+ module.exports = {
354
+ baseURL: "https://api.alma.az", // Direct string URL
355
+ };
356
+ ```
357
+
358
+ 2. **Create Environment Variable Files:**
359
+ Create JSON files under `src/tests/environment_variables/` folder with names matching your environment:
360
+
361
+ **dev.env.json:**
362
+ ```json
363
+ {
364
+ "api_key": "dev-api-key-12345",
365
+ "auth_token": "dev-auth-token",
366
+ "database_url": "dev-db.example.com",
367
+ "timeout": 5000,
368
+ "headers": {
369
+ "Authorization": "Bearer dev-token",
370
+ "Content-Type": "application/json"
371
+ }
372
+ }
373
+ ```
374
+
375
+ ### How It Works
376
+
377
+ 1. **Environment Detection:** When Artes runs, it reads the `env` value from `artes.config.js`
378
+ 2. **Base URL Resolution:** If `baseURL` is an object, it uses the environment key to find the corresponding URL. If `baseURL` is a string, it uses it directly
379
+ 3. **Variable Loading:** Artes looks for a JSON file matching the environment name in `src/tests/environment_variables/`
380
+ 4. **Runtime Access:** All variables from the environment file become available during test execution
381
+
382
+ ### Important Notes
383
+
384
+ - ⚠️ **Base URLs must be defined in `artes.config.js`** - they cannot be set in the environment variable JSON files
385
+ - 📁 Environment variable files should be placed in `src/tests/environment_variables/`
386
+ - 🏷️ File names must follow the format `{env}.env.json` (e.g., `dev.env.json` for `env: "dev"`)
387
+ - 🔄 Variables are loaded into variable storage and can be accessed during test runs
388
+ - 🌐 Use environment variables for headers, API keys, timeouts, and other environment-specific configurations
389
+
390
+ ---
391
+
392
+ ### Browser Configuration
393
+
394
+ | Option | Default Value | Description |
395
+ | ------------- | ------------------------------ | ------------------------------------------------------ |
396
+ | `browserType` | `"chrome"` | Browser type (`"chrome"`, `"firefox"`, or `"webkit"`). |
397
+ | `viewport` | `{ width: 1280, height: 720 }` | Browser viewport size. |
398
+ | `headless` | `true` | Run browser in headless mode (`true` or `false`). |
399
+
400
+ ## 📊 Report Generation
401
+
402
+ Artes can generate Allure reports. After running tests with the `-r` flag, the reports will be stored in the `report` folder in HTML format. You can view them in your browser after the tests complete.
403
+
404
+ ---
405
+
406
+ ## 🐳 Docker Image for CI/CD
407
+
408
+ A Docker image `vahidaghayev/artes` is available for running Artes in CI/CD pipelines. This image includes:
409
+
410
+ - **Playwright Browsers**: Pre-installed to support UI testing.
411
+ - **Xvfb**: Enables running UI tests with video recording in a virtual display.
412
+
413
+ ### Recommended Settings for Best Quality
414
+
415
+ To achieve the best video recording quality, use the following command:
416
+
417
+ ```bash
418
+ xvfb-run -a --server-args="-screen 0 3840x1180x24" --auto-servernum npx artes --width 1600 --height 900
419
+ ```
420
+
421
+ ### Playwright Version
422
+
423
+ The Docker image uses Playwright version `1.52.0`.
424
+
425
+ This setup ensures smooth execution of tests CI/CD environments.
426
+
427
+ ---
428
+
429
+ ## 👍 Good To Use
430
+
431
+ If you don't use the -c or --create option that the package offers, save the file below under the `.vscode` folder:
432
+
433
+ - Those configurations will help autocomplete both predefined and custom step definitions in your features file
434
+
435
+ **extensions.json**
436
+
437
+ ```json
438
+ {
439
+ "recommendations": ["CucumberOpen.cucumber-official"]
440
+ }
441
+ ```
442
+
443
+ **settings.json**
444
+
445
+ ```json
446
+ {
447
+ "cucumber.glue": [
448
+ "tests/steps/*.{ts,js}",
449
+ "node_modules/artes/src/tests/stepDefinitions/*.{ts,js}"
450
+ ],
451
+ "cucumber.features": ["tests/features/*.features"],
452
+ "cucumberautocomplete.syncfeatures": true,
453
+ "cucumberautocomplete.strictGherkinCompletion": true
454
+ }
455
+ ```
456
+
457
+ ---
458
+
459
459
  ## 🧑‍💻 Have a Good Testing