codeceptjs 3.5.7-beta.1 → 3.5.8

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.
@@ -27,6 +27,10 @@ or
27
27
 
28
28
  npm i playwright-core@^1.18 --save
29
29
 
30
+ Breaking Changes: if you use Playwright v1.38 and later, it will no longer download browsers automatically.
31
+
32
+ Run `npx playwright install` to download browsers after `npm install`.
33
+
30
34
  Using playwright-core package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
31
35
 
32
36
 
@@ -41,23 +45,23 @@ Type: [object][5]
41
45
 
42
46
  - `url` **[string][8]?** base url of website to be tested
43
47
  - `browser` **(`"chromium"` | `"firefox"` | `"webkit"` | `"electron"`)?** a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
44
- - `show` **[boolean][32]?** show browser window.
45
- - `restart` **([string][8] | [boolean][32])?** restart strategy between tests. Possible values:- 'context' or **false** - restarts [browser context][40] but keeps running browser. Recommended by Playwright team to keep tests isolated.
48
+ - `show` **[boolean][25]?** show browser window.
49
+ - `restart` **([string][8] | [boolean][25])?** restart strategy between tests. Possible values:- 'context' or **false** - restarts [browser context][42] but keeps running browser. Recommended by Playwright team to keep tests isolated.
46
50
  - 'browser' or **true** - closes browser and opens it again between tests.
47
51
  - 'session' or 'keep' - keeps browser context and session, but cleans up cookies and localStorage between tests. The fastest option when running tests in windowed mode. Works with `keepCookies` and `keepBrowserState` options. This behavior was default before CodeceptJS 3.1
48
- - `timeout` **[number][20]?** - [timeout][41] in ms of all Playwright actions .
49
- - `disableScreenshots` **[boolean][32]?** don't save screenshot on failure.
52
+ - `timeout` **[number][20]?** - [timeout][43] in ms of all Playwright actions .
53
+ - `disableScreenshots` **[boolean][25]?** don't save screenshot on failure.
50
54
  - `emulate` **any?** browser in device emulation mode.
51
- - `video` **[boolean][32]?** enables video recording for failed tests; videos are saved into `output/videos` folder
52
- - `keepVideoForPassedTests` **[boolean][32]?** save videos for passed tests; videos are saved into `output/videos` folder
53
- - `trace` **[boolean][32]?** record [tracing information][42] with screenshots and snapshots.
54
- - `keepTraceForPassedTests` **[boolean][32]?** save trace for passed tests.
55
- - `fullPageScreenshots` **[boolean][32]?** make full page screenshots on failure.
56
- - `uniqueScreenshotNames` **[boolean][32]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
57
- - `keepBrowserState` **[boolean][32]?** keep browser state between tests when `restart` is set to 'session'.
58
- - `keepCookies` **[boolean][32]?** keep cookies between tests when `restart` is set to 'session'.
55
+ - `video` **[boolean][25]?** enables video recording for failed tests; videos are saved into `output/videos` folder
56
+ - `keepVideoForPassedTests` **[boolean][25]?** save videos for passed tests; videos are saved into `output/videos` folder
57
+ - `trace` **[boolean][25]?** record [tracing information][44] with screenshots and snapshots.
58
+ - `keepTraceForPassedTests` **[boolean][25]?** save trace for passed tests.
59
+ - `fullPageScreenshots` **[boolean][25]?** make full page screenshots on failure.
60
+ - `uniqueScreenshotNames` **[boolean][25]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
61
+ - `keepBrowserState` **[boolean][25]?** keep browser state between tests when `restart` is set to 'session'.
62
+ - `keepCookies` **[boolean][25]?** keep cookies between tests when `restart` is set to 'session'.
59
63
  - `waitForAction` **[number][20]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
60
- - `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][38].
64
+ - `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][40].
61
65
  - `pressKeyDelay` **[number][20]?** Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
62
66
  - `getPageTimeout` **[number][20]?** config option to set maximum navigation time in milliseconds.
63
67
  - `waitForTimeout` **[number][20]?** default wait* timeout in ms. Default: 1000.
