codeceptjs 4.2.2 → 4.2.4

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 (74) hide show
  1. package/README.md +4 -4
  2. package/docs/ai.md +1 -1
  3. package/docs/alternative-browsers.md +4 -4
  4. package/docs/api.md +13 -13
  5. package/docs/assertions.md +6 -6
  6. package/docs/best.md +1 -1
  7. package/docs/bootstrap.md +1 -1
  8. package/docs/data.md +8 -8
  9. package/docs/element-selection.md +27 -4
  10. package/docs/helpers/ApiDataFactory.md +2 -2
  11. package/docs/helpers/Appium.md +56 -56
  12. package/docs/helpers/Decision.md +1 -1
  13. package/docs/helpers/Detox.md +1 -1
  14. package/docs/helpers/ExpectHelper.md +1 -1
  15. package/docs/helpers/FileSystem.md +1 -1
  16. package/docs/helpers/GraphQL.md +1 -1
  17. package/docs/helpers/GraphQLDataFactory.md +2 -2
  18. package/docs/helpers/JSONResponse.md +1 -1
  19. package/docs/helpers/Kitesurf.md +65 -65
  20. package/docs/helpers/Lightpanda.md +65 -65
  21. package/docs/helpers/MockRequest.md +1 -1
  22. package/docs/helpers/Moli.md +65 -65
  23. package/docs/helpers/Obscura.md +65 -65
  24. package/docs/helpers/Playwright.md +127 -127
  25. package/docs/helpers/Puppeteer.md +88 -88
  26. package/docs/helpers/REST.md +1 -1
  27. package/docs/helpers/WebDriver.md +87 -87
  28. package/docs/installation.md +1 -1
  29. package/docs/locators.md +5 -7
  30. package/docs/migration-4.md +7 -3
  31. package/docs/mobile.md +2 -2
  32. package/docs/parallel.md +1 -1
  33. package/docs/playwright.md +5 -5
  34. package/docs/plugins/aiTrace.md +1 -1
  35. package/docs/plugins/autoDelay.md +1 -1
  36. package/docs/plugins/customLocator.md +1 -1
  37. package/docs/plugins/customReporter.md +1 -1
  38. package/docs/plugins/junitReporter.md +2 -2
  39. package/docs/plugins/pageInfo.md +1 -1
  40. package/docs/plugins/pauseOnFail.md +1 -1
  41. package/docs/plugins/retryFailedStep.md +1 -1
  42. package/docs/plugins/screenshotOnFail.md +1 -1
  43. package/docs/plugins/stepTimeout.md +1 -1
  44. package/docs/plugins.md +10 -10
  45. package/docs/puppeteer.md +4 -4
  46. package/docs/retry.md +1 -1
  47. package/docs/timeouts.md +7 -7
  48. package/docs/webdriver.md +8 -8
  49. package/lib/actor.js +20 -2
  50. package/lib/aria.js +1 -0
  51. package/lib/codecept.js +1 -1
  52. package/lib/data/context.js +24 -0
  53. package/lib/element/WebElement.js +5 -5
  54. package/lib/helper/ApiDataFactory.js +1 -1
  55. package/lib/helper/Appium.js +2 -2
  56. package/lib/helper/GraphQLDataFactory.js +1 -1
  57. package/lib/helper/Playwright.js +22 -12
  58. package/lib/helper/Puppeteer.js +5 -11
  59. package/lib/mocha/asyncWrapper.js +14 -3
  60. package/lib/mocha/test.js +1 -0
  61. package/lib/plugin/auth.js +3 -0
  62. package/lib/plugin/junitReporter.js +21 -12
  63. package/lib/recorder.js +22 -3
  64. package/lib/step/base.js +8 -1
  65. package/lib/step/func.js +1 -1
  66. package/lib/step/helper.js +1 -1
  67. package/lib/step/record.js +22 -17
  68. package/lib/step/retry.js +13 -6
  69. package/lib/utils/typescript.js +86 -12
  70. package/lib/workers.js +15 -0
  71. package/package.json +2 -1
  72. package/typings/index.d.ts +12 -0
  73. package/typings/promiseBasedTypes.d.ts +696 -351
  74. package/typings/types.d.ts +485 -352
@@ -97,7 +97,7 @@ export const config = {
97
97
  }
