artes 1.0.61 → 1.0.63

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 CHANGED
@@ -242,9 +242,12 @@ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
242
242
  - **Frame Actions:**
243
243
  `frame.first()`
244
244
 
245
+ - **API Actions:**
246
+ `api.post(url, payload, requestDataType)`
247
+
245
248
  ---
246
249
 
247
- For a detailed explanation of each function, please refer to the [functionDefinitions.md](./docs/functionDefinitions.md).
250
+ For a detailed explanation of each function, please refer to the [function definitions](./docs/functionDefinitions.md).
248
251
 
249
252
  ---
250
253
 
@@ -270,26 +273,39 @@ Then("User should see the login form", async () => {
270
273
 
271
274
  You can configure Artes by editing the `artes.config.js` file. Below are the default configuration options with explanations:
272
275
 
273
- | **Option** | **Default Value** | **Description** |
274
- | ---------------- | ---------------------------------------------------- | ----------------------------------- |
275
- | `headless` | `true` | Run in headless browser mode. |
276
- | `paths` | `["tests/features/"]` | Array of paths to feature files. |
277
- | `pomPath` | `"tests/POMs/*.json"` | Path to Page Object Models. |
278
- | `steps` | `"tests/steps/*.js"` | string - Step definitions files. |
279
- | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Array of formatter names/paths. |
280
- | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
281
- | `parallel` | `1` | Number of parallel workers. |
282
- | `tags` | `""` | Tag expression to filter scenarios. |
283
- | `language` | `"en"` | Default language for feature files. |
284
- | `order` | `"defined"` | Run order (defined or random). |
285
- | `dryRun` | `false` | Prepare test run without execution. |
286
- | `failFast` | `false` | Stop on first failure. |
287
- | `forceExit` | `false` | Force `process.exit()` after tests. |
288
- | `retry` | `0` | Retry attempts for failing tests. |
289
- | `retryTagFilter` | `""` | Tag expression for retries. |
290
- | `strict` | `true` | Fail on pending steps. |
291
- | `backtrace` | `false` | Show full backtrace for errors. |
292
- | `publish` | `false` | Publish results to `cucumber.io`. |
276
+
277
+ | **Option** | **Default Value** | **Description** |
278
+ | ----------------- | ---------------------------------------------------- | ----------------------------------------------------- |
279
+ | `timeout` | `30` | Default timeout in milliseconds. |
280
+ | `paths` | `[moduleConfig.featuresPath]` | Paths to feature files. |
281
+ | `require` | `[moduleConfig.stepsPath, "src/stepDefinitions/*.js", "src/hooks/hooks.js"]` | Support code paths (CommonJS). |
282
+ | `pomPath` | `moduleConfig.pomPath` | Path to Page Object Models. |
283
+ | `import` | `[]` | Support code paths. |
284
+ | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Formatter names/paths. |
285
+ | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
286
+ | `parallel` | `1` | Number of parallel workers. |
287
+ | `dryRun` | `false` | Prepare test run without execution. |
288
+ | `failFast` | `false` | Stop on first test failure. |
289
+ | `forceExit` | `false` | Force `process.exit()` after tests. |
290
+ | `strict` | `true` | Fail on pending steps. |
291
+ | `backtrace` | `false` | Show full backtrace for errors. |
292
+ | `tags` | `""` | Tag expression to filter scenarios. |
293
+ | `name` | `[]` | Run scenarios matching regex. |
294
+ | `order` | `"defined"` | Run order (defined/random). |
295
+ | `language` | `"en"` | Default feature file language. |
296
+ | `loader` | `[]` | Module loader specifications. |
297
+ | `requireModule` | `[]` | Transpilation module names. |
298
+ | `retry` | `0` | Retry attempts for failing tests. |
299
+ | `retryTagFilter` | `""` | Tag expression for retries. |
300
+ | `publish` | `false` | Publish to cucumber.io. |
301
+ | `worldParameters` | `{}` | Custom world parameters. |
302
+
303
+ ### Environment Configuration
304
+
305
+ | **Option** | **Default Value** | **Description** |
306
+ | ----------- | ----------------- | ---------------------------------- |
307
+ | `env` | `""` | Environment configuration. Should match the name with the baseURL object, like "dev" |
308
+ | `baseURL` | `""` | Base URL for API requests. Can be object {"dev":"dev-api.com", "pre":"pre-api.com"}, or string "dev-api.com" |
293
309
 
294
310
  ---
295
311
 
@@ -3,7 +3,7 @@
3
3
  If you don't want to deal with Playwright methods directly, you can simply use the following predefined actions methods by import them:
4
4
 
5
5
  ```javascript
6
- const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
6
+ const { mouse, keyboard, frame, elementInteractions, page, api } = require("artes");
7
7
  ```
8
8
 
9
9
  - **Mouse Actions:**
@@ -21,6 +21,9 @@ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
21
21
  - **Frame Actions:**
22
22
  `frame.first()`
23
23
 
24
+ - **API Actions:**
25
+ `api.post(url, payload, requestDataType)`
26
+
24
27
  ---
25
28
 
26
29
  ## Table of Contents
@@ -30,6 +33,8 @@ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
30
33
  - [Assertions Functions](#assertions-functions)
31
34
  - [Page Functions](#page-functions)
32
35
  - [Frame Functions](#frame-functions)
36
+ - [API Functions](#api-object-methods)
37
+ - [Usage Examples](#usage-examples)
33
38
 
34
39
  ### **Mouse Functions**
35
40
 
@@ -440,7 +445,7 @@ await wait(time);
440
445
 
441
446
  ---
442
447
 
443
- ### **Assertion Functions**
448
+ ### **Assertions Functions**
444
449
 
445
450
  #### `shouldBeAttached(selector)`
446
451
 
@@ -2099,3 +2104,240 @@ Returns elements with the specified `data-testid` attribute.
2099
2104
  ```javascript
2100
2105
  const element = await getByTestId("submit-button");
2101
2106
  ```
2107
+
2108
+ ## API Object Methods
2109
+
2110
+ The `api` object provides methods for making HTTP requests with automatic URL resolution, payload processing, and response handling.
2111
+
2112
+ ### `api.get(url, payload)`
2113
+
2114
+ Makes a GET request to the specified URL.
2115
+
2116
+ **Parameters:**
2117
+ - `url` (string): The target URL (supports variable resolution)
2118
+ - `payload` (string, optional): JSON string containing headers and other request options
2119
+
2120
+ **Returns:** Promise that resolves when the request completes
2121
+
2122
+ **Example:**
2123
+ ```javascript
2124
+ await api.get("https://api.example.com/users", JSON.stringify({
2125
+ headers: { "Authorization": "Bearer {{token}}" }
2126
+ }));
2127
+ ```
2128
+
2129
+ ### `api.head(url)`
2130
+
2131
+ Makes a HEAD request to the specified URL.
2132
+
2133
+ **Parameters:**
2134
+ - `url` (string): The target URL (supports variable resolution)
2135
+
2136
+ **Returns:** Promise that resolves when the request completes
2137
+
2138
+ **Example:**
2139
+ ```javascript
2140
+ await api.head("https://api.example.com/status");
2141
+ ```
2142
+
2143
+ ### `api.post(url, payload, requestDataType)`
2144
+
2145
+ Makes a POST request to the specified URL.
2146
+
2147
+ **Parameters:**
2148
+ - `url` (string): The target URL (supports variable resolution)
2149
+ - `payload` (string): JSON string containing headers, body, and other request options
2150
+ - `requestDataType` (string, optional): Request data type ("multipart" for form data, default for JSON)
2151
+
2152
+ **Returns:** Promise that resolves when the request completes
2153
+
2154
+ **Example:**
2155
+ ```javascript
2156
+ // Regular POST request
2157
+ await api.post("https://api.example.com/users", JSON.stringify({
2158
+ headers: { "Content-Type": "application/json" },
2159
+ body: { name: "John", email: "john@example.com" }
2160
+ }));
2161
+
2162
+ // Multipart form data
2163
+ await api.post("https://api.example.com/upload", JSON.stringify({
2164
+ headers: {},
2165
+ body: { file: "/path/to/file.pdf", description: "Document upload" }
2166
+ }), "multipart");
2167
+ ```
2168
+
2169
+ ### `api.put(url, payload, requestDataType)`
2170
+
2171
+ Makes a PUT request to the specified URL.
2172
+
2173
+ **Parameters:**
2174
+ - `url` (string): The target URL (supports variable resolution)
2175
+ - `payload` (string): JSON string containing headers, body, and other request options
2176
+ - `requestDataType` (string, optional): Request data type ("multipart" for form data, default for JSON)
2177
+
2178
+ **Returns:** Promise that resolves when the request completes
2179
+
2180
+ **Example:**
2181
+ ```javascript
2182
+ await api.put("https://api.example.com/users/{{userId}}", JSON.stringify({
2183
+ headers: { "Content-Type": "application/json" },
2184
+ body: { name: "Updated Name" }
2185
+ }));
2186
+ ```
2187
+
2188
+ ### `api.patch(url, payload, requestDataType)`
2189
+
2190
+ Makes a PATCH request to the specified URL.
2191
+
2192
+ **Parameters:**
2193
+ - `url` (string): The target URL (supports variable resolution)
2194
+ - `payload` (string): JSON string containing headers, body, and other request options
2195
+ - `requestDataType` (string, optional): Request data type ("multipart" for form data, default for JSON)
2196
+
2197
+ **Returns:** Promise that resolves when the request completes
2198
+
2199
+ **Example:**
2200
+ ```javascript
2201
+ await api.patch("https://api.example.com/users/{{userId}}", JSON.stringify({
2202
+ headers: { "Content-Type": "application/json" },
2203
+ body: { email: "newemail@example.com" }
2204
+ }));
2205
+ ```
2206
+
2207
+ ### `api.delete(url, payload)`
2208
+
2209
+ Makes a DELETE request to the specified URL.
2210
+
2211
+ **Parameters:**
2212
+ - `url` (string): The target URL (supports variable resolution)
2213
+ - `payload` (string, optional): JSON string containing headers and other request options
2214
+
2215
+ **Returns:** Promise that resolves when the request completes
2216
+
2217
+ **Example:**
2218
+ ```javascript
2219
+ await api.delete("https://api.example.com/users/{{userId}}", JSON.stringify({
2220
+ headers: { "Authorization": "Bearer {{token}}" }
2221
+ }));
2222
+ ```
2223
+
2224
+ ### `api.vars()`
2225
+
2226
+ Returns the current context variables object.
2227
+
2228
+ **Returns:** Object containing all stored variables
2229
+
2230
+ **Example:**
2231
+ ```javascript
2232
+ const currentVars = api.vars();
2233
+ console.log(currentVars); // { token: "abc123", userId: "user456" }
2234
+ ```
2235
+
2236
+
2237
+ ## Static Methods
2238
+
2239
+ ### `extractVarsFromResponse(vars, customVarName)`
2240
+
2241
+ Extracts variables from the response body using dot notation paths.
2242
+
2243
+ **Parameters:**
2244
+ - `vars` (string): Comma-separated list of dot notation paths (e.g., "user.id,user.name")
2245
+ - `customVarName` (string, optional): Custom variable name to use instead of auto-generated names
2246
+
2247
+ **Behavior:**
2248
+ - Extracts values from `context.response.responseBody` using specified paths
2249
+ - Saves extracted values as variables using `saveVar()`
2250
+ - If `customVarName` is provided, uses it; otherwise generates camelCase names
2251
+
2252
+ **Example:**
2253
+ ```javascript
2254
+ // Response body: { user: { id: 123, profile: { name: "John" } } }
2255
+ extractVarsFromResponse("user.id,user.profile.name");
2256
+ // Creates variables: userId = 123, userProfileName = "John"
2257
+
2258
+ extractVarsFromResponse("user.id", "currentUserId");
2259
+ // Creates variable: currentUserId = 123
2260
+ ```
2261
+
2262
+ ### `saveVar(value, customName, path)`
2263
+
2264
+ Saves a variable to the context with either a custom name or auto-generated camelCase name.
2265
+
2266
+ **Parameters:**
2267
+ - `value` (any): The value to store
2268
+ - `customName` (string, optional): Custom variable name
2269
+ - `path` (string): Dot notation path used for auto-generating variable name
2270
+
2271
+ **Behavior:**
2272
+ - If `customName` is provided, uses it as the variable name
2273
+ - Otherwise, converts dot notation path to camelCase (e.g., "user.profile.name" → "userProfileName")
2274
+
2275
+ ### `resolveVariable(template)`
2276
+
2277
+ Resolves variable placeholders in template strings using the format `{{variableName}}`.
2278
+
2279
+ **Parameters:**
2280
+ - `template` (string): Template string containing variable placeholders
2281
+
2282
+ **Returns:** String with variables resolved, or original value if not a string
2283
+
2284
+ **Example:**
2285
+ ```javascript
2286
+ // Assuming context.vars = { userId: "123", token: "abc" }
2287
+ resolveVariable("https://api.example.com/users/{{userId}}")
2288
+ // Returns: "https://api.example.com/users/123"
2289
+
2290
+ resolveVariable("Bearer {{token}}")
2291
+ // Returns: "Bearer abc"
2292
+ ```
2293
+
2294
+ ## Usage Examples
2295
+
2296
+ ### Basic API Usage
2297
+
2298
+ ```javascript
2299
+ // Set up variables
2300
+ context.vars.baseUrl = "https://api.example.com";
2301
+ context.vars.token = "your-auth-token";
2302
+
2303
+ // Make a GET request
2304
+ await api.get("{{baseUrl}}/users", JSON.stringify({
2305
+ headers: { "Authorization": "Bearer {{token}}" }
2306
+ }));
2307
+
2308
+ // Extract user ID from response
2309
+ extractVarsFromResponse("data.0.id", "firstUserId");
2310
+
2311
+ // Use extracted variable in subsequent request
2312
+ await api.get("{{baseUrl}}/users/{{firstUserId}}/profile");
2313
+ ```
2314
+
2315
+ ### File Upload Example
2316
+
2317
+ ```javascript
2318
+ await api.post("{{baseUrl}}/upload", JSON.stringify({
2319
+ headers: { "Authorization": "Bearer {{token}}" },
2320
+ body: {
2321
+ file: "/path/to/document.pdf",
2322
+ description: "Important document",
2323
+ metadata: { type: "legal", priority: "high" }
2324
+ }
2325
+ }), "multipart");
2326
+ ```
2327
+
2328
+ ### Variable Extraction and Chaining
2329
+
2330
+ ```javascript
2331
+ // Login request
2332
+ await api.post("{{baseUrl}}/auth/login", JSON.stringify({
2333
+ body: { username: "user@example.com", password: "password" }
2334
+ }));
2335
+
2336
+ // Extract token from login response
2337
+ extractVarsFromResponse("access_token", "authToken");
2338
+
2339
+ // Use token in protected endpoint
2340
+ await api.get("{{baseUrl}}/protected-data", JSON.stringify({
2341
+ headers: { "Authorization": "Bearer {{authToken}}" }
2342
+ }));
2343
+ ```
@@ -6,13 +6,17 @@
6
6
  - [Keyboard Actions](#keyboard-actions)
7
7
  - [Page Actions](#page-actions)
8
8
  - [Frame Actions](#frame-actions)
9
+ - [API Actions](#api-actions)
10
+ - [Variable Management](#variable-management)
11
+ - [Debugging / Console Output](#debugging--console-output)
12
+ - [Generic HTTP Request](#generic-http-request)
9
13
  - [Assertions](#assertions)
10
14
 
11
15
  ---
12
16
 
13
- ## Mouse Actions
17
+ # Mouse Actions
14
18
 
15
- ### Click Actions
19
+ ## Click Actions
16
20
 
17
21
  - User clicks `{string}`
18
22
  - User clicks `{string}` with force
@@ -24,7 +28,7 @@
24
28
  - User clicks `{string}` with button `{string}`
25
29
  - User clicks `{string}` with button `{string}` and force
26
30
 
27
- ### Double Click Actions
31
+ ## Double Click Actions
28
32
 
29
33
  - User double clicks `{string}`
30
34
  - User double clicks `{string}` with force
@@ -34,70 +38,70 @@
34
38
  - User double clicks at `{int}, {int}` coordinates with click count `{int}` and delay `{int}`
35
39
  - User double clicks at `{int}, {int}` coordinates with force
36
40
 
37
- ### Mouse Movement Actions
41
+ ## Mouse Movement Actions
38
42
 
39
43
  - User moves to `{int}, {int}` coordinates
40
44
  - User scrolls the mouse wheel at `{int}, {int}` coordinates
41
45
 
42
- ### Hover Actions
46
+ ## Hover Actions
43
47
 
44
48
  - User hovers over `{string}`
45
49
  - User hovers over `{string}` with force
46
50
  - User hovers over `{string}` at `{int}, {int}` position
47
51
  - User hovers over `{string}` at `{int}, {int}` position with force
48
52
 
49
- ### Focus Actions
53
+ ## Focus Actions
50
54
 
51
55
  - User focuses on `{string}`
52
56
  - User focuses on `{string}` with force
53
57
  - User focuses on `{string}` at `{int}, {int}` position
54
58
  - User focuses on `{string}` at `{int}, {int}` position with force
55
59
 
56
- ### Drag Actions
60
+ ## Drag Actions
57
61
 
58
62
  - User drags `{string}` to `{string}`
59
63
  - User drags `{string}` to `{int}, {int}` position
60
64
 
61
- ### Selection Actions
65
+ ## Selection Actions
62
66
 
63
67
  - User selects by value `{string}` from `{string}`
64
68
  - User selects by text `{string}` from `{string}`
65
69
 
66
- ### Checkbox Actions
70
+ ## Checkbox Actions
67
71
 
68
72
  - User checks `{string}`
69
73
  - User unchecks `{string}`
70
74
 
71
- ### Scroll Actions
75
+ ## Scroll Actions
72
76
 
73
77
  - User scrolls into view for `{string}`
74
78
 
75
79
  ---
76
80
 
77
- ## Keyboard Actions
81
+ # Keyboard Actions
78
82
 
79
- ### Press Actions
83
+ ## Press Actions
80
84
 
81
- - User presses `{string} on {string}`
85
+ - User presses `{string}` on `{string}`
82
86
  - User presses keys `{string}` sequentially on `{string}`
83
- - User presses keys `{string}` sequentially with delay `{int} on {string}`
87
+ - User presses keys `{string}` sequentially with delay `{int}` on `{string}`
84
88
 
85
- ### Input Actions
89
+ ## Input Actions
86
90
 
87
91
  - User types `{string}` in `{string}`
88
92
  - User types `{string}` with delay `{int}`
89
93
  - User inserts text `{string}`
90
94
  - User clears `{string}`
91
95
 
92
- ### Selection Actions
96
+ ## Selection Actions
93
97
 
94
98
  - User selects text in `{string}`
95
99
 
96
- ### File Input Actions
100
+ ## File Input Actions
97
101
 
98
102
  - User sets input files `{string}` for `{string}`
99
103
 
100
- ### Key State Actions
104
+ ## Key State Actions
101
105
 
102
106
  - User holds down `{string}`
103
107
  - User releases `{string}`
@@ -105,19 +109,19 @@
105
109
 
106
110
  ---
107
111
 
108
- ## Page Actions
112
+ # Page Actions
109
113
 
110
- ### Navigation Actions
114
+ ## Navigation Actions
111
115
 
112
116
  - User navigates to `{string}` page
113
117
  - User navigates previous page
114
118
  - User navigates next page
115
119
 
116
- ### URL Actions
120
+ ## URL Actions
117
121
 
118
122
  - User gets URL of page
119
123
 
120
- ### Wait Actions
124
+ ## Wait Actions
121
125
 
122
126
  - User waits `{int}` seconds
123
127
  - User waits `{int}` milliseconds
@@ -125,36 +129,113 @@
125
129
 
126
130
  ---
127
131
 
128
- ## Frame Actions
132
+ # Frame Actions
129
133
 
130
- ### Screenshot Actions
134
+ ## Screenshot Actions
131
135
 
132
136
  - User takes a screenshot of `{string}`
133
137
 
134
- ### Content and Locator Actions
138
+ ## Content and Locator Actions
135
139
 
136
140
  - User gets the content frame of `{string}`
137
141
  - User gets the frame locator of `{string}`
138
142
 
139
- ### Element Retrieval Actions
143
+ ## Element Retrieval Actions
140
144
 
141
- - User gets the `{int}th` element of `{string}`
145
+ - User gets the `{int} th` element of `{string}`
142
146
  - User gets the first element of `{string}`
143
147
  - User gets the last element of `{string}`
144
148
  - User filters elements of `{string}` with filter `{string}`
145
149
 
146
- ### Counting Actions
150
+ ## Counting Actions
147
151
 
148
152
  - User counts the elements of `{string}`
149
153
 
150
- ### Accessibility-Based Retrieval Actions
154
+ ## Accessibility-Based Retrieval Actions
151
155
 
152
156
  - User gets the element with alt text `{string}`
153
157
  - User gets the element with label `{string}`
154
158
  - User gets the element with placeholder `{string}`
155
159
  - User gets the element with role `{string}`
156
- - User gets the element with testI `{string}`
157
- - User gets the element with testII `{string}`
160
+ - User gets the element with testId `{string}`
161
+ - User gets the element with testId `{string}` (assuming you meant testId twice)
162
+
163
+ ---
164
+
165
+ # API Actions
166
+
167
+ ## GET Requests
168
+
169
+ - User sends GET request to `{string}`
170
+ - User sends GET request to `{string}` with payload:
171
+ - User sends GET request to `{string}` and saves `{string}` variables
172
+ - User sends GET request to `{string}` with payload and saves `{string}` variables
173
+
174
+ ## HEAD Requests
175
+
176
+ - User sends HEAD request to `{string}`
177
+
178
+ ## POST Requests
179
+
180
+ - User sends POST request to `{string}` with payload:
181
+ - User sends POST request to `{string}` with payload and saves `{string}` variables
182
+ - User sends multipart POST request to `{string}` with payload:
183
+ - User sends multipart POST request to `{string}` with payload and `{string}` variables
184
+
185
+ ## PUT Requests
186
+
187
+ - User sends PUT request to `{string}` with payload:
188
+ - User sends PUT request to `{string}` with payload and saves `{string}` variables
189
+ - User sends multipart PUT request to `{string}` with payload:
190
+ - User sends multipart PUT request to `{string}` with payload and saves `{string}` variables
191
+
192
+ ## PATCH Requests
193
+
194
+ - User sends PATCH request to `{string}` with payload:
195
+ - User sends PATCH request to `{string}` with payload and saves `{string}` variables
196
+ - User sends multipart PATCH request to `{string}` with payload:
197
+ - User sends multipart PATCH request to `{string}` with payload and saves `{string}` variables
198
+
199
+ ## DELETE Requests
200
+
201
+ - User sends DELETE request to `{string}`
202
+ - User sends DELETE request to `{string}` and saves `{string}` variables
203
+ - User sends DELETE request to `{string}` with payload:
204
+ - User sends DELETE request to `{string}` with payload and saves `{string}` variables
205
+
206
+ ---
207
+
208
+ # Variable Management
209
+
210
+ - User saves `{string}` variable from response as `{string}`
211
+ - User saves `{string}` variable as `{string}`
212
+
213
+ ---
214
+
215
+ # Debugging / Console Output
216
+
217
+ - User wants to see saved variables
218
+ - User wants to see request body
219
+ - User wants to see response body
220
+
221
+ ---
222
+
223
+ # Generic HTTP Request
224
+
225
+ - User sends `{string}` request to `{string}`
226
+
227
+ ---
228
+
229
+ # Random Data Generation
230
+
231
+ - User sets random words as `{string}` variable
232
+ - User sets random number from `{int}` to `{int}` as `{string}` variable
233
+
234
+ # API Data Extraction
235
+
236
+ - User sends GET request to `{string}` and save `{string}` variable as a `{string}` randomly
237
+
238
+ ---
158
239
 
159
240
  ## Assertions
160
241
 
@@ -267,3 +348,5 @@
267
348
  - User expects `{string}` should not contain `{string}` object properties
268
349
  - User expects `{string}` should not contain `{string}` substring
269
350
  - User expects `{string}` should not match `{string}` regex
351
+ - User expects that request should have `{int}` status code
352
+ - User expects that response body should match `{string}` schema
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -87,10 +87,10 @@ async function responseMaker(request, response) {
87
87
 
88
88
  response && Object.assign(responseObject, { URL: response.url() });
89
89
 
90
- request.headers &&
90
+ request?.headers &&
91
91
  Object.assign(responseObject, { "Request Headers": await request.headers });
92
92
 
93
- request.body &&
93
+ request?.body &&
94
94
  Object.assign(responseObject, { "Request Body": await request.body });
95
95
 
96
96
  response && Object.assign(responseObject, { Response: await response });
@@ -1,7 +1,9 @@
1
- const { context, selector } = require("../imports/commons");
1
+ const { context, selector, resolveVariable } = require("../imports/commons");
2
2
 
3
3
  const browser = {
4
4
  setCookies: async (cookies) => {
5
+ cookies = await resolveVariable(cookies);
6
+
5
7
  let cookieData;
6
8
  try {
7
9
  cookieData = JSON.parse(cookies);
@@ -1,21 +1,25 @@
1
- const { element } = require("../imports/commons");
1
+ const { element, resolveVariable } = require("../imports/commons");
2
2
 
3
3
  const keyboard = {
4
4
  press: async (selector, key) => {
5
+ key = await resolveVariable(key);
5
6
  await element(selector).press(key);
6
7
  },
7
8
  pressSequentially: async (selector, keys) => {
9
+ keys = await resolveVariable(keys);
8
10
  await element(selector).pressSequentially(keys);
9
11
  },
10
12
  pressSequentiallyDelay: async (selector, keys, delay) => {
13
+ keys = await resolveVariable(keys);
11
14
  await element(selector).pressSequentially(keys, { delay: delay });
12
15
  },
13
16
  fill: async (selector, value) => {
17
+ value = await resolveVariable(value);
14
18
  value !== "" ? await element(selector).fill(value) : "";
15
19
  },
16
20
  multipleElementFill: async (selectors, value) => {
17
21
  const elementCount = await frame.count(selectors);
18
-
22
+ value = await resolveVariable(value);
19
23
  for (let i = 0; i < elementCount; i++) {
20
24
  await frame.nth(selectors, i).fill(value);
21
25
  }
@@ -27,6 +31,7 @@ const keyboard = {
27
31
  await element(selector).selectText();
28
32
  },
29
33
  setInputFiles: async (selector, files) => {
34
+ files = await resolveVariable(files);
30
35
  await element(selector).setInputFiles(files);
31
36
  },
32
37
  };
@@ -176,11 +176,11 @@ When("User wants to see saved variables", async function () {
176
176
  });
177
177
 
178
178
  When("User wants to see request body", async function () {
179
- console.log("Request Body: ", context.response.requestBody);
179
+ console.log("Request Body: ", context.response["Request Body"]);
180
180
  });
181
181
 
182
182
  When("User wants to see response body", async function () {
183
- console.log("Request Body: ", context.response.responseBody);
183
+ console.log("Request Body: ", context.response["Response Body"]);
184
184
  });
185
185
 
186
186
  When(
@@ -225,7 +225,7 @@ When(
225
225
  When(
226
226
  "User expects that request should have {int} status code",
227
227
  async function (expectedStatusCode) {
228
- const actualStatusCode = await context.response.response.status();
228
+ const actualStatusCode = await context.response.Response.status();
229
229
  expect(actualStatusCode).toBe(expectedStatusCode);
230
230
  },
231
231
  );
@@ -18,7 +18,7 @@ When("User gets the frame locator of {string}", async function (selector) {
18
18
 
19
19
  // User gets the nth element of a specific selector
20
20
  When(
21
- "User gets the {int}th element of {string}",
21
+ "User gets the {int} th element of {string}",
22
22
  async function (index, selector) {
23
23
  await frame.nth(selector, index);
24
24
  },