@@ -66,15 +70,15 @@ Type: [object][5]
66
70
  - `colorScheme` **(`"dark"` | `"light"` | `"no-preference"`)?** default color scheme. Possible values: `dark` | `light` | `no-preference`.
67
71
  - `userAgent` **[string][8]?** user-agent string.
68
72
  - `locale` **[string][8]?** locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
69
- - `manualStart` **[boolean][32]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
73
+ - `manualStart` **[boolean][25]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
70
74
  - `chromium` **[object][5]?** pass additional chromium options
71
75
  - `firefox` **[object][5]?** pass additional firefox options
72
76
  - `electron` **[object][5]?** (pass additional electron options
73
- - `channel` **any?** (While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge][43].
74
- - `ignoreLog` **[Array][10]<[string][8]>?** An array with console message types that are not logged to debug log. Default value is `['warning', 'log']`. E.g. you can set `[]` to log all messages. See all possible [values][44].
75
- - `ignoreHTTPSErrors` **[boolean][32]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
76
- - `bypassCSP` **[boolean][32]?** bypass Content Security Policy or CSP
77
- - `highlightElement` **[boolean][32]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
77
+ - `channel` **any?** (While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge][45].
78
+ - `ignoreLog` **[Array][10]<[string][8]>?** An array with console message types that are not logged to debug log. Default value is `['warning', 'log']`. E.g. you can set `[]` to log all messages. See all possible [values][46].
79
+ - `ignoreHTTPSErrors` **[boolean][25]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
80
+ - `bypassCSP` **[boolean][25]?** bypass Content Security Policy or CSP
81
+ - `highlightElement` **[boolean][25]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
78
82
 
79
83
 
80
84
 
@@ -991,6 +995,17 @@ console.log(JSON.stringify(errors));
991
995
 
992
996
  Returns **[Promise][9]<[Array][10]<any>>**
993
997
 
998
+ ### grabCheckedElementStatus
999
+
1000
+ Return the checked status of given element.
1001
+
1002
+ #### Parameters
1003
+
1004
+ - `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
1005
+ - `options` **[object][5]?** See [https://playwright.dev/docs/api/class-locator#locator-is-checked][24]
1006
+
1007
+ Returns **[Promise][9]<[boolean][25]>**
1008
+
994
1009
  ### grabCookie
995
1010
 
996
1011
  Gets a cookie object by name.
@@ -1078,6 +1093,17 @@ let data = await I.grabDataFromPerformanceTiming();
1078
1093
 
1079
1094
  Returns **[Promise][9]<void>** automatically synchronized promise through #recorder
1080
1095
 
1096
+ ### grabDisabledElementStatus
1097
+
1098
+ Return the disabled status of given element.
1099
+
1100
+ #### Parameters
1101
+
1102
+ - `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
1103
+ - `options` **[object][5]?** See [https://playwright.dev/docs/api/class-locator#locator-is-disabled][26]
1104
+
1105
+ Returns **[Promise][9]<[boolean][25]>**
1106
+
1081
1107
  ### grabElementBoundingRect
1082
1108
 
1083
1109
  Grab the width, height, location of given locator.
@@ -1362,7 +1388,7 @@ Returns **[Array][10]<any>**
1362
1388
  Handles a file download. A file name is required to save the file on disk.
1363
1389
  Files are saved to "output" directory.
1364
1390
 
1365
- Should be used with [FileSystem helper][24] to check that file were downloaded correctly.
1391
+ Should be used with [FileSystem helper][27] to check that file were downloaded correctly.
1366
1392
 
1367
1393
  ```js
1368
1394
  I.handleDownloads('downloads/avatar.jpg');
@@ -1379,7 +1405,7 @@ Returns **[Promise][9]<void>**
1379
1405
 
1380
1406
  ### makeApiRequest
1381
1407
 
1382
- Performs [api request][25] using
1408
+ Performs [api request][28] using
1383
1409
  the cookies from the current browser session.
1384
1410
 
1385
1411
  ```js
@@ -1400,13 +1426,13 @@ Returns **[Promise][9]<[object][5]>** response
1400
1426
 
1401
1427
  ### mockRoute
1402
1428
 
1403
- Mocks network request using [`browserContext.route`][26] of Playwright
1429
+ Mocks network request using [`browserContext.route`][29] of Playwright
1404
1430
 
1405
1431
  ```js
1406
1432
  I.mockRoute(/(.png$)|(.jpg$)/, route => route.abort());
1407
1433
  ```
1408
1434
 
1409
- This method allows intercepting and mocking requests & responses. [Learn more about it][27]
1435
+ This method allows intercepting and mocking requests & responses. [Learn more about it][30]
1410
1436
 
1411
1437
  #### Parameters
1412
1438
 
@@ -1458,7 +1484,7 @@ Open new tab and automatically switched to new tab
1458
1484
  I.openNewTab();
1459
1485
  ```
1460
1486
 
1461
- You can pass in [page options][28] to emulate device on this page
1487
+ You can pass in [page options][31] to emulate device on this page
1462
1488
 
1463
1489
  ```js
1464
1490
  // enable mobile
@@ -1473,7 +1499,7 @@ I.openNewTab({ isMobile: true });
1473
1499
 
1474
1500
  Presses a key in the browser (on a focused element).
1475
1501
 
1476
- _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][29].
1502
+ _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][32].
1477
1503
 