98
98
  ```
99
99
 
100
- See [Alternative Browser Engines](/alternative-browsers) for connection modes and limitations, and the [Obscura helper reference](/helpers/Obscura) for every option.
100
+ See [Alternative Browser Engines](/alternative-browsers) for connection modes and limitations, and the [Obscura helper reference](/helpers/obscura) for every option.
101
101
 
102
102
  ## Lightpanda (experimental)
103
103
 
package/docs/locators.md CHANGED
@@ -158,17 +158,15 @@ I.tap('~submit') // mobile
158
158
 
159
159
  ## Picking a specific element
160
160
 
161
- When a locator matches several elements on the page, CodeceptJS acts on the first one by default. To target a different match, pass `elementIndex` via `step.opts()`:
161
+ When a locator matches several elements on the page, CodeceptJS acts on the first one by default. To target a different match, chain `first()`, `last()` or `at()` to the action:
162
162
 
163
163
  ```js
164
- import step from 'codeceptjs/steps'
165
-
166
- I.click('a', step.opts({ elementIndex: 2 })) // the 2nd link
167
- I.click('a', step.opts({ elementIndex: 'last' })) // the last link
168
- I.fillField('.email-input', 'u@t.com', step.opts({ elementIndex: -1 }))
164
+ I.click('a').at(2) // the 2nd link
165
+ I.click('a').last() // the last link
166
+ I.fillField('.email-input', 'u@t.com').at(-1)
169
167
  ```
170
168
 
171
- `elementIndex` accepts positive numbers (1-based), negative numbers (`-1` is last), or the aliases `'first'` and `'last'`. It works with `click`, `fillField`, `selectOption`, `checkOption`, and other single-element actions.
169
+ `at()` accepts positive numbers (1-based) and negative numbers (`-1` is last). It works with `click`, `fillField`, `selectOption`, `checkOption`, and other single-element actions. The same selection is available as `step.opts({ elementIndex: 2 })`.
172
170
 
173
171
  To catch ambiguous locators during development rather than silently using the first match, enable `strict: true` in the helper config, or pass `step.opts({ exact: true })` on a single step:
174
172
 
@@ -534,6 +534,8 @@ I.retry(3).click('Submit') // I.click('Submit', step.retry(3))
534
534
  I.limitTime(10).fillField('Email', 'a@b.c') // I.fillField('Email', 'a@b.c', step.timeout(10))
535
535
  ```
536
536
 
537
+ You can also chain them to the action: `I.click('Submit').retry(3)`, `I.fillField('Email', 'a@b.c').timeout(10)`. Pass a whole config with `I.click('Submit').stepConfig(step.retry(3).timeout(10))`.
538
+
537
539
  `step.*` configs are also composable with the other step options:
538
540
 
539
541
  ```js
@@ -648,11 +650,13 @@ The error includes a `fetchDetails()` method that prints XPaths and HTML for eve
648
650
  Pick a specific match without writing a more specific locator:
649
651
 
650
652
  ```js
651
- I.click('a', step.opts({ elementIndex: 2 }))
652
- I.click('a', step.opts({ elementIndex: 'last' }))
653
- I.fillField('input', 'x', step.opts({ elementIndex: -1 }))
653
+ I.click('a').at(2)
654
+ I.click('a').last()
655
+ I.fillField('input', 'x').first()
654
656
  ```
655
657
 
658
+ `step.opts({ elementIndex: 2 })` does the same.
659
+
656
660
  ### Unfocused Element Detection
657
661
 
658
662
  `I.type()` and `I.pressKey()` throw `NonFocusedType` if no element has focus. Click or focus the field first.
package/docs/mobile.md CHANGED
@@ -114,7 +114,7 @@ Initialize CodeceptJS with `init` command:
114
114
  npx codeceptjs init
115
115
  ```
116
116
 
