codeceptjs 3.5.0 â 3.5.1
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/CHANGELOG.md +20 -0
- package/README.md +3 -3
- package/docs/ai.md +11 -9
- package/docs/build/Playwright.js +59 -27
- package/docs/build/Puppeteer.js +56 -0
- package/docs/build/TestCafe.js +58 -1
- package/docs/build/WebDriver.js +55 -0
- package/docs/changelog.md +20 -0
- package/docs/helpers/Playwright.md +201 -166
- package/docs/helpers/Puppeteer.md +148 -102
- package/docs/helpers/TestCafe.md +95 -49
- package/docs/helpers/WebDriver.md +150 -104
- package/docs/plugins.md +1 -1
- package/docs/webapi/blur.mustache +17 -0
- package/docs/webapi/focus.mustache +12 -0
- package/lib/cli.js +9 -1
- package/lib/command/init.js +10 -0
- package/lib/event.js +2 -0
- package/lib/helper/Playwright.js +47 -44
- package/lib/helper/Puppeteer.js +27 -0
- package/lib/helper/TestCafe.js +29 -1
- package/lib/helper/WebDriver.js +26 -0
- package/lib/helper/scripts/blurElement.js +17 -0
- package/lib/helper/scripts/focusElement.js +17 -0
- package/lib/interfaces/gherkin.js +8 -0
- package/lib/plugin/heal.js +5 -7
- package/lib/recorder.js +7 -4
- package/lib/utils.js +13 -0
- package/package.json +3 -6
- package/typings/promiseBasedTypes.d.ts +130 -13
- package/typings/types.d.ts +134 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 3.5.1
|
|
2
|
+
|
|
3
|
+
đŠī¸ Features
|
|
4
|
+
|
|
5
|
+
* [Puppeteer][WebDriver][TestCafe] Added methods by @KobeNguyenT in #3737
|
|
6
|
+
* `blur`
|
|
7
|
+
* `focus`
|
|
8
|
+
* Improved BDD output to print steps without `I.` commands` by @davertmik #3739
|
|
9
|
+
* Improved `codecept init` setup for Electron tests by @KobeNguyenT. See #3733
|
|
10
|
+
|
|
11
|
+
đ Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Fixed serializing of custom errors making tests stuck. Fix #3739 by @davertmik.
|
|
14
|
+
|
|
15
|
+
đ Documentation
|
|
16
|
+
|
|
17
|
+
* Fixed Playwright docs by @Horsty80
|
|
18
|
+
* Fixed ai docs by @ngraf
|
|
19
|
+
* Various fixes by @KobeNguyenT
|
|
20
|
+
|
|
1
21
|
## 3.5.0
|
|
2
22
|
|
|
3
23
|
đŠī¸ Features
|
package/README.md
CHANGED
|
@@ -309,22 +309,22 @@ Thanks all to those who are and will have contributing to this awesome project!
|
|
|
309
309
|
<a href="https://github.com/nikocanvacom"><img src="https://avatars.githubusercontent.com/u/83254493?v=4" title="nikocanvacom" width="80" height="80"></a>
|
|
310
310
|
<a href="https://github.com/elukoyanov"><img src="https://avatars.githubusercontent.com/u/11647141?v=4" title="elukoyanov" width="80" height="80"></a>
|
|
311
311
|
<a href="https://github.com/gkushang"><img src="https://avatars.githubusercontent.com/u/3663389?v=4" title="gkushang" width="80" height="80"></a>
|
|
312
|
+
<a href="https://github.com/actions-user"><img src="https://avatars.githubusercontent.com/u/65916846?v=4" title="actions-user" width="80" height="80"></a>
|
|
312
313
|
<a href="https://github.com/tsuemura"><img src="https://avatars.githubusercontent.com/u/17092259?v=4" title="tsuemura" width="80" height="80"></a>
|
|
313
314
|
<a href="https://github.com/EgorBodnar"><img src="https://avatars.githubusercontent.com/u/63167966?v=4" title="EgorBodnar" width="80" height="80"></a>
|
|
314
315
|
<a href="https://github.com/VikalpP"><img src="https://avatars.githubusercontent.com/u/11846339?v=4" title="VikalpP" width="80" height="80"></a>
|
|
316
|
+
<a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4" title="dependabot[bot]" width="80" height="80"></a>
|
|
315
317
|
<a href="https://github.com/BorisOsipov"><img src="https://avatars.githubusercontent.com/u/6514276?v=4" title="BorisOsipov" width="80" height="80"></a>
|
|
316
318
|
<a href="https://github.com/elaichenkov"><img src="https://avatars.githubusercontent.com/u/29764053?v=4" title="elaichenkov" width="80" height="80"></a>
|
|
317
|
-
<a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4" title="dependabot[bot]" width="80" height="80"></a>
|
|
318
319
|
<a href="https://github.com/nitschSB"><img src="https://avatars.githubusercontent.com/u/39341455?v=4" title="nitschSB" width="80" height="80"></a>
|
|
319
320
|
<a href="https://github.com/hubidu"><img src="https://avatars.githubusercontent.com/u/13134082?v=4" title="hubidu" width="80" height="80"></a>
|
|
320
321
|
<a href="https://github.com/jploskonka"><img src="https://avatars.githubusercontent.com/u/669483?v=4" title="jploskonka" width="80" height="80"></a>
|
|
322
|
+
<a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
|
|
321
323
|
<a href="https://github.com/maojunxyz"><img src="https://avatars.githubusercontent.com/u/28778042?v=4" title="maojunxyz" width="80" height="80"></a>
|
|
322
324
|
<a href="https://github.com/abhimanyupandian"><img src="https://avatars.githubusercontent.com/u/36107381?v=4" title="abhimanyupandian" width="80" height="80"></a>
|
|
323
325
|
<a href="https://github.com/martomo"><img src="https://avatars.githubusercontent.com/u/1850135?v=4" title="martomo" width="80" height="80"></a>
|
|
324
326
|
<a href="https://github.com/denis-sokolov"><img src="https://avatars.githubusercontent.com/u/113721?v=4" title="denis-sokolov" width="80" height="80"></a>
|
|
325
327
|
<a href="https://github.com/lennym"><img src="https://avatars.githubusercontent.com/u/117398?v=4" title="lennym" width="80" height="80"></a>
|
|
326
|
-
<a href="https://github.com/petehouston"><img src="https://avatars.githubusercontent.com/u/9006720?v=4" title="petehouston" width="80" height="80"></a>
|
|
327
|
-
<a href="https://github.com/jancorvus"><img src="https://avatars.githubusercontent.com/u/67001310?v=4" title="jancorvus" width="80" height="80"></a>
|
|
328
328
|
|
|
329
329
|
[//]: contributor-faces
|
|
330
330
|
|
package/docs/ai.md
CHANGED
|
@@ -3,6 +3,8 @@ permalink: /ai
|
|
|
3
3
|
title: Testing with AI đĒ
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
# đĒ Testing with AI
|
|
7
|
+
|
|
6
8
|
**CodeceptJS is the first open-source test automation framework with AI** features to improve the testing experience. CodeceptJS uses OpenAI GPT to auto-heal failing tests, assist in writing tests, and more...
|
|
7
9
|
|
|
8
10
|
Think of it as your testing co-pilot built into the testing framework
|
|
@@ -22,7 +24,7 @@ CodeceptJS AI can do the following:
|
|
|
22
24
|
* đ **self-heal failing tests** (can be used on CI)
|
|
23
25
|
* đŦ send arbitrary prompts to GPT from any tested page attaching its HTML contents
|
|
24
26
|
|
|
25
|
-

|
|
26
28
|
|
|
27
29
|
### How it works
|
|
28
30
|
|
|
@@ -32,7 +34,7 @@ GPT models have limits on information passed, and HTML pages can be huge. And so
|
|
|
32
34
|
|
|
33
35
|
Even though, the HTML is still quite big and may exceed the token limit. So we recommend using **gpt-3.5-turbo-16k** model, as it accepts 16K tokens (approx. 50K of HTML text), which should be enough for most web pages. It is possible to strictly limit the size of HTML to not exceed GPT tokens limit.
|
|
34
36
|
|
|
35
|
-
>
|
|
37
|
+
> âAI features require sending HTML contents to OpenAI. If you use it in enterprise, ensure that your company requirements match [OpenAI complience](https://openai.com/security). If you work on public web applications this should be ok, as HTML code is genrally available to all web application users.
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
### Getting Started
|
|
@@ -88,17 +90,17 @@ When pause mode started you can ask GPT to fill in the fields on this page. Use
|
|
|
88
90
|
I.fill checkout form with valid values without submitting it
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-

|
|
92
94
|
|
|
93
95
|
GPT will generate code and data and CodeceptJS will try to execute its code. If it succeeds, the code will be saved to history and you will be able to copy it to your test.
|
|
94
96
|
|
|
95
|
-

|
|
96
98
|
|
|
97
99
|
This AI copilot works best with long static forms. In the case of complex and dynamic single-page applications, it may not perform as well, as the form may not be present on HTML page yet. For instance, interacting with calendars or inputs with real-time validations (like credit cards) can not yet be performed by AI.
|
|
98
100
|
|
|
99
101
|
Please keep in mind that GPT can't react to page changes and operates with static text only. This is why it is not ready yet to write the test completely. However, if you are new to CodeceptJS and automated testing AI copilot may help you write tests more efficiently.
|
|
100
102
|
|
|
101
|
-
> đļ
|
|
103
|
+
> đļ Enable AI copilot for junior test automation engineers. It may help them to get started with CodeceptJS and to write good semantic locators.
|
|
102
104
|
|
|
103
105
|
### Self-Healing Tests
|
|
104
106
|
|
|
@@ -110,7 +112,7 @@ Heal actions **work only on actions like `click`, `fillField`**, etc, and won't
|
|
|
110
112
|
|
|
111
113
|
If Heal plugin successfully fixes the step, it will print a suggested change at the end of execution. Take it as actionable advice and use it to update the codebase. Heal plugin is supposed to be used on CI, and works automatically without human assistance.
|
|
112
114
|
|
|
113
|
-
To start, enable `heal` plugin in `codecept.conf.js
|
|
115
|
+
To start, enable `heal` plugin in `codecept.conf.js` or `codecept.conf.ts`:
|
|
114
116
|
|
|
115
117
|
```js
|
|
116
118
|
plugins: {
|
|
@@ -126,7 +128,7 @@ and run tests in AI mode with `OPENAI_API_KEY` provided:
|
|
|
126
128
|
OPENAI_API_KEY=sk-******** npx codeceptjs run
|
|
127
129
|
```
|
|
128
130
|
|
|
129
|
-