1478
1504
  ```js
1479
1505
  I.pressKey('Backspace');
@@ -1534,13 +1560,13 @@ Some of the supported key names are:
1534
1560
 
1535
1561
  - `key` **([string][8] | [Array][10]<[string][8]>)** key or array of keys to press.
1536
1562
 
1537
- Returns **[Promise][9]<void>** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][30]).
1563
+ Returns **[Promise][9]<void>** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][33]).
1538
1564
 
1539
1565
  ### pressKeyDown
1540
1566
 
1541
1567
  Presses a key in the browser and leaves it in a down state.
1542
1568
 
1543
- To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1569
+ To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][34]).
1544
1570
 
1545
1571
  ```js
1546
1572
  I.pressKeyDown('Control');
@@ -1558,7 +1584,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
1558
1584
 
1559
1585
  Releases a key in the browser which was previously set to a down state.
1560
1586
 
1561
- To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1587
+ To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][34]).
1562
1588
 
1563
1589
  ```js
1564
1590
  I.pressKeyDown('Control');
@@ -1667,7 +1693,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
1667
1693
  #### Parameters
1668
1694
 
1669
1695
  - `fileName` **[string][8]** file name to save.
1670
- - `fullPage` **[boolean][32]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
1696
+ - `fullPage` **[boolean][25]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
1671
1697
 
1672
1698
  Returns **[Promise][9]<void>** automatically synchronized promise through #recorder
1673
1699
 
@@ -2174,7 +2200,7 @@ I.switchToPreviousTab(2);
2174
2200
 
2175
2201
  Types out the given text into an active field.
2176
2202
  To slow down typing use a second parameter, to set interval between key presses.
2177
- _Note:_ Should be used when [`fillField`][29] is not an option.
2203
+ _Note:_ Should be used when [`fillField`][32] is not an option.
2178
2204
 
2179
2205
  ```js
2180
2206
  // passing in a string