117
- Select [Appium helper](https://codecept.io/helpers/Appium/) when asked.
117
+ Select [Appium helper](https://codecept.io/helpers/appium/) when asked.
118
118
 
119
119
  ```sh
120
120
  ? What helpers do you want to use?
@@ -207,7 +207,7 @@ There are mobile-only methods like:
207
207
  * `hideDeviceKeyboard`,
208
208
  * `seeAppIsInstalled`, `installApp`, `removeApp`, `seeAppIsNotInstalled` - Android only
209
209
 
210
- and [others](https://codecept.io/helpers/Appium/).
210
+ and [others](https://codecept.io/helpers/appium/).
211
211
 
212
212
  ## Locating Elements
213
213
 
package/docs/parallel.md CHANGED
@@ -225,7 +225,7 @@ share({ tmpFile: '/tmp/run-1' }, { local: true })
225
225
  ## Scaling beyond one machine
226
226
 
227
227
  Worker threads split the suite, but every Playwright worker still runs a full local browser.
228
- With the [Kitesurf helper](/helpers/Kitesurf) each worker drives a cloud browser on Cloudflare
228
+ With the [Kitesurf helper](/helpers/kitesurf) each worker drives a cloud browser on Cloudflare
229
229
  instead — `run-workers 16` means sixteen browsers spawned in about a second, none of them
230
230
  competing for your runner's CPU. See [Alternative Browser Engines](/alternative-browsers) for
231
231
  the full setup.
@@ -104,7 +104,7 @@ When to consider navigation succeeded, defaults to `load`. Given an array of eve
104
104
  When a test runs faster than application it is recommended to increase `waitForAction` config value.
105
105
  It will wait for a small amount of time (100ms) by default after each user action is taken.
106
106
 
107
- > ▶ More options are listed in [helper reference](https://codecept.io/helpers/Playwright/).
107
+ > ▶ More options are listed in [helper reference](https://codecept.io/helpers/playwright/).
108
108
 
109
109
  ## Writing Tests
110
110
 
@@ -129,7 +129,7 @@ Tests consist with a scenario of user's action taken on a page. The most widely
129
129
  - `see`, `dontSee` - to check for a text on a page
130
130
  - `seeElement`, `dontSeeElement` - to check for elements on a page
131
131
 
132
- > ℹ All actions are listed in [Playwright helper reference](https://codecept.io/helpers/Playwright/).\*
132
+ > ℹ All actions are listed in [Playwright helper reference](https://codecept.io/helpers/playwright/).\*
133
133
 
134
134
  All actions which interact with elements can use **[CSS or XPath locators](https://codecept.io/locators/#css-and-xpath)**. Actions like `click` or `fillField` can locate elements by their name or value on a page:
135
135
 
@@ -377,15 +377,15 @@ Scenario('website looks nice on iPhone', () => {
377
377
 
378
378
  ## API Requests
379
379
 
380
- CodeceptJS has [REST](/helpers/REST) and [GraphQL](<(/helpers/GraphQL)>) helpers to perform requests to external APIs. This may be helpful to implement [data management](https://codecept.io/data/) strategy.
380
+ CodeceptJS has [REST](/helpers/rest) and [GraphQL](/helpers/graph-ql) helpers to perform requests to external APIs. This may be helpful to implement [data management](https://codecept.io/data/) strategy.
381
381
 
382
- However, Playwright since 1.18 has its own [API for making request](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get). It uses cookies from browser session to authenticate requests. So you can use it via [`makeApiRequest`](/helpers/Playwright#makeApiRequest) method:
382
+ However, Playwright since 1.18 has its own [API for making request](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get). It uses cookies from browser session to authenticate requests. So you can use it via [`makeApiRequest`](/helpers/playwright#makeapirequest) method:
383
383
 
384
384
  ```js
385
385
  I.makeApiRequest('GET', '/users')
386
386
  ```
387
387
 
388
- It is also possible to test JSON responses by adding [`JSONResponse`](/helpers/JSONResponse) and connecting it to Playwright:
388
+ It is also possible to test JSON responses by adding [`JSONResponse`](/helpers/json-response) and connecting it to Playwright:
389
389
 
390
390
  ```js
391
391
  // inside codecept.conf.js
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/aiTrace
2
+ permalink: /plugins/ai-trace
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: aiTrace
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/autoDelay
2
+ permalink: /plugins/auto-delay
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: autoDelay
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/customLocator
2
+ permalink: /plugins/custom-locator
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: customLocator
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/customReporter
2
+ permalink: /plugins/custom-reporter
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: customReporter
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/junitReporter
2
+ permalink: /plugins/junit-reporter
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: junitReporter
@@ -33,7 +33,7 @@ The produced file is consumable by Jenkins, GitLab CI, CircleCI, GitHub Actions
33
33
  Possible config options:
34
34
 
35
35
  * `outputName`: file name for the report. Default: `report.xml`.
36
- * `output`: directory where the report is stored, relative to the project root. Default: the `output` directory.
36
+ * `output`: directory where the report is stored, relative to the project root. Default: the `output` directory. With `run-workers` and `multiple` runs, each run writes its own report into its run folder (e.g. `output/dev_chromium1`) and this option is ignored.
37
37
  * `testGroupName`: value of the `name` attribute on the root `<testsuites>` element. Default: `CodeceptJS`.
38
38
  * `attachMeta`: add the test's meta information (`meta` keys, `tags`, `retries`) as `<properties>`. Default: true.
39
39
  * `attachSteps`: add the step/substep log as `<system-out>`. Default: true.
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/pageInfo
2
+ permalink: /plugins/page-info
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: pageInfo
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/pauseOnFail
2
+ permalink: /plugins/pause-on-fail
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: pauseOnFail
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/retryFailedStep
2
+ permalink: /plugins/retry-failed-step
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: retryFailedStep
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/screenshotOnFail
2
+ permalink: /plugins/screenshot-on-fail
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: screenshotOnFail
@@ -1,5 +1,5 @@
1
1
  ---
2
- permalink: /plugins/stepTimeout
2
+ permalink: /plugins/step-timeout
3
3
  editLink: false
4
4
  sidebar: auto
5
5
  title: stepTimeout
package/docs/plugins.md CHANGED
@@ -9,7 +9,7 @@ title: Plugins
9
9
 
10
10
  CodeceptJS bundles the following plugins. Each plugin has its own page with full configuration reference.
11
11
 
12
- ## [aiTrace](/plugins/aiTrace)
12
+ ## [aiTrace](/plugins/ai-trace)
13
13
 
14
14
  Generates AI-friendly trace files for debugging with AI agents. This plugin creates a markdown file with test execution logs and links to all artifacts (screenshots, HTML, ARIA snapshots, browser logs, HTTP requests) for each step.
15
15
 
@@ -21,7 +21,7 @@ Uses AI to analyze test failures and provide insights
21
21
 
22
22
  Logs user in for the first test and reuses session for next tests. Works by saving cookies into memory or file. If a session expires automatically logs in again.
23
23
 
24
- ## [autoDelay](/plugins/autoDelay)
24
+ ## [autoDelay](/plugins/auto-delay)
25
25
 
26
26
  Sometimes it takes some time for a page to respond to user's actions. Depending on app's performance this can be either slow or fast.
27
27
 
@@ -33,11 +33,11 @@ Overrides browser helper config from the command line. Works for all browser hel
33
33
 
34
34
  Dumps code coverage from Playwright/Puppeteer after every test.
35
35
 
36
- ## [customLocator](/plugins/customLocator)
36
+ ## [customLocator](/plugins/custom-locator)
37
37
 
38
38
  Creates a [custom locator][1] by using special attributes in HTML.
39
39
 
40
- ## [customReporter](/plugins/customReporter)
40
+ ## [customReporter](/plugins/custom-reporter)
41
41
 
42
42
  Sample custom reporter for CodeceptJS.
43
43
 
@@ -49,11 +49,11 @@ Exposes properties from helper instances as injectable test arguments. Use it to
49
49
 
50
50
  Self-healing tests with AI.
51
51
 
52
- ## [junitReporter](/plugins/junitReporter)
52
+ ## [junitReporter](/plugins/junit-reporter)
53
53
 
54
54
  Generates a JUnit-compatible XML report after a test run.
55
55
 
56
- ## [pageInfo](/plugins/pageInfo)
56
+ ## [pageInfo](/plugins/page-info)
57
57
 
58
58
  Collects information from web page after each failed test and adds it to the test as an artifact. It is suggested to enable this plugin if you run tests on CI and you need to debug failed tests. This plugin can be paired with `analyze` plugin to provide more context.
59
59
 
@@ -61,11 +61,11 @@ Collects information from web page after each failed test and adds it to the tes
61
61
 
62
62
  Pauses test execution interactively. Replaces the legacy `pauseOnFail` plugin. The default `on=fail` matches the old `pauseOnFail` behavior.
63
63
 
64
- ## [pauseOnFail](/plugins/pauseOnFail)
64
+ ## [pauseOnFail](/plugins/pause-on-fail)
65
65
 
66
66
  Starts an interactive pause when a test fails.
67
67
 
68
- ## [retryFailedStep](/plugins/retryFailedStep)
68
+ ## [retryFailedStep](/plugins/retry-failed-step)
69
69
 
70
70
  Retries each failed step in a test.
71
71
 
@@ -77,7 +77,7 @@ Records a video of tests. Uses Playwright's `page.screencast` API (WebM) when th
77
77
 
78
78
  Saves screenshots from the browser at points triggered by `on=`.
79
79
 
80
- ## [screenshotOnFail](/plugins/screenshotOnFail)
80
+ ## [screenshotOnFail](/plugins/screenshot-on-fail)
81
81
 
82
82
  Saves a screenshot when a test fails.
83
83
 
@@ -85,7 +85,7 @@ Saves a screenshot when a test fails.
85
85
 
86
86
  Collects all pages visited while tests are running and saves them as a [sitemap][1] XML file.
87
87
 
88
- ## [stepTimeout](/plugins/stepTimeout)
88
+ ## [stepTimeout](/plugins/step-timeout)
89
89
 
90
90
  Set timeout for test steps globally.
91
91
 
package/docs/puppeteer.md CHANGED
@@ -43,7 +43,7 @@ npx codeceptjs init
43
43
 
44
44
  You will be asked for a Helper to use, you should select Puppeteer and provide url of a website you are testing.
45
45
 
46
- > Puppeteer can also work with Firefox. [Learn how to set it up](/helpers/Puppeteer-firefox)
46
+ > Puppeteer can also work with Firefox. [Learn how to set it up](/helpers/puppeteer-firefox)
47
47
 
48
48
  ## Configuring
49
49
 
@@ -80,7 +80,7 @@ By default it is set to `domcontentloaded` which waits for `DOMContentLoaded` ev
80
80
  When a test runs faster than application it is recommended to increase `waitForAction` config value.
81
81
  It will wait for a small amount of time (100ms) by default after each user action is taken.
82
82
 
83
- > ▶ More options are listed in [helper reference](https://codecept.io/helpers/Puppeteer/).
83
+ > ▶ More options are listed in [helper reference](https://codecept.io/helpers/puppeteer/).
84
84
 
85
85
  ## Writing Tests
86
86
 
@@ -105,7 +105,7 @@ Tests consist with a scenario of user's action taken on a page. The most widely
105
105
  - `see`, `dontSee` - to check for a text on a page
106
106
  - `seeElement`, `dontSeeElement` - to check for elements on a page
107
107
 
108
- > ℹ All actions are listed in [Puppeteer helper reference](https://codecept.io/helpers/Puppeteer/).\*
108
+ > ℹ All actions are listed in [Puppeteer helper reference](https://codecept.io/helpers/puppeteer/).\*
109
109
 
110
110
  All actions which interact with elements **support CSS and XPath locators**. Actions like `click` or `fillField` by locate elements by their name or value on a page:
111
111
 
@@ -241,7 +241,7 @@ To master request intercepting [use `HTTPRequest` object](https://pptr.dev/next/
241
241
 
242
242
  ## Accessing Puppeteer API
243
243
 
244
- To get Puppeteer API inside a test use [`I.usePupepteerTo`](/helpers/Puppeteer/#usepuppeteerto) method with a callback.
244
+ To get Puppeteer API inside a test use [`I.usePupepteerTo`](/helpers/puppeteer/#usepuppeteerto) method with a callback.
245
245
  To keep test readable provide a description of a callback inside the first parameter.
246
246
 
247
247
  ```js
package/docs/retry.md CHANGED
@@ -119,7 +119,7 @@ import step from 'codeceptjs/steps'
119
119
  Scenario('checkout', ({ I }) => {
120
120
  I.amOnPage('/cart')
121
121
  I.click('Proceed to Checkout', step.retry(5)) // retry up to 5 times
122
- I.see('Payment')
122
+ I.see('Payment').retry(3) // same, chained to the action
123
123
  })
124
124
  ```
125
125
 
package/docs/timeouts.md CHANGED
@@ -9,14 +9,14 @@ CodeceptJS provides multiple timeout configurations to control test execution ti
9
9
 
10
10
  ## Step Timeout
11
11
 
12
- Set timeout for individual steps using `step.timeout()`:
12
+ Set timeout for individual steps by chaining `timeout()` to the action, or by passing `step.timeout()`:
13
13
 
14
14
  ```js
15
15
  import step from 'codeceptjs/steps'
16
16
 
17
17
  Scenario('test with step timeouts', ({ I }) => {
18
18
  I.amOnPage('/')
19
- I.click('Slow Button', step.timeout(30))
19
+ I.click('Slow Button').timeout(30)
20
20
  I.fillField('Email', 'user@example.com', step.timeout(10))
21
21
  })
22
22
  ```
@@ -85,11 +85,11 @@ Each helper (Playwright, Puppeteer, WebDriver, Appium, REST) has its own timeout
85
85
 
86
86
  Refer to helper-specific documentation for timeout configuration:
87
87
 
88
- - [Playwright Helper](/helpers/Playwright) — `timeout`, `waitForTimeout`, `getPageTimeout`
89
- - [Puppeteer Helper](/helpers/Puppeteer) — `waitForTimeout`, `getPageTimeout`
90
- - [WebDriver Helper](/helpers/WebDriver) — `waitForTimeout`, `smartWait`, `timeouts` object
91
- - [Appium Helper](/helpers/Appium) — `timeouts` object
92
- - [REST Helper](/helpers/REST) — `timeout`
88
+ - [Playwright Helper](/helpers/playwright) — `timeout`, `waitForTimeout`, `getPageTimeout`
89
+ - [Puppeteer Helper](/helpers/puppeteer) — `waitForTimeout`, `getPageTimeout`
90
+ - [WebDriver Helper](/helpers/web-driver) — `waitForTimeout`, `smartWait`, `timeouts` object
91
+ - [Appium Helper](/helpers/appium) — `timeouts` object
92
+ - [REST Helper](/helpers/rest) — `timeout`
93
93
 
94
94
  ## stepTimeout Plugin
95
95
 
package/docs/webdriver.md CHANGED
@@ -91,7 +91,7 @@ keepBrowserState: true,
91
91
  keepCookies: true,
92
92
  ```
93
93
 
94
- > ▶ More config options available on [WebDriver helper reference](/helpers/WebDriver#configuration)
94
+ > ▶ More config options available on [WebDriver helper reference](/helpers/web-driver#configuration)
95
95
 
96
96
  ### Headless Mode
97
97
 
@@ -138,7 +138,7 @@ desiredCapabilities: {
138
138
 
139
139
  ### Cloud Providers
140
140
 
141
- By default, WebdriverIO starts a local driver automatically, so no connection parameters are needed. To run tests via [Cloud Providers](/helpers/WebDriver#cloud-providers) instead, specify `host`, `port`, `protocol`, and `path` parameters pointing to the service. You may also need `user` and `key` parameters to authenticate on the cloud service.
141
+ By default, WebdriverIO starts a local driver automatically, so no connection parameters are needed. To run tests via [Cloud Providers](/helpers/web-driver#cloud-providers) instead, specify `host`, `port`, `protocol`, and `path` parameters pointing to the service. You may also need `user` and `key` parameters to authenticate on the cloud service.
142
142
 
143
143
  There are also [browser and platform specific capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities). Services like SauceLabs, BrowserStack or browser vendors can provide their own specific capabilities for more tuning.
144
144
 
@@ -208,7 +208,7 @@ Tests consist with a scenario of user's action taken on a page. The most widely
208
208
  * `see`, `dontSee` - to check for a text on a page
209
209
  * `seeElement`, `dontSeeElement` - to check for elements on a page
210
210
 
211
- > ℹ All actions are listed in [WebDriver helper reference](https://codecept.io/helpers/WebDriver/).*
211
+ > ℹ All actions are listed in [WebDriver helper reference](https://codecept.io/helpers/web-driver/).*
212
212
 
213
213
  All actions which interact with elements **support CSS and XPath locators**. Actions like `click` or `fillField` by locate elements by their name or value on a page:
214
214
 
@@ -252,7 +252,7 @@ npx codeceptjs run --steps
252
252
 
253
253
  After a page is opened a full control of a browser is given to a terminal. Type in different commands such as `click`, `see`, `fillField` to write the test. A successful commands will be saved to `./output/cli-history` file and can be copied into a test.
254
254
 
255
- > ℹ All actions are listed in [WebDriver helper reference](/helpers/WebDriver).
255
+ > ℹ All actions are listed in [WebDriver helper reference](/helpers/web-driver).
256
256
 
257
257
  An interactive shell output may look like this:
258
258
 
@@ -420,7 +420,7 @@ There are following options available:
420
420
 
421
421
  * Use headless Chrome or Firefox.
422
422
  * Use [Selenoid](/plugins/selenoid) to run browsers inside Docker containers.
423
- * Use paid [cloud services (SauceLabs, BrowserStack, TestingBot)](/helpers/WebDriver#cloud-providers).
423
+ * Use paid [cloud services (SauceLabs, BrowserStack, TestingBot)](/helpers/web-driver#cloud-providers).
424
424
 
425
425
  ## Video Recording
426
426
 
@@ -494,7 +494,7 @@ This is useful when you want to isolate application testing from a backend. For
494
494
 
495
495
  > **WebDriver has limited ability to mock requests**, so you can only mock only requests performed after page is loaded. This means that you can't block Google Analytics, or CDN calls, but you can mock API requests performed on user action.
496
496
 
497
- To mock requests enable additional helper [MockRequest](/helpers/MockRequest) (which is based on Polly.js).
497
+ To mock requests enable additional helper [MockRequest](/helpers/mock-request) (which is based on Polly.js).
498
498
 
499
499
  ```js
500
500
  helpers: {
@@ -529,7 +529,7 @@ I.click('Go to Next Page');
529
529
  // in WebDriver as we can't detect that the page was reloaded, so no mocking :(
530
530
  ```
531
531
 
532
- > See [`mockRequest` API](/helpers/MockRequest#mockrequest)
532
+ > See [`mockRequest` API](/helpers/mock-request#mockrequest)
533
533
 
534
534
  To see `mockRequest` method in intellisense auto completion don't forget to run `codeceptjs def` command:
535
535
 
@@ -542,7 +542,7 @@ Mocking rules will be kept while a test is running. To stop mocking use `I.stopM
542
542
 
543
543
  ## Accessing webdriverio API
544
544
 
545
- To get [webdriverio browser API](https://webdriver.io/docs/api.html) inside a test use [`I.useWebDriverTo`](/helpers/WebDriver/#usewebdriverto) method with a callback.
545
+ To get [webdriverio browser API](https://webdriver.io/docs/api.html) inside a test use [`I.useWebDriverTo`](/helpers/web-driver/#usewebdriverto) method with a callback.
546
546
  To keep test readable provide a description of a callback inside the first parameter.
547
547
 
548
548
  ```js
package/lib/actor.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import Step, { MetaStep } from './step.js'
2
- import recordStep from './step/record.js'
2
+ import recordStep, { applyStepConfig } from './step/record.js'
3
+ import StepConfig from './step/config.js'
3
4
  import { methodsOfObject } from './utils.js'
4
5
  import event from './event.js'
5
6
  import output from './output.js'
@@ -29,6 +30,23 @@ class Actor {
29
30
  }
30
31
  }
31
32
 
33
+ function addStepConfigChain(promise, step) {
34
+ promise.stepConfig = config => {
35
+ if (step.status !== 'queued') {
36
+ throw new Error(`Can't configure "${step.title}": the step was already executed. Chain it to the step call: I.${step.title}(...).first()`)
37
+ }
38
+ applyStepConfig(step, config)
39
+ return promise
40
+ }
41
+
42
+ promise.first = () => promise.stepConfig(new StepConfig({ elementIndex: 'first' }))
43
+ promise.last = () => promise.stepConfig(new StepConfig({ elementIndex: 'last' }))
44
+ promise.at = position => promise.stepConfig(new StepConfig({ elementIndex: position }))
45
+ promise.timeout = seconds => promise.stepConfig(new StepConfig().timeout(seconds))
46
+ promise.retry = retry => promise.stepConfig(new StepConfig().retry(retry))
47
+ return promise
48
+ }
49
+
32
50
  /**
33
51
  * Fetches all methods from all enabled helpers,
34
52
  * and makes them available to use from I. object
@@ -63,7 +81,7 @@ export default function (obj = {}, container) {
63
81
  step.actor = translation.I
64
82
  }
65
83
  // add methods to promise chain
66
- return recordStep(step, Array.from(arguments))
84
+ return addStepConfigChain(recordStep(step, Array.from(arguments)), step)
67
85
  }
68
86
  }
69
87
  })
package/lib/aria.js CHANGED
@@ -121,6 +121,7 @@ function dropEmpty(nodes) {
121
121
  const children = dropEmpty(node.children)
122
122
  if (INTERACTIVE_ROLES.has(node.role)) return [{ ...node, children }]
123
123
  if (children.length > 0) return [{ ...node, children }]
124
+ if (node.value !== undefined && node.value !== null && String(node.value).trim()) return [{ ...node, children }]
124
125
  return []
125
126
  })
126
127
  }
package/lib/codecept.js CHANGED
@@ -279,7 +279,7 @@ class Codecept {
279
279
  */
280
280
  filterLastFailedTests(mocha) {
281
281
  if (!this.opts.lastFailed) return
282
- const failedTestUids = new Set(Result.loadFailedTests().map(test => test.uid))
282
+ const failedTestUids = new Set(Result.loadFailedTests().map(test => test.uid?.split('@')[0]))
283
283
  const filterSuite = suite => {
284
284
  suite.tests = suite.tests.filter(test => failedTestUids.has(test.uid))
285
285
  suite.suites.forEach(filterSuite)
@@ -26,6 +26,30 @@ export default function (context) {
26
26
  maskSecretInTitle(scenarios)
27
27
  return new DataScenarioConfig(scenarios)
28
28
  },
29
+ Before(fn) {
30
+ data.forEach(dataRow => {
31
+ if (!dataRow.skip) {
32
+ const wrappedFn = (args) => {
33
+ if (args && args.test && args.test.inject && args.test.inject.current === dataRow.data) {
34
+ return fn({ ...args, current: dataRow.data })
35
+ }
36
+ }
37
+ context.Before(wrappedFn)
38
+ }
39
+ })
40
+ },
41
+ After(fn) {
42
+ data.forEach(dataRow => {
43
+ if (!dataRow.skip) {
44
+ const wrappedFn = (args) => {
45
+ if (args && args.test && args.test.inject && args.test.inject.current === dataRow.data) {
46
+ return fn({ ...args, current: dataRow.data })
47
+ }
48
+ }
49
+ context.After(wrappedFn)
50
+ }
51
+ })
52
+ },
29
53
  only: {
30
54
  Scenario(title, opts, fn) {
31
55
  const scenarios = []
@@ -29,7 +29,7 @@ class WebElement {
29
29
 
30
30
  /**
31
31
  * Get the native element instance
32
- * @returns {ElementHandle|WebElement|ElementHandle} Native element
32
+ * @returns {any} Native element (Playwright/Puppeteer ElementHandle or WebdriverIO element)
33
33
  */
34
34
  getNativeElement() {
35
35
  return this.element
@@ -220,7 +220,7 @@ class WebElement {
220
220
 
221
221
  /**
222
222
  * Click the element
223
- * @param {Object} options Click options
223
+ * @param {Object} [options] Click options
224
224
  * @returns {Promise<void>}
225
225
  */
226
226
  async click(options = {}) {
@@ -239,7 +239,7 @@ class WebElement {
239
239
  /**
240
240
  * Type text into the element
241
241
  * @param {string} text Text to type
242
- * @param {Object} options Type options
242
+ * @param {Object} [options] Type options
243
243
  * @returns {Promise<void>}
244
244
  */
245
245
  async type(text, options = {}) {
@@ -362,7 +362,7 @@ class WebElement {
362
362
  * Treat this element as an iframe; invoke `fn` with a WebElement wrapping
363
363
  * the iframe body. For WebDriver this switches the browser into the frame
364
364
  * for the duration of the callback and switches back on exit.
365
- * @param {(body: WebElement) => Promise<any>} fn
365
+ * @param {function(WebElement): Promise<any>} fn
366
366
  * @returns {Promise<any>} Return value of fn
367
367
  */
368
368
  async inIframe(fn) {
@@ -530,7 +530,7 @@ class WebElement {
530
530
  * @param {object} [opts]
531
531
  * @param {number} [opts.maxHtmlLength=300] passed through to toSimplifiedHTML
532
532
  * @param {string[]} [opts.attrs] attribute names to surface
533
- * @returns {Promise<{text?: string, html?: string, visible?: boolean, enabled?: boolean, attrs?: object}>}
533
+ * @returns {Promise<{text: (string|undefined), html: (string|undefined), visible: (boolean|undefined), enabled: (boolean|undefined), attrs: (Object|undefined)}>}
534
534
  */
535
535
  async describe({ maxHtmlLength = 300, attrs = ['id', 'class', 'name', 'role', 'type', 'href', 'value', 'aria-label', 'placeholder', 'data-testid'] } = {}) {
536
536
  const out = {}
@@ -99,7 +99,7 @@ import { resolveImportModulePath } from '../utils.js'
99
99
  * It is required to set REST API `endpoint` which is the baseURL for all API requests.
100
100
  * Factory file is expected to be passed via `factory` option.
101
101
  *
102
- * This Helper uses [REST](http://codecept.io/helpers/REST/) helper and accepts its configuration in "REST" section.
102
+ * This Helper uses [REST](http://codecept.io/helpers/rest/) helper and accepts its configuration in "REST" section.
103
103
  * For instance, to set timeout you should add:
104
104
  *
105
105
  * ```js
@@ -24,7 +24,7 @@ const vendorPrefix = {
24
24
  }
25
25
 
26
26
  /**
27
- * Appium helper extends [Webdriver](http://codecept.io/helpers/WebDriver/) helper.
27
+ * Appium helper extends [Webdriver](http://codecept.io/helpers/web-driver/) helper.
28
28
  * It supports all browser methods and also includes special methods for mobile apps testing.
29
29
  * You can use this helper to test Web on desktop and mobile devices and mobile apps.
30
30
  *
@@ -1738,7 +1738,7 @@ class Appium extends Webdriver {
1738
1738
  * ```
1739
1739
  *
1740
1740
  * @param {string} fileName file name to save.
1741
- * @return {Promise<void>}
1741
+ * @return {CodeceptJS.StepPromise}
1742
1742
  */
1743
1743
  async saveScreenshot(fileName) {
1744
1744
  return super.saveScreenshot(fileName, false)
@@ -100,7 +100,7 @@ import store from '../store.js'
100
100
  * It is required to set GraphQL `endpoint` which is the URL to which all the queries go to.
101
101
  * Factory file is expected to be passed via `factory` option.
102
102
  *
103
- * This Helper uses [GraphQL](http://codecept.io/helpers/GraphQL/) helper and accepts its configuration in "GraphQL" section.
103
+ * This Helper uses [GraphQL](http://codecept.io/helpers/graph-ql/) helper and accepts its configuration in "GraphQL" section.
104
104
  * For instance, to set timeout you should add:
105
105
  *
106
106
  * ```js