|
|
130
132
|
|
|
131
133
|
|
|
132
134
|
### Arbitrary GPT Prompts
|
|
@@ -153,7 +155,7 @@ Here are some good use cases for this helper:
|
|
|
153
155
|
const pageDoc = await I.askGptOnPageFragment('Act as technical writer, describe what is this page for', '#container');
|
|
154
156
|
```
|
|
155
157
|
|
|
156
|
-
As of now, those use cases
|
|
158
|
+
As of now, those use cases do not apply to test automation but maybe you can apply them to your testing setup.
|
|
157
159
|
|
|
158
160
|
## Configuration
|
|
159
161
|
|
|
@@ -243,4 +245,4 @@ To debug AI features run tests with `DEBUG="codeceptjs:ai"` flag. This will prin
|
|
|
243
245
|
|
|
244
246
|
```
|
|
245
247
|
DEBUG="codeceptjs:ai" OPENAI_API_KEY=sk-******** npx codeceptjs run
|
|
246
|
-
```
|
|
248
|
+
```
|
package/docs/build/Playwright.js
CHANGED
|
@@ -52,13 +52,13 @@ const pathSeparator = path.sep;
|
|
|
52
52
|
/**
|
|
53
53
|
* ## Configuration
|
|
54
54
|
*
|
|
55
|
-
* This helper should be configured in codecept.conf.js
|
|
55
|
+
* This helper should be configured in codecept.conf.(js|ts)
|
|
56
56
|
*
|
|
57
57
|
* @typedef PlaywrightConfig
|
|
58
58
|
* @type {object}
|
|
59
|
-
* @prop {string} url - base url of website to be tested
|
|
59
|
+
* @prop {string} [url] - base url of website to be tested
|
|
60
60
|
* @prop {'chromium' | 'firefox'| 'webkit' | 'electron'} [browser='chromium'] - a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
|
|
61
|
-
* @prop {boolean} [show=
|
|
61
|
+
* @prop {boolean} [show=true] - show browser window.
|
|
62
62
|
* @prop {string|boolean} [restart=false] - restart strategy between tests. Possible values:
|
|
63
63
|
* * 'context' or **false** - restarts [browser context](https://playwright.dev/docs/api/class-browsercontext) but keeps running browser. Recommended by Playwright team to keep tests isolated.
|
|
64
64
|
* * 'browser' or **true** - closes browser and opens it again between tests.
|
|
@@ -260,6 +260,22 @@ const config = {};
|
|
|
260
260
|
* }
|
|
261
261
|
* ```
|
|
262
262
|
*
|
|
263
|
+
* * #### Example #9: Launch electron test
|
|
264
|
+
*
|
|
265
|
+
* ```js
|
|
266
|
+
* {
|
|
267
|
+
* helpers: {
|
|
268
|
+
* Playwright: {
|
|
269
|
+
* browser: 'electron',
|
|
270
|
+
* electron: {
|
|
271
|
+
* executablePath: require("electron"),
|
|
272
|
+
* args: [path.join('../', "main.js")],
|
|
273
|
+
* },
|
|
274
|
+
* }
|
|
275
|
+
* },
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
263
279
|
* Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
264
280
|
*
|
|
265
281
|
* ## Access From Helpers
|
|
@@ -373,15 +389,24 @@ class Playwright extends Helper {
|
|
|
373
389
|
|
|
374
390
|
static _config() {
|
|
375
391
|
return [
|
|
376
|
-
{ name: 'url', message: 'Base url of site to be tested', default: 'http://localhost' },
|
|
377
|
-
{
|
|
378
|
-
name: 'show', message: 'Show browser window', default: true, type: 'confirm',
|
|
379
|
-
},
|
|
380
392
|
{
|
|
381
393
|
name: 'browser',
|
|
382
394
|
message: 'Browser in which testing will be performed. Possible options: chromium, firefox, webkit or electron',
|
|
383
395
|
default: 'chromium',
|
|
384
396
|
},
|
|
397
|
+
{
|
|
398
|
+
name: 'url',
|
|
399
|
+
message: 'Base url of site to be tested',
|
|
400
|
+
default: 'http://localhost',
|
|
401
|
+
when: (answers) => answers.Playwright_browser !== 'electron',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: 'show',
|
|
405
|
+
message: 'Show browser window',
|
|
406
|
+
default: true,
|
|
407
|
+
type: 'confirm',
|
|
408
|
+
when: (answers) => answers.Playwright_browser !== 'electron',
|
|
409
|
+
},
|
|
385
410
|
];
|
|
386
411
|
}
|
|
387
412
|
|
|
@@ -945,16 +970,18 @@ class Playwright extends Helper {
|
|
|
945
970
|
|
|
946
971
|
/**
|
|
947
972
|
* Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
|
948
|
-
*
|
|
949
|
-
* @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
950
|
-
*
|
|
973
|
+
*
|
|
951
974
|
* Examples:
|
|
952
|
-
*
|
|
975
|
+
*
|
|
953
976
|
* ```js
|
|
954
977
|
* I.dontSee('#add-to-cart-btn');
|
|
955
978
|
* I.focus('#product-tile')
|
|
956
979
|
* I.see('#add-to-cart-bnt');
|
|
957
980
|
* ```
|
|
981
|
+
*
|
|
982
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
983
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
984
|
+
*
|
|
958
985
|
*
|
|
959
986
|
*/
|
|
960
987
|
async focus(locator, options = {}) {
|
|
@@ -967,13 +994,11 @@ class Playwright extends Helper {
|
|
|
967
994
|
}
|
|
968
995
|
|
|
969
996
|
/**
|
|
970
|
-
* Remove focus from a text input, button, etc
|
|
971
|
-
* Calls [blur](https://
|
|
972
|
-
*
|
|
973
|
-
* @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
974
|
-
*
|
|
997
|
+
* Remove focus from a text input, button, etc.
|
|
998
|
+
* Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
999
|
+
*
|
|
975
1000
|
* Examples:
|
|
976
|
-
*
|
|
1001
|
+
*
|
|
977
1002
|
* ```js
|
|
978
1003
|
* I.blur('.text-area')
|
|
979
1004
|
* ```
|
|
@@ -983,6 +1008,10 @@ class Playwright extends Helper {
|
|
|
983
1008
|
* I.blur('#product-tile')
|
|
984
1009
|
* I.dontSee('#add-to-cart-btn');
|
|
985
1010
|
* ```
|
|
1011
|
+
*
|
|
1012
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1013
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
1014
|
+
*
|
|
986
1015
|
*
|
|
987
1016
|
*/
|
|
988
1017
|
async blur(locator, options = {}) {
|
|
@@ -1943,18 +1972,21 @@ class Playwright extends Helper {
|
|
|
1943
1972
|
}
|
|
1944
1973
|
|
|
1945
1974
|
/**
|
|
1946
|
-
*
|
|
1975
|
+
* Clears the text input element: `<input>`, `<textarea>` or `[contenteditable]` .
|
|
1976
|
+
*
|
|
1977
|
+
*
|
|
1978
|
+
* Examples:
|
|
1979
|
+
*
|
|
1980
|
+
* ```js
|
|
1981
|
+
* I.clearField('.text-area')
|
|
1982
|
+
*
|
|
1983
|
+
* // if this doesn't work use force option
|
|
1984
|
+
* I.clearField('#submit', { force: true })
|
|
1985
|
+
* ```
|
|
1986
|
+
* Use `force` to bypass the [actionability](https://playwright.dev/docs/actionability) checks.
|
|
1987
|
+
*
|
|
1947
1988
|
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1948
1989
|
* @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-locator#locator-clear) for available options object as 2nd argument.
|
|
1949
|
-
*
|
|
1950
|
-
* Examples:
|
|
1951
|
-
*
|
|
1952
|
-
* ```js
|
|
1953
|
-
* I.clearField('.text-area')
|
|
1954
|
-
* ```
|
|
1955
|
-
* ```js
|
|
1956
|
-
* I.clearField('#submit', { force: true }) // force to bypass the [actionability](https://playwright.dev/docs/actionability) checks.
|
|
1957
|
-
* ```
|
|
1958
1990
|
*/
|
|
1959
1991
|
async clearField(locator, options = {}) {
|
|
1960
1992
|
let result;
|
package/docs/build/Puppeteer.js
CHANGED
|
@@ -35,6 +35,8 @@ const Popup = require('./extras/Popup');
|
|
|
35
35
|
const Console = require('./extras/Console');
|
|
36
36
|
const findReact = require('./extras/React');
|
|
37
37
|
const { highlightElement } = require('./scripts/highlightElement');
|
|
38
|
+
const { blurElement } = require('./scripts/blurElement');
|
|
39
|
+
const { focusElement } = require('./scripts/focusElement');
|
|
38
40
|
|
|
39
41
|
let puppeteer;
|
|
40
42
|
let perfTiming;
|
|
@@ -743,6 +745,60 @@ class Puppeteer extends Helper {
|
|
|
743
745
|
return this._waitForAction();
|
|
744
746
|
}
|
|
745
747
|
|
|
748
|
+
/**
|
|
749
|
+
* Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
|
750
|
+
*
|
|
751
|
+
* Examples:
|
|
752
|
+
*
|
|
753
|
+
* ```js
|
|
754
|
+
* I.dontSee('#add-to-cart-btn');
|
|
755
|
+
* I.focus('#product-tile')
|
|
756
|
+
* I.see('#add-to-cart-bnt');
|
|
757
|
+
* ```
|
|
758
|
+
*
|
|
759
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
760
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
761
|
+
*
|
|
762
|
+
*
|
|
763
|
+
*/
|
|
764
|
+
async focus(locator) {
|
|
765
|
+
const els = await this._locate(locator);
|
|
766
|
+
assertElementExists(els, locator, 'Element to focus');
|
|
767
|
+
const el = els[0];
|
|
768
|
+
|
|
769
|
+
await focusElement(el, this.page);
|
|
770
|
+
return this._waitForAction();
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Remove focus from a text input, button, etc.
|
|
775
|
+
* Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
776
|
+
*
|
|
777
|
+
* Examples:
|
|
778
|
+
*
|
|
779
|
+
* ```js
|
|
780
|
+
* I.blur('.text-area')
|
|
781
|
+
* ```
|
|
782
|
+
* ```js
|
|
783
|
+
* //element `#product-tile` is focused
|
|
784
|
+
* I.see('#add-to-cart-btn');
|
|
785
|
+
* I.blur('#product-tile')
|
|
786
|
+
* I.dontSee('#add-to-cart-btn');
|
|
787
|
+
* ```
|
|
788
|
+
*
|
|
789
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
790
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
791
|
+
*
|
|
792
|
+
*
|
|
793
|
+
*/
|
|
794
|
+
async blur(locator) {
|
|
795
|
+
const els = await this._locate(locator);
|
|
796
|
+
assertElementExists(els, locator, 'Element to blur');
|
|
797
|
+
|
|
798
|
+
await blurElement(els[0], this.page);
|
|
799
|
+
return this._waitForAction();
|
|
800
|
+
}
|
|
801
|
+
|
|
746
802
|
/**
|
|
747
803
|
* Drag an item to a destination element.
|
|
748
804
|
*
|
package/docs/build/TestCafe.js
CHANGED
|
@@ -362,6 +362,63 @@ class TestCafe extends Helper {
|
|
|
362
362
|
return this.t.resizeWindow(width, height).catch(mapError);
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
|
367
|
+
*
|
|
368
|
+
* Examples:
|
|
369
|
+
*
|
|
370
|
+
* ```js
|
|
371
|
+
* I.dontSee('#add-to-cart-btn');
|
|
372
|
+
* I.focus('#product-tile')
|
|
373
|
+
* I.see('#add-to-cart-bnt');
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
377
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
378
|
+
*
|
|
379
|
+
*
|
|
380
|
+
*/
|
|
381
|
+
async focus(locator) {
|
|
382
|
+
const els = await this._locate(locator);
|
|
383
|
+
await assertElementExists(els, locator, 'Element to focus');
|
|
384
|
+
const element = await els.nth(0);
|
|
385
|
+
|
|
386
|
+
const focusElement = ClientFunction(() => element().focus(), { boundTestRun: this.t, dependencies: { element } });
|
|
387
|
+
|
|
388
|
+
return focusElement();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Remove focus from a text input, button, etc.
|
|
393
|
+
* Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
394
|
+
*
|
|
395
|
+
* Examples:
|
|
396
|
+
*
|
|
397
|
+
* ```js
|
|
398
|
+
* I.blur('.text-area')
|
|
399
|
+
* ```
|
|
400
|
+
* ```js
|
|
401
|
+
* //element `#product-tile` is focused
|
|
402
|
+
* I.see('#add-to-cart-btn');
|
|
403
|
+
* I.blur('#product-tile')
|
|
404
|
+
* I.dontSee('#add-to-cart-btn');
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
408
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
409
|
+
*
|
|
410
|
+
*
|
|
411
|
+
*/
|
|
412
|
+
async blur(locator) {
|
|
413
|
+
const els = await this._locate(locator);
|
|
414
|
+
await assertElementExists(els, locator, 'Element to blur');
|
|
415
|
+
const element = await els.nth(0);
|
|
416
|
+
|
|
417
|
+
const blurElement = ClientFunction(() => element().blur(), { boundTestRun: this.t, dependencies: { element } });
|
|
418
|
+
|
|
419
|
+
return blurElement();
|
|
420
|
+
}
|
|
421
|
+
|
|
365
422
|
/**
|
|
366
423
|
* Perform a click on a link or a button, given by a locator.
|
|
367
424
|
* If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
@@ -1214,7 +1271,7 @@ class TestCafe extends Helper {
|
|
|
1214
1271
|
* â ī¸ returns a _promise_ which is synchronized internally by recorder
|
|
1215
1272
|
*
|
|
1216
1273
|
*
|
|
1217
|
-
* If a function returns a Promise It will wait for
|
|
1274
|
+
* If a function returns a Promise It will wait for its resolution.
|
|
1218
1275
|
*/
|
|
1219
1276
|
async executeScript(fn, ...args) {
|
|
1220
1277
|
const browserFn = createClientFunction(fn, args).with({ boundTestRun: this.t });
|
package/docs/build/WebDriver.js
CHANGED
|
@@ -30,6 +30,8 @@ const ConnectionRefused = require('./errors/ConnectionRefused');
|
|
|
30
30
|
const Locator = require('../locator');
|
|
31
31
|
const { highlightElement } = require('./scripts/highlightElement');
|
|
32
32
|
const store = require('../store');
|
|
33
|
+
const { focusElement } = require('./scripts/focusElement');
|
|
34
|
+
const { blurElement } = require('./scripts/blurElement');
|
|
33
35
|
|
|
34
36
|
const SHADOW = 'shadow';
|
|
35
37
|
const webRoot = 'body';
|
|
@@ -2764,6 +2766,59 @@ class WebDriver extends Helper {
|
|
|
2764
2766
|
}
|
|
2765
2767
|
}
|
|
2766
2768
|
|
|
2769
|
+
/**
|
|
2770
|
+
* Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
|
2771
|
+
*
|
|
2772
|
+
* Examples:
|
|
2773
|
+
*
|
|
2774
|
+
* ```js
|
|
2775
|
+
* I.dontSee('#add-to-cart-btn');
|
|
2776
|
+
* I.focus('#product-tile')
|
|
2777
|
+
* I.see('#add-to-cart-bnt');
|
|
2778
|
+
* ```
|
|
2779
|
+
*
|
|
2780
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2781
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
2782
|
+
*
|
|
2783
|
+
*
|
|
2784
|
+
*/
|
|
2785
|
+
async focus(locator) {
|
|
2786
|
+
const els = await this._locate(locator);
|
|
2787
|
+
assertElementExists(els, locator, 'Element to focus');
|
|
2788
|
+
const el = usingFirstElement(els);
|
|
2789
|
+
|
|
2790
|
+
await focusElement(el, this.browser);
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/**
|
|
2794
|
+
* Remove focus from a text input, button, etc.
|
|
2795
|
+
* Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
2796
|
+
*
|
|
2797
|
+
* Examples:
|
|
2798
|
+
*
|
|
2799
|
+
* ```js
|
|
2800
|
+
* I.blur('.text-area')
|
|
2801
|
+
* ```
|
|
2802
|
+
* ```js
|
|
2803
|
+
* //element `#product-tile` is focused
|
|
2804
|
+
* I.see('#add-to-cart-btn');
|
|
2805
|
+
* I.blur('#product-tile')
|
|
2806
|
+
* I.dontSee('#add-to-cart-btn');
|
|
2807
|
+
* ```
|
|
2808
|
+
*
|
|
2809
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2810
|
+
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
2811
|
+
*
|
|
2812
|
+
*
|
|
2813
|
+
*/
|
|
2814
|
+
async blur(locator) {
|
|
2815
|
+
const els = await this._locate(locator);
|
|
2816
|
+
assertElementExists(els, locator, 'Element to blur');
|
|
2817
|
+
const el = usingFirstElement(els);
|
|
2818
|
+
|
|
2819
|
+
await blurElement(el, this.browser);
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2767
2822
|
/**
|
|
2768
2823
|
* Drag an item to a destination element.
|
|
2769
2824
|
*
|
package/docs/changelog.md
CHANGED
|
@@ -7,6 +7,26 @@ layout: Section
|
|
|
7
7
|
|
|
8
8
|
# Releases
|
|
9
9
|
|
|
10
|
+
## 3.5.1
|
|
11
|
+
|
|
12
|
+
đŠī¸ Features
|
|
13
|
+
|
|
14
|
+
* [Puppeteer][WebDriver][TestCafe] Added methods by **[KobeNguyenT](https://github.com/KobeNguyenT)** in [#3737](https://github.com/codeceptjs/CodeceptJS/issues/3737)
|
|
15
|
+
* `blur`
|
|
16
|
+
* `focus`
|
|
17
|
+
* Improved BDD output to print steps without `I.` commands` by **[davertmik](https://github.com/davertmik)** [#3739](https://github.com/codeceptjs/CodeceptJS/issues/3739)
|
|
18
|
+
* Improved `codecept init` setup for Electron tests by **[KobeNguyenT](https://github.com/KobeNguyenT)**. See [#3733](https://github.com/codeceptjs/CodeceptJS/issues/3733)
|
|
19
|
+
|
|
20
|
+
đ Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Fixed serializing of custom errors making tests stuck. Fix [#3739](https://github.com/codeceptjs/CodeceptJS/issues/3739) by **[davertmik](https://github.com/davertmik)**.
|
|
23
|
+
|
|
24
|
+
đ Documentation
|
|
25
|
+
|
|
26
|
+
* Fixed Playwright docs by **[Horsty80](https://github.com/Horsty80)**
|
|
27
|
+
* Fixed ai docs by **[ngraf](https://github.com/ngraf)**
|
|
28
|
+
* Various fixes by **[KobeNguyenT](https://github.com/KobeNguyenT)**
|
|
29
|
+
|
|
10
30
|
## 3.5.0
|
|
11
31
|
|
|
12
32
|
đŠī¸ Features
|