@@ -2217,7 +2243,7 @@ I.uncheckOption('agree', '//form');
2217
2243
  - `context` **([string][8]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
2218
2244
  - `options`
2219
2245
 
2220
- Returns **[Promise][9]<void>** automatically synchronized promise through #recorder[Additional options][33] for uncheck available as 3rd argument.Examples:```js
2246
+ Returns **[Promise][9]<void>** automatically synchronized promise through #recorder[Additional options][35] for uncheck available as 3rd argument.Examples:```js
2221
2247
  // click on element at position
2222
2248
  I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
2223
2249
  ```> ⚠️ To avoid flakiness, option `force: true` is set by default
@@ -2229,7 +2255,7 @@ Use Playwright API inside a test.
2229
2255
  First argument is a description of an action.
2230
2256
  Second argument is async function that gets this helper as parameter.
2231
2257
 
2232
- { [`page`][34], [`browserContext`][35] [`browser`][36] } objects from Playwright API are available.
2258
+ { [`page`][36], [`browserContext`][37] [`browser`][38] } objects from Playwright API are available.
2233
2259
 
2234
2260
  ```js
2235
2261
  I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
@@ -2362,7 +2388,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
2362
2388
 
2363
2389
  Waits for navigation to finish. By default, it takes configured `waitForNavigation` option.
2364
2390
 
2365
- See [Playwright's reference][37]
2391
+ See [Playwright's reference][39]
2366
2392
 
2367
2393
  #### Parameters
2368
2394
 
@@ -2419,7 +2445,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
2419
2445
 
2420
2446
  Waits for page navigates to a new URL or reloads. By default, it takes configured `waitForNavigation` option.
2421
2447
 
2422
- See [Playwright's reference][38]
2448
+ See [Playwright's reference][40]
2423
2449
 
2424
2450
  #### Parameters
2425
2451
 
@@ -2456,7 +2482,7 @@ I.waitForVisible('#popup');
2456
2482
  - `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
2457
2483
  - `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
2458
2484
 
2459
- Returns **[Promise][9]<void>** automatically synchronized promise through #recorderThis method accepts [React selectors][39].
2485
+ Returns **[Promise][9]<void>** automatically synchronized promise through #recorderThis method accepts [React selectors][41].
2460
2486
 
2461
2487
  ### waitInUrl
2462
2488
 
@@ -2567,44 +2593,48 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
2567
2593
 
2568
2594
  [23]: https://playwright.dev/docs/api/class-consolemessage
2569
2595
 
2570
- [24]: https://codecept.io/helpers/FileSystem
2596
+ [24]: https://playwright.dev/docs/api/class-locator#locator-is-checked
2597
+
2598
+ [25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
2599
+
2600
+ [26]: https://playwright.dev/docs/api/class-locator#locator-is-disabled
2571
2601
 
2572
- [25]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
2602
+ [27]: https://codecept.io/helpers/FileSystem
2573
2603
 
2574
- [26]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
2604
+ [28]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
2575
2605
 
2576
- [27]: https://playwright.dev/docs/network#handle-requests
2606
+ [29]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
2577
2607
 
2578
- [28]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
2608
+ [30]: https://playwright.dev/docs/network#handle-requests
2579
2609
 
2580
- [29]: #fillfield
2610
+ [31]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
2581
2611
 
2582
- [30]: https://github.com/GoogleChrome/puppeteer/issues/1313
2612
+ [32]: #fillfield
2583
2613
 
2584
- [31]: #click
2614
+ [33]: https://github.com/GoogleChrome/puppeteer/issues/1313
2585
2615
 
2586
- [32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
2616
+ [34]: #click
2587
2617
 
2588
- [33]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
2618
+ [35]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
2589
2619
 
2590
- [34]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
2620
+ [36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
2591
2621
 
2592
- [35]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
2622
+ [37]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
2593
2623
 
2594
- [36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
2624
+ [38]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
2595
2625
 
2596
- [37]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
2626
+ [39]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
2597
2627
 
2598
- [38]: https://playwright.dev/docs/api/class-page#page-wait-for-url
2628
+ [40]: https://playwright.dev/docs/api/class-page#page-wait-for-url
2599
2629
 
2600
- [39]: https://codecept.io/react
2630
+ [41]: https://codecept.io/react
2601
2631
 
2602
- [40]: https://playwright.dev/docs/api/class-browsercontext
2632
+ [42]: https://playwright.dev/docs/api/class-browsercontext
2603
2633
 
2604
- [41]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
2634
+ [43]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
2605
2635
 
2606
- [42]: https://playwright.dev/docs/trace-viewer
2636
+ [44]: https://playwright.dev/docs/trace-viewer
2607
2637
 
2608
- [43]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
2638
+ [45]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
2609
2639
 
2610
- [44]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
2640
+ [46]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
@@ -44,6 +44,8 @@ Type: [object][4]
44
44
  - `disableScreenshots` **[boolean][20]?** don't save screenshot on failure.
45
45
  - `fullPageScreenshots` **[boolean][20]?** make full page screenshots on failure.
46
46
  - `uniqueScreenshotNames` **[boolean][20]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
47
+ - `trace` **[boolean][20]?** record [tracing information][25] with screenshots.
48
+ - `keepTraceForPassedTests` **[boolean][20]?** save trace for passed tests.
47
49
  - `keepBrowserState` **[boolean][20]?** keep browser state between tests when `restart` is set to false.
48
50
  - `keepCookies` **[boolean][20]?** keep cookies between tests when `restart` is set to false.
49
51
  - `waitForAction` **[number][11]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
@@ -55,11 +57,19 @@ Type: [object][4]
55
57
  - `userAgent` **[string][6]?** user-agent string.
56
58
  - `manualStart` **[boolean][20]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
57
59
  - `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
58
- - `chrome` **[object][4]?** pass additional [Puppeteer run options][25].
60
+ - `chrome` **[object][4]?** pass additional [Puppeteer run options][26].
59
61
  - `highlightElement` **[boolean][20]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
60
62
 
61
63
 
62
64
 
65
+ #### Trace Recording Customization
66
+
67
+ Trace recording provides complete information on test execution and includes screenshots, and network requests logged during run.
68
+ Traces will be saved to `output/trace`
69
+
70
+ - `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
71
+ - `keepTraceForPassedTests`: - save trace for passed tests
72
+
63
73
  #### Example #1: Wait for 0 network connections.
64
74
 
65
75
  ```js
@@ -2263,4 +2273,6 @@ Returns **[Promise][7]<void>** automatically synchronized promise through #re
2263
2273
 
2264
2274
  [24]: https://codecept.io/react
2265
2275
 
2266
- [25]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
2276
+ [25]: https://pptr.dev/api/puppeteer.tracing
2277
+
2278
+ [26]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
package/docs/webdriver.md CHANGED
@@ -447,7 +447,7 @@ To share the same user session across different tests CodeceptJS provides [autoL
447
447
  This plugin requires some configuration but is very simple in use:
448
448
 
449
449
  ```js
450
- Scenario('do something with logged in user', ({ I, login) }) => {
450
+ Scenario('do something with logged in user', ({ I, login }) => {
451
451
  login('user');
452
452
  I.see('Dashboard','h1');
453
453
  });
package/lib/ai.js CHANGED
@@ -16,8 +16,6 @@ const htmlConfig = {
16
16
  html: {},
17
17
  };
18
18
 
19
- const aiInstance = null;
20
-
21
19
  class AiAssistant {
22
20
  constructor() {
23
21
  this.config = config.get('ai', defaultConfig);
@@ -28,10 +26,7 @@ class AiAssistant {
28
26
 
29
27
  this.isEnabled = !!process.env.OPENAI_API_KEY;
30
28
 
31
- if (!this.isEnabled) {
32
- debug('No OpenAI API key provided. AI assistant is disabled.');
33
- return;
34
- }
29
+ if (!this.isEnabled) return;
35
30
 
36
31
  const configuration = new Configuration({
37
32
  apiKey: process.env.OPENAI_API_KEY,
@@ -40,17 +35,13 @@ class AiAssistant {
40
35
  this.openai = new OpenAIApi(configuration);
41
36
  }
42
37
 
43
- static getInstance() {
44
- return aiInstance || new AiAssistant();
45
- }
46
-
47
- async setHtmlContext(html) {
38
+ setHtmlContext(html) {
48
39
  let processedHTML = html;
49
40
 
50
41
  if (this.htmlConfig.simplify) {
51
42
  processedHTML = removeNonInteractiveElements(processedHTML, this.htmlConfig);
52
43
  }
53
- if (this.htmlConfig.minify) processedHTML = await minifyHtml(processedHTML);
44
+ if (this.htmlConfig.minify) processedHTML = minifyHtml(processedHTML);
54
45
  if (this.htmlConfig.maxLength) processedHTML = splitByChunks(processedHTML, this.htmlConfig.maxLength)[0];
55
46
 
56
47
  debug(processedHTML);
@@ -183,6 +183,11 @@ class Appium extends Webdriver {
183
183
  this.axios = axios.create();
184
184
 
185
185
  webdriverio = require('webdriverio');
186
+ if (!config.appiumV2) {
187
+ console.log('The Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022. Please migrating to Appium 2.x by adding appiumV2: true to your config.');
188
+ console.log('More info: https://bit.ly/appium-v2-migration');
189
+ console.log('This Appium 1.x support will be removed in next major release.');
190
+ }
186
191
  }
187
192
 
188
193
  _validateConfig(config) {
@@ -916,11 +921,12 @@ class Appium extends Webdriver {
916
921
  * I.setNetworkConnection(4) // airplane mode off, wifi off, data on
917
922
  * I.setNetworkConnection(6) // airplane mode off, wifi on, data on
918
923
  * ```
919
- * See corresponding [webdriverio reference](http://webdriver.io/api/mobile/setNetworkConnection.html).
920
- *
921
- * @return {Promise<{}>}
924
+ * See corresponding [webdriverio reference](https://webdriver.io/docs/api/chromium/#setnetworkconnection).
922
925
  *
923
926
  * Appium: support only Android
927
+ *
928
+ * @param {number} value The network connection mode bitmask
929
+ * @return {Promise<number>}
924
930
  */
925
931
  async setNetworkConnection(value) {
926
932
  onlyForApps.call(this, supportedPlatform.android);
@@ -116,6 +116,10 @@ const config = {};
116
116
  * npm i playwright-core@^1.18 --save
117
117
  * ```
118
118
  *
119
+ * Breaking Changes: if you use Playwright v1.38 and later, it will no longer download browsers automatically.
120
+ *
121
+ * Run `npx playwright install` to download browsers after `npm install`.
122
+ *
119
123
  * Using playwright-core package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
120
124
  *
121
125
  *
@@ -993,6 +997,38 @@ class Playwright extends Helper {
993
997
  await el.blur(options);
994
998
  return this._waitForAction();
995
999
  }
1000
+ /**
1001
+ * Return the checked status of given element.
1002
+ *
1003
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1004
+ * @param {object} [options] See https://playwright.dev/docs/api/class-locator#locator-is-checked
1005
+ * @return {Promise<boolean>}
1006
+ *
1007
+ */
1008
+
1009
+ async grabCheckedElementStatus(locator, options = {}) {
1010
+ const supportedTypes = ['checkbox', 'radio'];
1011
+ const el = await this._locateElement(locator);
1012
+ const type = await el.getAttribute('type');
1013
+
1014
+ if (supportedTypes.includes(type)) {
1015
+ return el.isChecked(options);
1016
+ }
1017
+ throw new Error(`Element is not a ${supportedTypes.join(' or ')} input`);
1018
+ }
1019
+ /**
1020
+ * Return the disabled status of given element.
1021
+ *
1022
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1023
+ * @param {object} [options] See https://playwright.dev/docs/api/class-locator#locator-is-disabled
1024
+ * @return {Promise<boolean>}
1025
+ *
1026
+ */
1027
+
1028
+ async grabDisabledElementStatus(locator, options = {}) {
1029
+ const el = await this._locateElement(locator);
1030
+ return el.isDisabled(options);
1031
+ }
996
1032
 
997
1033
  /**
998
1034
  * {{> dragAndDrop }}
@@ -2546,6 +2582,7 @@ class Playwright extends Helper {
2546
2582
  let count = 0;
2547
2583
  do {
2548
2584
  waiter = await _contextObject.locator(`:has-text('${text}')`).first().isVisible();
2585
+ if (waiter) break;
2549
2586
  await this.wait(1);
2550
2587
  count += 1000;
2551
2588
  } while (count <= waitTimeout);
@@ -4,6 +4,7 @@ const fsExtra = require('fs-extra');
4
4
  const path = require('path');
5
5
 
6
6
  const Helper = require('@codeceptjs/helper');
7
+ const { v4: uuidv4 } = require('uuid');
7
8
  const Locator = require('../locator');
8
9
  const recorder = require('../recorder');
9
10
  const store = require('../store');
@@ -19,6 +20,7 @@ const {
19
20
  fileExists,
20
21
  chunkArray,
21
22
  toCamelCase,
23
+ clearString,
22
24
  convertCssPropertiesToCamelCase,
23
25
  screenshotOutputFolder,
24
26
  getNormalizedKeyAttributeValue,
@@ -57,6 +59,8 @@ const consoleLogStore = new Console();
57
59
  * @prop {boolean} [disableScreenshots=false] - don't save screenshot on failure.
58
60
  * @prop {boolean} [fullPageScreenshots=false] - make full page screenshots on failure.
59
61
  * @prop {boolean} [uniqueScreenshotNames=false] - option to prevent screenshot override if you have scenarios with the same name in different suites.
62
+ * @prop {boolean} [trace=false] - record [tracing information](https://pptr.dev/api/puppeteer.tracing) with screenshots.
63
+ * @prop {boolean} [keepTraceForPassedTests=false] - save trace for passed tests.
60
64
  * @prop {boolean} [keepBrowserState=false] - keep browser state between tests when `restart` is set to false.
61
65
  * @prop {boolean} [keepCookies=false] - keep cookies between tests when `restart` is set to false.
62
66
  * @prop {number} [waitForAction=100] - how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
@@ -92,6 +96,14 @@ const config = {};
92
96
  *
93
97
  * <!-- configuration -->
94
98
  *
99
+ * #### Trace Recording Customization
100
+ *
101
+ * Trace recording provides complete information on test execution and includes screenshots, and network requests logged during run.
102
+ * Traces will be saved to `output/trace`
103
+ *
104
+ * * `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
105
+ * * `keepTraceForPassedTests`: - save trace for passed tests
106
+ *
95
107
  * #### Example #1: Wait for 0 network connections.
96
108
  *
97
109
  * ```js
@@ -281,8 +293,9 @@ class Puppeteer extends Helper {
281
293
  }
282
294
  }
283
295
 
284
- async _before() {
296
+ async _before(test) {
285
297
  this.sessionPages = {};
298
+ this.currentRunningTest = test;
286
299
  recorder.retry({
287
300
  retries: 3,
288
301
  when: err => {
@@ -647,6 +660,14 @@ class Puppeteer extends Helper {
647
660
  }
648
661
  }
649
662
 
663
+ if (this.options.trace) {
664
+ const fileName = `${`${global.output_dir}${path.sep}trace${path.sep}${uuidv4()}_${clearString(this.currentRunningTest.title)}`.slice(0, 245)}.json`;
665
+ const dir = path.dirname(fileName);
666
+ if (!fileExists(dir)) fs.mkdirSync(dir);
667
+ await this.page.tracing.start({ screenshots: true, path: fileName });
668
+ this.currentRunningTest.artifacts.trace = fileName;
669
+ }
670
+
650
671
  await this.page.goto(url, { waitUntil: this.options.waitForNavigation });
651
672
 
652
673
  const performanceTiming = JSON.parse(await this.page.evaluate(() => JSON.stringify(window.performance.timing)));
@@ -1898,8 +1919,30 @@ class Puppeteer extends Helper {
1898
1919
  }
1899
1920
  }
1900
1921
 
1901
- async _failed() {
1922
+ async _failed(test) {
1923
+ await this._withinEnd();
1924
+
1925
+ if (this.options.trace) {
1926
+ await this.page.tracing.stop();
1927
+ const _traceName = this.currentRunningTest.artifacts.trace.replace('.json', '.failed.json');
1928
+ fs.renameSync(this.currentRunningTest.artifacts.trace, _traceName);
1929
+ test.artifacts.trace = _traceName;
1930
+ }
1931
+ }
1932
+
1933
+ async _passed(test) {
1902
1934
  await this._withinEnd();
1935
+
1936
+ if (this.options.trace) {
1937
+ await this.page.tracing.stop();
1938
+ if (this.options.keepTraceForPassedTests) {
1939
+ const _traceName = this.currentRunningTest.artifacts.trace.replace('.json', '.passed.json');
1940
+ fs.renameSync(this.currentRunningTest.artifacts.trace, _traceName);
1941
+ test.artifacts.trace = _traceName;
1942
+ } else {
1943
+ fs.unlinkSync(this.currentRunningTest.artifacts.trace);
1944
+ }
1945
+ }
1903
1946
  }
1904
1947
 
1905
1948
  /**
package/lib/html.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const { parse, serialize } = require('parse5');
2
- const { minify } = require('html-minifier-terser');
2
+ const { minify } = require('html-minifier');
3
3
 
4
- async function minifyHtml(html) {
4
+ function minifyHtml(html) {
5
5
  return minify(html, {
6
6
  collapseWhitespace: true,
7
7
  removeComments: true,
@@ -11,7 +11,7 @@ async function minifyHtml(html) {
11
11
  removeStyleLinkTypeAttributes: true,
12
12
  collapseBooleanAttributes: true,
13
13
  useShortDoctype: true,
14
- });
14
+ }).toString();
15
15
  }
16
16
 
17
17
  const defaultHtmlOpts = {
package/lib/pause.js CHANGED
@@ -18,7 +18,8 @@ let nextStep;
18
18
  let finish;
19
19
  let next;
20
20
  let registeredVariables = {};
21
- let aiAssistant;
21
+ const aiAssistant = new AiAssistant();
22
+
22
23
  /**
23
24
  * Pauses test execution and starts interactive shell
24
25
  * @param {Object<string, *>} [passedObject]
@@ -44,8 +45,6 @@ function pauseSession(passedObject = {}) {
44
45
  let vars = Object.keys(registeredVariables).join(', ');
45
46
  if (vars) vars = `(vars: ${vars})`;
46
47
 
47
- aiAssistant = AiAssistant.getInstance();
48
-
49
48
  output.print(colors.yellow(' Interactive shell started'));
50
49
  output.print(colors.yellow(' Use JavaScript syntax to try steps in action'));
51
50
  output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`));
@@ -103,9 +102,7 @@ async function parseInput(cmd) {
103
102
  let isAiCommand = false;
104
103
  let $res;
105
104
  try {
106
- // eslint-disable-next-line
107
105
  const locate = global.locate; // enable locate in this context
108
- // eslint-disable-next-line
109
106
  const I = container.support('I');
110
107
  if (cmd.trim().startsWith('=>')) {
111
108
  isCustomCommand = true;
@@ -118,7 +115,7 @@ async function parseInput(cmd) {
118
115
  executeCommand = executeCommand.then(async () => {
119
116
  try {
120
117
  const html = await res;
121
- await aiAssistant.setHtmlContext(html);
118
+ aiAssistant.setHtmlContext(html);
122
119
  } catch (err) {
123
120
  output.print(output.styles.error(' ERROR '), 'Can\'t get HTML context', err.stack);
124
121
  return;
@@ -9,6 +9,7 @@ const isAsyncFunction = require('../utils').isAsyncFunction;
9
9
 
10
10
  const defaultUser = {
11
11
  fetch: I => I.grabCookie(),
12
+ check: () => {},
12
13
  restore: (I, cookies) => {
13
14
  I.amOnPage('/'); // open a page
14
15
  I.setCookie(cookies);
@@ -283,7 +284,12 @@ module.exports = function (config) {
283
284
  } else {
284
285
  userSession.login(I);
285
286
  }
287
+
286
288
  const cookies = await userSession.fetch(I);
289
+ if (!cookies) {
290
+ debug('Cannot save user session with empty cookies from auto login\'s fetch method');
291
+ return;
292
+ }
287
293
  if (config.saveToFile) {
288
294
  debug(`Saved user session into file for ${name}`);
289
295
  fs.writeFileSync(path.join(global.output_dir, `${name}_session.json`), JSON.stringify(cookies));