codeceptjs 3.5.2 → 3.5.4-beta.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/README.md +4 -5
- package/docs/basics.md +1 -2
- package/docs/build/Playwright.js +461 -0
- package/docs/changelog.md +0 -7
- package/docs/custom-helpers.md +2 -2
- package/docs/data.md +6 -2
- package/docs/docker.md +2 -3
- package/docs/helpers/Playwright.md +305 -153
- package/docs/installation.md +1 -1
- package/docs/mobile.md +0 -2
- package/docs/plugins.md +0 -2
- package/docs/quickstart.md +0 -1
- package/docs/testcafe.md +1 -1
- package/docs/webdriver.md +0 -2
- package/lib/command/init.js +1 -1
- package/lib/helper/Playwright.js +562 -136
- package/lib/helper/extras/PlaywrightReact.js +9 -0
- package/lib/plugin/standardActingHelpers.js +0 -2
- package/lib/plugin/wdio.js +0 -1
- package/lib/recorder.js +2 -1
- package/package.json +5 -7
- package/typings/index.d.ts +0 -1
- package/typings/promiseBasedTypes.d.ts +127 -0
- package/typings/types.d.ts +127 -25
- package/docs/helpers/Nightmare.md +0 -1258
- package/docs/nightmare.md +0 -223
- package/lib/helper/Nightmare.js +0 -1410
- package/lib/helper/Protractor.js +0 -1832
- package/lib/helper/clientscripts/nightmare.js +0 -213
|
@@ -41,40 +41,40 @@ Type: [object][5]
|
|
|
41
41
|
|
|
42
42
|
- `url` **[string][8]?** base url of website to be tested
|
|
43
43
|
- `browser` **(`"chromium"` | `"firefox"` | `"webkit"` | `"electron"`)?** a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
|
|
44
|
-
- `show` **[boolean][
|
|
45
|
-
- `restart` **([string][8] | [boolean][
|
|
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][39] but keeps running browser. Recommended by Playwright team to keep tests isolated.
|
|
46
46
|
- 'browser' or **true** - closes browser and opens it again between tests.
|
|
47
47
|
- '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][
|
|
49
|
-
- `disableScreenshots` **[boolean][
|
|
48
|
+
- `timeout` **[number][18]?** - [timeout][40] in ms of all Playwright actions .
|
|
49
|
+
- `disableScreenshots` **[boolean][32]?** don't save screenshot on failure.
|
|
50
50
|
- `emulate` **any?** browser in device emulation mode.
|
|
51
|
-
- `video` **[boolean][
|
|
52
|
-
- `keepVideoForPassedTests` **[boolean][
|
|
53
|
-
- `trace` **[boolean][
|
|
54
|
-
- `keepTraceForPassedTests` **[boolean][
|
|
55
|
-
- `fullPageScreenshots` **[boolean][
|
|
56
|
-
- `uniqueScreenshotNames` **[boolean][
|
|
57
|
-
- `keepBrowserState` **[boolean][
|
|
58
|
-
- `keepCookies` **[boolean][
|
|
59
|
-
- `waitForAction` **[number][
|
|
60
|
-
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"networkidle"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API][
|
|
61
|
-
- `pressKeyDelay` **[number][
|
|
62
|
-
- `getPageTimeout` **[number][
|
|
63
|
-
- `waitForTimeout` **[number][
|
|
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][41] 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'.
|
|
59
|
+
- `waitForAction` **[number][18]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
60
|
+
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"networkidle"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API][42].
|
|
61
|
+
- `pressKeyDelay` **[number][18]?** Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
|
|
62
|
+
- `getPageTimeout` **[number][18]?** config option to set maximum navigation time in milliseconds.
|
|
63
|
+
- `waitForTimeout` **[number][18]?** default wait* timeout in ms. Default: 1000.
|
|
64
64
|
- `basicAuth` **[object][5]?** the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
65
65
|
- `windowSize` **[string][8]?** default window size. Set a dimension like `640x480`.
|
|
66
66
|
- `colorScheme` **(`"dark"` | `"light"` | `"no-preference"`)?** default color scheme. Possible values: `dark` | `light` | `no-preference`.
|
|
67
67
|
- `userAgent` **[string][8]?** user-agent string.
|
|
68
68
|
- `locale` **[string][8]?** locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
69
|
-
- `manualStart` **[boolean][
|
|
69
|
+
- `manualStart` **[boolean][32]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
70
70
|
- `chromium` **[object][5]?** pass additional chromium options
|
|
71
71
|
- `firefox` **[object][5]?** pass additional firefox options
|
|
72
72
|
- `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][
|
|
74
|
-
- `ignoreLog` **[Array][
|
|
75
|
-
- `ignoreHTTPSErrors` **[boolean][
|
|
76
|
-
- `bypassCSP` **[boolean][
|
|
77
|
-
- `highlightElement` **[boolean][
|
|
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][22]<[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
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
@@ -299,7 +299,7 @@ const elements = await this.helpers['Playwright']._locate({name: 'password'});
|
|
|
299
299
|
|
|
300
300
|
### _locateCheckable
|
|
301
301
|
|
|
302
|
-
Find a checkbox by providing human
|
|
302
|
+
Find a checkbox by providing human-readable text:
|
|
303
303
|
NOTE: Assumes the checkable element exists
|
|
304
304
|
|
|
305
305
|
```js
|
|
@@ -313,7 +313,7 @@ this.helpers['Playwright']._locateCheckable('I agree with terms and conditions')
|
|
|
313
313
|
|
|
314
314
|
### _locateClickable
|
|
315
315
|
|
|
316
|
-
Find a clickable element by providing human
|
|
316
|
+
Find a clickable element by providing human-readable text:
|
|
317
317
|
|
|
318
318
|
```js
|
|
319
319
|
this.helpers['Playwright']._locateClickable('Next page').then // ...
|
|
@@ -323,9 +323,22 @@ this.helpers['Playwright']._locateClickable('Next page').then // ...
|
|
|
323
323
|
|
|
324
324
|
- `locator`
|
|
325
325
|
|
|
326
|
+
### _locateElement
|
|
327
|
+
|
|
328
|
+
Get the first element by different locator types, including strict locator
|
|
329
|
+
Should be used in custom helpers:
|
|
330
|
+
|
|
331
|
+
```js
|
|
332
|
+
const element = await this.helpers['Playwright']._locateElement({name: 'password'});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### Parameters
|
|
336
|
+
|
|
337
|
+
- `locator`
|
|
338
|
+
|
|
326
339
|
### _locateFields
|
|
327
340
|
|
|
328
|
-
Find field elements by providing human
|
|
341
|
+
Find field elements by providing human-readable text:
|
|
329
342
|
|
|
330
343
|
```js
|
|
331
344
|
this.helpers['Playwright']._locateFields('Your email').then // ...
|
|
@@ -422,10 +435,27 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
422
435
|
- `pathToFile` **[string][8]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
423
436
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
424
437
|
|
|
438
|
+
### blockTraffic
|
|
439
|
+
|
|
440
|
+
Blocks traffic for URL.
|
|
441
|
+
|
|
442
|
+
Examples:
|
|
443
|
+
|
|
444
|
+
```js
|
|
445
|
+
I.blockTraffic('http://example.com/css/style.css');
|
|
446
|
+
I.blockTraffic('http://example.com/css/*.css');
|
|
447
|
+
I.blockTraffic('http://example.com/**');
|
|
448
|
+
I.blockTraffic(/.css$/);
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### Parameters
|
|
452
|
+
|
|
453
|
+
- `url` URL to block . URL can contain * for wildcards. Example: [https://www.example.com**][9] to block all traffic for that domain. Regexp are also supported.
|
|
454
|
+
|
|
425
455
|
### blur
|
|
426
456
|
|
|
427
457
|
Remove focus from a text input, button, etc.
|
|
428
|
-
Calls [blur][
|
|
458
|
+
Calls [blur][10] on the element.
|
|
429
459
|
|
|
430
460
|
Examples:
|
|
431
461
|
|
|
@@ -443,7 +473,7 @@ I.dontSee('#add-to-cart-btn');
|
|
|
443
473
|
#### Parameters
|
|
444
474
|
|
|
445
475
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
446
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
476
|
+
- `options` **any?** Playwright only: [Additional options][11] for available options object as 2nd argument.
|
|
447
477
|
|
|
448
478
|
### cancelPopup
|
|
449
479
|
|
|
@@ -466,7 +496,7 @@ I.checkOption('agree', '//form');
|
|
|
466
496
|
|
|
467
497
|
- `field` **([string][8] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
468
498
|
- `context` **([string][8]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
469
|
-
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][
|
|
499
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][12] for check available as 3rd argument.Examples:```js
|
|
470
500
|
// click on element at position
|
|
471
501
|
I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
472
502
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -500,12 +530,12 @@ I.clearField('.text-area')
|
|
|
500
530
|
I.clearField('#submit', { force: true })
|
|
501
531
|
```
|
|
502
532
|
|
|
503
|
-
Use `force` to bypass the [actionability][
|
|
533
|
+
Use `force` to bypass the [actionability][13] checks.
|
|
504
534
|
|
|
505
535
|
#### Parameters
|
|
506
536
|
|
|
507
537
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
508
|
-
- `options` **any?** [Additional options][
|
|
538
|
+
- `options` **any?** [Additional options][14] for available options object as 2nd argument.
|
|
509
539
|
|
|
510
540
|
### click
|
|
511
541
|
|
|
@@ -536,7 +566,7 @@ I.click({css: 'nav a.login'});
|
|
|
536
566
|
- `locator` **([string][8] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
537
567
|
- `context` **([string][8]? | [object][5] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
538
568
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
539
|
-
- `options` **any?** [Additional options][
|
|
569
|
+
- `options` **any?** [Additional options][15] for click available as 3rd argument.Examples:```js
|
|
540
570
|
// click on element at position
|
|
541
571
|
I.click('canvas', '.model', { position: { x: 20, y: 40 } })
|
|
542
572
|
|
|
@@ -706,6 +736,23 @@ I.dontSeeInTitle('Error');
|
|
|
706
736
|
- `text` **[string][8]** value to check.
|
|
707
737
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
708
738
|
|
|
739
|
+
### dontSeeTraffic
|
|
740
|
+
|
|
741
|
+
Verifies that a certain request is not part of network traffic.
|
|
742
|
+
|
|
743
|
+
Examples:
|
|
744
|
+
|
|
745
|
+
```js
|
|
746
|
+
I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
|
|
747
|
+
I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
#### Parameters
|
|
751
|
+
|
|
752
|
+
- `opts` **[Object][5]** options when checking the traffic network.
|
|
753
|
+
- `opts.name` **[string][8]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
|
|
754
|
+
- `opts.url` **([string][8] | [RegExp][16])** Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
755
|
+
|
|
709
756
|
### doubleClick
|
|
710
757
|
|
|
711
758
|
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
@@ -737,7 +784,7 @@ I.dragAndDrop('#dragHandle', '#container');
|
|
|
737
784
|
- `srcElement` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
738
785
|
- `destElement` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
739
786
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
740
|
-
- `options` **any?** [Additional options][
|
|
787
|
+
- `options` **any?** [Additional options][17] can be passed as 3rd argument.```js
|
|
741
788
|
// specify coordinates for source position
|
|
742
789
|
I.dragAndDrop('img.src', 'img.dst', { sourcePosition: {x: 10, y: 10} })
|
|
743
790
|
```> When no option is set, custom drag and drop would be used, to use the dragAndDrop API from Playwright, please set options, for example `force: true`
|
|
@@ -755,7 +802,7 @@ I.dragSlider('#slider', -70);
|
|
|
755
802
|
#### Parameters
|
|
756
803
|
|
|
757
804
|
- `locator` **([string][8] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
758
|
-
- `offsetX` **[number][
|
|
805
|
+
- `offsetX` **[number][18]** position to drag.
|
|
759
806
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
760
807
|
|
|
761
808
|
### executeScript
|
|
@@ -783,10 +830,10 @@ If a function returns a Promise it will wait for its resolution.
|
|
|
783
830
|
|
|
784
831
|
#### Parameters
|
|
785
832
|
|
|
786
|
-
- `fn` **([string][8] | [function][
|
|
833
|
+
- `fn` **([string][8] | [function][19])** function to be executed in browser context.
|
|
787
834
|
- `arg` **any?** optional argument to pass to the function
|
|
788
835
|
|
|
789
|
-
Returns **[Promise][
|
|
836
|
+
Returns **[Promise][20]<any>**
|
|
790
837
|
|
|
791
838
|
### fillField
|
|
792
839
|
|
|
@@ -810,9 +857,13 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
810
857
|
- `value` **([string][8] | [object][5])** text value to fill.
|
|
811
858
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
812
859
|
|
|
860
|
+
### flushNetworkTraffics
|
|
861
|
+
|
|
862
|
+
Resets all recorded network requests.
|
|
863
|
+
|
|
813
864
|
### focus
|
|
814
865
|
|
|
815
|
-
Calls [focus][
|
|
866
|
+
Calls [focus][10] on the matching element.
|
|
816
867
|
|
|
817
868
|
Examples:
|
|
818
869
|
|
|
@@ -825,7 +876,7 @@ I.see('#add-to-cart-bnt');
|
|
|
825
876
|
#### Parameters
|
|
826
877
|
|
|
827
878
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
828
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
879
|
+
- `options` **any?** Playwright only: [Additional options][21] for available options object as 2nd argument.
|
|
829
880
|
|
|
830
881
|
### forceClick
|
|
831
882
|
|
|
@@ -875,7 +926,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
875
926
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
876
927
|
- `attr` **[string][8]** attribute name.
|
|
877
928
|
|
|
878
|
-
Returns **[Promise][
|
|
929
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
879
930
|
|
|
880
931
|
### grabAttributeFromAll
|
|
881
932
|
|
|
@@ -891,7 +942,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
891
942
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
892
943
|
- `attr` **[string][8]** attribute name.
|
|
893
944
|
|
|
894
|
-
Returns **[Promise][
|
|
945
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
895
946
|
|
|
896
947
|
### grabBrowserLogs
|
|
897
948
|
|
|
@@ -903,9 +954,9 @@ const errors = logs.map(l => ({ type: l.type(), text: l.text() })).filter(l => l
|
|
|
903
954
|
console.log(JSON.stringify(errors));
|
|
904
955
|
```
|
|
905
956
|
|
|
906
|
-
[Learn more about console messages][
|
|
957
|
+
[Learn more about console messages][23]
|
|
907
958
|
|
|
908
|
-
Returns **[Promise][
|
|
959
|
+
Returns **[Promise][20]<[Array][22]<any>>**
|
|
909
960
|
|
|
910
961
|
### grabCookie
|
|
911
962
|
|
|
@@ -922,7 +973,7 @@ assert(cookie.value, '123456');
|
|
|
922
973
|
|
|
923
974
|
- `name` **[string][8]?** cookie name.
|
|
924
975
|
|
|
925
|
-
Returns **([Promise][
|
|
976
|
+
Returns **([Promise][20]<[string][8]> | [Promise][20]<[Array][22]<[string][8]>>)** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
926
977
|
|
|
927
978
|
### grabCssPropertyFrom
|
|
928
979
|
|
|
@@ -939,7 +990,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
939
990
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
940
991
|
- `cssProperty` **[string][8]** CSS property name.
|
|
941
992
|
|
|
942
|
-
Returns **[Promise][
|
|
993
|
+
Returns **[Promise][20]<[string][8]>** CSS value
|
|
943
994
|
|
|
944
995
|
### grabCssPropertyFromAll
|
|
945
996
|
|
|
@@ -955,7 +1006,7 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
955
1006
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
956
1007
|
- `cssProperty` **[string][8]** CSS property name.
|
|
957
1008
|
|
|
958
|
-
Returns **[Promise][
|
|
1009
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** CSS value
|
|
959
1010
|
|
|
960
1011
|
### grabCurrentUrl
|
|
961
1012
|
|
|
@@ -967,7 +1018,7 @@ let url = await I.grabCurrentUrl();
|
|
|
967
1018
|
console.log(`Current URL is [${url}]`);
|
|
968
1019
|
```
|
|
969
1020
|
|
|
970
|
-
Returns **[Promise][
|
|
1021
|
+
Returns **[Promise][20]<[string][8]>** current URL
|
|
971
1022
|
|
|
972
1023
|
### grabDataFromPerformanceTiming
|
|
973
1024
|
|
|
@@ -992,7 +1043,7 @@ let data = await I.grabDataFromPerformanceTiming();
|
|
|
992
1043
|
}
|
|
993
1044
|
```
|
|
994
1045
|
|
|
995
|
-
Returns **[Promise][
|
|
1046
|
+
Returns **[Promise][20]<any>** automatically synchronized promise through #recorder
|
|
996
1047
|
|
|
997
1048
|
### grabElementBoundingRect
|
|
998
1049
|
|
|
@@ -1020,7 +1071,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
1020
1071
|
- `prop`
|
|
1021
1072
|
- `elementSize` **[string][8]?** x, y, width or height of the given element.
|
|
1022
1073
|
|
|
1023
|
-
Returns **([Promise][
|
|
1074
|
+
Returns **([Promise][20]<DOMRect> | [Promise][20]<[number][18]>)** Element bounding rectangle
|
|
1024
1075
|
|
|
1025
1076
|
### grabHTMLFrom
|
|
1026
1077
|
|
|
@@ -1037,7 +1088,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
1037
1088
|
- `locator`
|
|
1038
1089
|
- `element` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1039
1090
|
|
|
1040
|
-
Returns **[Promise][
|
|
1091
|
+
Returns **[Promise][20]<[string][8]>** HTML code for an element
|
|
1041
1092
|
|
|
1042
1093
|
### grabHTMLFromAll
|
|
1043
1094
|
|
|
@@ -1053,7 +1104,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
1053
1104
|
- `locator`
|
|
1054
1105
|
- `element` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1055
1106
|
|
|
1056
|
-
Returns **[Promise][
|
|
1107
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** HTML code for an element
|
|
1057
1108
|
|
|
1058
1109
|
### grabNumberOfOpenTabs
|
|
1059
1110
|
|
|
@@ -1064,7 +1115,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1064
1115
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
1065
1116
|
```
|
|
1066
1117
|
|
|
1067
|
-
Returns **[Promise][
|
|
1118
|
+
Returns **[Promise][20]<[number][18]>** number of open tabs
|
|
1068
1119
|
|
|
1069
1120
|
### grabNumberOfVisibleElements
|
|
1070
1121
|
|
|
@@ -1079,7 +1130,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
1079
1130
|
|
|
1080
1131
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1081
1132
|
|
|
1082
|
-
Returns **[Promise][
|
|
1133
|
+
Returns **[Promise][20]<[number][18]>** number of visible elements
|
|
1083
1134
|
|
|
1084
1135
|
### grabPageScrollPosition
|
|
1085
1136
|
|
|
@@ -1090,7 +1141,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
1090
1141
|
let { x, y } = await I.grabPageScrollPosition();
|
|
1091
1142
|
```
|
|
1092
1143
|
|
|
1093
|
-
Returns **[Promise][
|
|
1144
|
+
Returns **[Promise][20]<PageScrollPosition>** scroll position
|
|
1094
1145
|
|
|
1095
1146
|
### grabPopupText
|
|
1096
1147
|
|
|
@@ -1100,7 +1151,13 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
1100
1151
|
await I.grabPopupText();
|
|
1101
1152
|
```
|
|
1102
1153
|
|
|
1103
|
-
Returns **[Promise][
|
|
1154
|
+
Returns **[Promise][20]<([string][8] | null)>**
|
|
1155
|
+
|
|
1156
|
+
### grabRecordedNetworkTraffics
|
|
1157
|
+
|
|
1158
|
+
Grab the recording network traffics
|
|
1159
|
+
|
|
1160
|
+
Returns **[Array][22]<any>**
|
|
1104
1161
|
|
|
1105
1162
|
### grabSource
|
|
1106
1163
|
|
|
@@ -1111,7 +1168,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1111
1168
|
let pageSource = await I.grabSource();
|
|
1112
1169
|
```
|
|
1113
1170
|
|
|
1114
|
-
Returns **[Promise][
|
|
1171
|
+
Returns **[Promise][20]<[string][8]>** source code
|
|
1115
1172
|
|
|
1116
1173
|
### grabTextFrom
|
|
1117
1174
|
|
|
@@ -1128,7 +1185,7 @@ If multiple elements found returns first element.
|
|
|
1128
1185
|
|
|
1129
1186
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1130
1187
|
|
|
1131
|
-
Returns **[Promise][
|
|
1188
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
1132
1189
|
|
|
1133
1190
|
### grabTextFromAll
|
|
1134
1191
|
|
|
@@ -1143,7 +1200,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
1143
1200
|
|
|
1144
1201
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1145
1202
|
|
|
1146
|
-
Returns **[Promise][
|
|
1203
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
1147
1204
|
|
|
1148
1205
|
### grabTitle
|
|
1149
1206
|
|
|
@@ -1154,7 +1211,20 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
1154
1211
|
let title = await I.grabTitle();
|
|
1155
1212
|
```
|
|
1156
1213
|
|
|
1157
|
-
Returns **[Promise][
|
|
1214
|
+
Returns **[Promise][20]<[string][8]>** title
|
|
1215
|
+
|
|
1216
|
+
### grabTrafficUrl
|
|
1217
|
+
|
|
1218
|
+
Returns full URL of request matching parameter "urlMatch".
|
|
1219
|
+
|
|
1220
|
+
#### Parameters
|
|
1221
|
+
|
|
1222
|
+
- `urlMatch` **([string][8] | [RegExp][16])** Expected URL of request in network traffic. Can be a string or a regular expression.Examples:```js
|
|
1223
|
+
I.grabTrafficUrl('https://api.example.com/session');
|
|
1224
|
+
I.grabTrafficUrl(/session.*start/);
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
Returns **[Promise][20]<any>**
|
|
1158
1228
|
|
|
1159
1229
|
### grabValueFrom
|
|
1160
1230
|
|
|
@@ -1170,7 +1240,7 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
1170
1240
|
|
|
1171
1241
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1172
1242
|
|
|
1173
|
-
Returns **[Promise][
|
|
1243
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
1174
1244
|
|
|
1175
1245
|
### grabValueFromAll
|
|
1176
1246
|
|
|
@@ -1185,14 +1255,14 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
1185
1255
|
|
|
1186
1256
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1187
1257
|
|
|
1188
|
-
Returns **[Promise][
|
|
1258
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
1189
1259
|
|
|
1190
1260
|
### handleDownloads
|
|
1191
1261
|
|
|
1192
1262
|
Handles a file download. A file name is required to save the file on disk.
|
|
1193
1263
|
Files are saved to "output" directory.
|
|
1194
1264
|
|
|
1195
|
-
Should be used with [FileSystem helper][
|
|
1265
|
+
Should be used with [FileSystem helper][24] to check that file were downloaded correctly.
|
|
1196
1266
|
|
|
1197
1267
|
```js
|
|
1198
1268
|
I.handleDownloads('downloads/avatar.jpg');
|
|
@@ -1205,7 +1275,7 @@ I.waitForFile('avatar.jpg', 5);
|
|
|
1205
1275
|
|
|
1206
1276
|
- `fileName` **[string][8]** set filename for downloaded file
|
|
1207
1277
|
|
|
1208
|
-
Returns **[Promise][
|
|
1278
|
+
Returns **[Promise][20]<void>**
|
|
1209
1279
|
|
|
1210
1280
|
### haveRequestHeaders
|
|
1211
1281
|
|
|
@@ -1223,7 +1293,7 @@ I.haveRequestHeaders({
|
|
|
1223
1293
|
|
|
1224
1294
|
### makeApiRequest
|
|
1225
1295
|
|
|
1226
|
-
Performs [api request][
|
|
1296
|
+
Performs [api request][25] using
|
|
1227
1297
|
the cookies from the current browser session.
|
|
1228
1298
|
|
|
1229
1299
|
```js
|
|
@@ -1240,22 +1310,41 @@ I.makeApiRequest('PATCH', )
|
|
|
1240
1310
|
- `url` **[string][8]** endpoint
|
|
1241
1311
|
- `options` **[object][5]** request options depending on method used
|
|
1242
1312
|
|
|
1243
|
-
Returns **[Promise][
|
|
1313
|
+
Returns **[Promise][20]<[object][5]>** response
|
|
1244
1314
|
|
|
1245
1315
|
### mockRoute
|
|
1246
1316
|
|
|
1247
|
-
Mocks network request using [`browserContext.route`][
|
|
1317
|
+
Mocks network request using [`browserContext.route`][26] of Playwright
|
|
1248
1318
|
|
|
1249
1319
|
```js
|
|
1250
1320
|
I.mockRoute(/(.png$)|(.jpg$)/, route => route.abort());
|
|
1251
1321
|
```
|
|
1252
1322
|
|
|
1253
|
-
This method allows intercepting and mocking requests & responses. [Learn more about it][
|
|
1323
|
+
This method allows intercepting and mocking requests & responses. [Learn more about it][27]
|
|
1324
|
+
|
|
1325
|
+
#### Parameters
|
|
1326
|
+
|
|
1327
|
+
- `url` **([string][8] | [RegExp][16])?** URL, regex or pattern for to match URL
|
|
1328
|
+
- `handler` **[function][19]?** a function to process reques
|
|
1329
|
+
|
|
1330
|
+
### mockTraffic
|
|
1331
|
+
|
|
1332
|
+
Mocks traffic for URL(s).
|
|
1333
|
+
This is a powerful feature to manipulate network traffic. Can be used e.g. to stabilize your tests, speed up your tests or as a last resort to make some test scenarios even possible.
|
|
1334
|
+
|
|
1335
|
+
Examples:
|
|
1336
|
+
|
|
1337
|
+
```js
|
|
1338
|
+
I.mockTraffic('/api/users/1', '{ id: 1, name: 'John Doe' }');
|
|
1339
|
+
I.mockTraffic('/api/users/*', JSON.stringify({ id: 1, name: 'John Doe' }));
|
|
1340
|
+
I.mockTraffic([/^https://api.example.com/v1/, 'https://api.example.com/v2/**'], 'Internal Server Error', 'text/html');
|
|
1341
|
+
```
|
|
1254
1342
|
|
|
1255
1343
|
#### Parameters
|
|
1256
1344
|
|
|
1257
|
-
- `
|
|
1258
|
-
- `
|
|
1345
|
+
- `urls` string|Array These are the URL(s) to mock, e.g. "/fooapi/_" or "['/fooapi_1/_', '/barapi_2/*']". Regular expressions are also supported.
|
|
1346
|
+
- `responseString` string The string to return in fake response's body.
|
|
1347
|
+
- `contentType` Content type of fake response. If not specified default value 'application/json' is used.
|
|
1259
1348
|
|
|
1260
1349
|
### moveCursorTo
|
|
1261
1350
|
|
|
@@ -1270,8 +1359,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1270
1359
|
#### Parameters
|
|
1271
1360
|
|
|
1272
1361
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1273
|
-
- `offsetX` **[number][
|
|
1274
|
-
- `offsetY` **[number][
|
|
1362
|
+
- `offsetX` **[number][18]** (optional, `0` by default) X-axis offset.
|
|
1363
|
+
- `offsetY` **[number][18]** (optional, `0` by default) Y-axis offset.
|
|
1275
1364
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1276
1365
|
|
|
1277
1366
|
### openNewTab
|
|
@@ -1282,7 +1371,7 @@ Open new tab and automatically switched to new tab
|
|
|
1282
1371
|
I.openNewTab();
|
|
1283
1372
|
```
|
|
1284
1373
|
|
|
1285
|
-
You can pass in [page options][
|
|
1374
|
+
You can pass in [page options][28] to emulate device on this page
|
|
1286
1375
|
|
|
1287
1376
|
```js
|
|
1288
1377
|
// enable mobile
|
|
@@ -1297,7 +1386,7 @@ I.openNewTab({ isMobile: true });
|
|
|
1297
1386
|
|
|
1298
1387
|
Presses a key in the browser (on a focused element).
|
|
1299
1388
|
|
|
1300
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1389
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][29].
|
|
1301
1390
|
|
|
1302
1391
|
```js
|
|
1303
1392
|
I.pressKey('Backspace');
|
|
@@ -1356,14 +1445,14 @@ Some of the supported key names are:
|
|
|
1356
1445
|
|
|
1357
1446
|
#### Parameters
|
|
1358
1447
|
|
|
1359
|
-
- `key` **([string][8] | [Array][
|
|
1360
|
-
⚠️ returns a _promise_ which is synchronized internally by recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][
|
|
1448
|
+
- `key` **([string][8] | [Array][22]<[string][8]>)** key or array of keys to press.
|
|
1449
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][30]).
|
|
1361
1450
|
|
|
1362
1451
|
### pressKeyDown
|
|
1363
1452
|
|
|
1364
1453
|
Presses a key in the browser and leaves it in a down state.
|
|
1365
1454
|
|
|
1366
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1455
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
|
|
1367
1456
|
|
|
1368
1457
|
```js
|
|
1369
1458
|
I.pressKeyDown('Control');
|
|
@@ -1380,7 +1469,7 @@ I.pressKeyUp('Control');
|
|
|
1380
1469
|
|
|
1381
1470
|
Releases a key in the browser which was previously set to a down state.
|
|
1382
1471
|
|
|
1383
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1472
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
|
|
1384
1473
|
|
|
1385
1474
|
```js
|
|
1386
1475
|
I.pressKeyDown('Control');
|
|
@@ -1410,8 +1499,8 @@ First parameter can be set to `maximize`.
|
|
|
1410
1499
|
|
|
1411
1500
|
#### Parameters
|
|
1412
1501
|
|
|
1413
|
-
- `width` **[number][
|
|
1414
|
-
- `height` **[number][
|
|
1502
|
+
- `width` **[number][18]** width in pixels or `maximize`.
|
|
1503
|
+
- `height` **[number][18]** height in pixels.
|
|
1415
1504
|
⚠️ returns a _promise_ which is synchronized internally by recorderUnlike other drivers Playwright changes the size of a viewport, not the window!
|
|
1416
1505
|
Playwright does not control the window of a browser so it can't adjust its real size.
|
|
1417
1506
|
It also can't maximize a window.Update configuration to change real window size on start:```js
|
|
@@ -1485,7 +1574,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1485
1574
|
#### Parameters
|
|
1486
1575
|
|
|
1487
1576
|
- `fileName` **[string][8]** file name to save.
|
|
1488
|
-
- `fullPage` **[boolean][
|
|
1577
|
+
- `fullPage` **[boolean][32]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1489
1578
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1490
1579
|
|
|
1491
1580
|
### scrollPageToBottom
|
|
@@ -1521,8 +1610,8 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1521
1610
|
#### Parameters
|
|
1522
1611
|
|
|
1523
1612
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1524
|
-
- `offsetX` **[number][
|
|
1525
|
-
- `offsetY` **[number][
|
|
1613
|
+
- `offsetX` **[number][18]** (optional, `0` by default) X-axis offset.
|
|
1614
|
+
- `offsetY` **[number][18]** (optional, `0` by default) Y-axis offset.
|
|
1526
1615
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1527
1616
|
|
|
1528
1617
|
### see
|
|
@@ -1725,7 +1814,7 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
1725
1814
|
#### Parameters
|
|
1726
1815
|
|
|
1727
1816
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1728
|
-
- `num` **[number][
|
|
1817
|
+
- `num` **[number][18]** number of elements.
|
|
1729
1818
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1730
1819
|
|
|
1731
1820
|
### seeNumberOfVisibleElements
|
|
@@ -1740,7 +1829,7 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1740
1829
|
#### Parameters
|
|
1741
1830
|
|
|
1742
1831
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1743
|
-
- `num` **[number][
|
|
1832
|
+
- `num` **[number][18]** number of elements.
|
|
1744
1833
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1745
1834
|
|
|
1746
1835
|
### seeTextEquals
|
|
@@ -1770,6 +1859,48 @@ I.seeTitleEquals('Test title.');
|
|
|
1770
1859
|
- `text` **[string][8]** value to check.
|
|
1771
1860
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1772
1861
|
|
|
1862
|
+
### seeTraffic
|
|
1863
|
+
|
|
1864
|
+
Verifies that a certain request is part of network traffic.
|
|
1865
|
+
|
|
1866
|
+
```js
|
|
1867
|
+
// checking the request url contains certain query strings
|
|
1868
|
+
I.amOnPage('https://openai.com/blog/chatgpt');
|
|
1869
|
+
I.startRecordingTraffic();
|
|
1870
|
+
await I.seeTraffic({
|
|
1871
|
+
name: 'sentry event',
|
|
1872
|
+
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
|
|
1873
|
+
parameters: {
|
|
1874
|
+
width: '1919',
|
|
1875
|
+
height: '1138',
|
|
1876
|
+
},
|
|
1877
|
+
});
|
|
1878
|
+
```
|
|
1879
|
+
|
|
1880
|
+
```js
|
|
1881
|
+
// checking the request url contains certain post data
|
|
1882
|
+
I.amOnPage('https://openai.com/blog/chatgpt');
|
|
1883
|
+
I.startRecordingTraffic();
|
|
1884
|
+
await I.seeTraffic({
|
|
1885
|
+
name: 'event',
|
|
1886
|
+
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
|
|
1887
|
+
requestPostData: {
|
|
1888
|
+
st: 2,
|
|
1889
|
+
},
|
|
1890
|
+
});
|
|
1891
|
+
```
|
|
1892
|
+
|
|
1893
|
+
#### Parameters
|
|
1894
|
+
|
|
1895
|
+
- `opts` **[Object][5]** options when checking the traffic network.
|
|
1896
|
+
- `opts.name` **[string][8]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
|
|
1897
|
+
- `opts.url` **[string][8]** Expected URL of request in network traffic
|
|
1898
|
+
- `opts.parameters` **[Object][5]?** Expected parameters of that request in network traffic
|
|
1899
|
+
- `opts.requestPostData` **[Object][5]?** Expected that request contains post data in network traffic
|
|
1900
|
+
- `opts.timeout` **[number][18]?** Timeout to wait for request in seconds. Default is 10 seconds.
|
|
1901
|
+
|
|
1902
|
+
Returns **[Promise][20]<any>**
|
|
1903
|
+
|
|
1773
1904
|
### selectOption
|
|
1774
1905
|
|
|
1775
1906
|
Selects an option in a drop-down select.
|
|
@@ -1794,7 +1925,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1794
1925
|
#### Parameters
|
|
1795
1926
|
|
|
1796
1927
|
- `select` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1797
|
-
- `option` **([string][8] | [Array][
|
|
1928
|
+
- `option` **([string][8] | [Array][22]<any>)** visible text or value of option.
|
|
1798
1929
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1799
1930
|
|
|
1800
1931
|
### setCookie
|
|
@@ -1815,9 +1946,20 @@ I.setCookie([
|
|
|
1815
1946
|
|
|
1816
1947
|
#### Parameters
|
|
1817
1948
|
|
|
1818
|
-
- `cookie` **(Cookie | [Array][
|
|
1949
|
+
- `cookie` **(Cookie | [Array][22]<Cookie>)** a cookie object or array of cookie objects.
|
|
1819
1950
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1820
1951
|
|
|
1952
|
+
### startRecordingTraffic
|
|
1953
|
+
|
|
1954
|
+
Starts recording of network traffic.
|
|
1955
|
+
This also resets recorded network requests.
|
|
1956
|
+
|
|
1957
|
+
```js
|
|
1958
|
+
I.startRecordingTraffic();
|
|
1959
|
+
```
|
|
1960
|
+
|
|
1961
|
+
Returns **[Promise][20]<void>**
|
|
1962
|
+
|
|
1821
1963
|
### stopMockingRoute
|
|
1822
1964
|
|
|
1823
1965
|
Stops network mocking created by `mockRoute`.
|
|
@@ -1831,8 +1973,16 @@ If no handler is passed, all mock requests for the rote are disabled.
|
|
|
1831
1973
|
|
|
1832
1974
|
#### Parameters
|
|
1833
1975
|
|
|
1834
|
-
- `url` **([string][8] | [RegExp][
|
|
1835
|
-
- `handler` **[function][
|
|
1976
|
+
- `url` **([string][8] | [RegExp][16])?** URL, regex or pattern for to match URL
|
|
1977
|
+
- `handler` **[function][19]?** a function to process reques
|
|
1978
|
+
|
|
1979
|
+
### stopRecordingTraffic
|
|
1980
|
+
|
|
1981
|
+
Stops recording of network traffic. Recorded traffic is not flashed.
|
|
1982
|
+
|
|
1983
|
+
```js
|
|
1984
|
+
I.stopRecordingTraffic();
|
|
1985
|
+
```
|
|
1836
1986
|
|
|
1837
1987
|
### switchTo
|
|
1838
1988
|
|
|
@@ -1859,7 +2009,7 @@ I.switchToNextTab(2);
|
|
|
1859
2009
|
|
|
1860
2010
|
#### Parameters
|
|
1861
2011
|
|
|
1862
|
-
- `num` **[number][
|
|
2012
|
+
- `num` **[number][18]**
|
|
1863
2013
|
|
|
1864
2014
|
### switchToPreviousTab
|
|
1865
2015
|
|
|
@@ -1872,13 +2022,13 @@ I.switchToPreviousTab(2);
|
|
|
1872
2022
|
|
|
1873
2023
|
#### Parameters
|
|
1874
2024
|
|
|
1875
|
-
- `num` **[number][
|
|
2025
|
+
- `num` **[number][18]**
|
|
1876
2026
|
|
|
1877
2027
|
### type
|
|
1878
2028
|
|
|
1879
2029
|
Types out the given text into an active field.
|
|
1880
2030
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
1881
|
-
_Note:_ Should be used when [`fillField`][
|
|
2031
|
+
_Note:_ Should be used when [`fillField`][29] is not an option.
|
|
1882
2032
|
|
|
1883
2033
|
```js
|
|
1884
2034
|
// passing in a string
|
|
@@ -1897,9 +2047,9 @@ I.type(secret('123456'));
|
|
|
1897
2047
|
#### Parameters
|
|
1898
2048
|
|
|
1899
2049
|
- `keys`
|
|
1900
|
-
- `delay` **[number][
|
|
2050
|
+
- `delay` **[number][18]?** (optional) delay in ms between key presses
|
|
1901
2051
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1902
|
-
- `key` **([string][8] | [Array][
|
|
2052
|
+
- `key` **([string][8] | [Array][22]<[string][8]>)** or array of keys to type.
|
|
1903
2053
|
|
|
1904
2054
|
### uncheckOption
|
|
1905
2055
|
|
|
@@ -1918,7 +2068,7 @@ I.uncheckOption('agree', '//form');
|
|
|
1918
2068
|
|
|
1919
2069
|
- `field` **([string][8] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
1920
2070
|
- `context` **([string][8]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1921
|
-
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][
|
|
2071
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][33] for uncheck available as 3rd argument.Examples:```js
|
|
1922
2072
|
// click on element at position
|
|
1923
2073
|
I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
1924
2074
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -1931,7 +2081,7 @@ Use Playwright API inside a test.
|
|
|
1931
2081
|
First argument is a description of an action.
|
|
1932
2082
|
Second argument is async function that gets this helper as parameter.
|
|
1933
2083
|
|
|
1934
|
-
{ [`page`][
|
|
2084
|
+
{ [`page`][34], [`browserContext`][35] [`browser`][36] } objects from Playwright API are available.
|
|
1935
2085
|
|
|
1936
2086
|
```js
|
|
1937
2087
|
I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
@@ -1942,7 +2092,7 @@ I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
|
1942
2092
|
#### Parameters
|
|
1943
2093
|
|
|
1944
2094
|
- `description` **[string][8]** used to show in logs.
|
|
1945
|
-
- `fn` **[function][
|
|
2095
|
+
- `fn` **[function][19]** async function that executed with Playwright helper as argumen
|
|
1946
2096
|
|
|
1947
2097
|
### wait
|
|
1948
2098
|
|
|
@@ -1954,7 +2104,7 @@ I.wait(2); // wait 2 secs
|
|
|
1954
2104
|
|
|
1955
2105
|
#### Parameters
|
|
1956
2106
|
|
|
1957
|
-
- `sec` **[number][
|
|
2107
|
+
- `sec` **[number][18]** number of second to wait.
|
|
1958
2108
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1959
2109
|
|
|
1960
2110
|
### waitForClickable
|
|
@@ -1971,7 +2121,7 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
|
1971
2121
|
|
|
1972
2122
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1973
2123
|
- `waitTimeout`
|
|
1974
|
-
- `sec` **[number][
|
|
2124
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
1975
2125
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1976
2126
|
|
|
1977
2127
|
### waitForDetached
|
|
@@ -1986,7 +2136,7 @@ I.waitForDetached('#popup');
|
|
|
1986
2136
|
#### Parameters
|
|
1987
2137
|
|
|
1988
2138
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1989
|
-
- `sec` **[number][
|
|
2139
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
1990
2140
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1991
2141
|
|
|
1992
2142
|
### waitForElement
|
|
@@ -2002,7 +2152,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
2002
2152
|
#### Parameters
|
|
2003
2153
|
|
|
2004
2154
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2005
|
-
- `sec` **[number][
|
|
2155
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
2006
2156
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2007
2157
|
|
|
2008
2158
|
### waitForEnabled
|
|
@@ -2013,7 +2163,7 @@ Element can be located by CSS or XPath.
|
|
|
2013
2163
|
#### Parameters
|
|
2014
2164
|
|
|
2015
2165
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2016
|
-
- `sec` **[number][
|
|
2166
|
+
- `sec` **[number][18]** (optional) time in seconds to wait, 1 by default.
|
|
2017
2167
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2018
2168
|
|
|
2019
2169
|
### waitForFunction
|
|
@@ -2033,9 +2183,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
2033
2183
|
|
|
2034
2184
|
#### Parameters
|
|
2035
2185
|
|
|
2036
|
-
- `fn` **([string][8] | [function][
|
|
2037
|
-
- `argsOrSec` **([Array][
|
|
2038
|
-
- `sec` **[number][
|
|
2186
|
+
- `fn` **([string][8] | [function][19])** to be executed in browser context.
|
|
2187
|
+
- `argsOrSec` **([Array][22]<any> | [number][18])?** (optional, `1` by default) arguments for function or seconds.
|
|
2188
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
2039
2189
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2040
2190
|
|
|
2041
2191
|
### waitForInvisible
|
|
@@ -2050,14 +2200,14 @@ I.waitForInvisible('#popup');
|
|
|
2050
2200
|
#### Parameters
|
|
2051
2201
|
|
|
2052
2202
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2053
|
-
- `sec` **[number][
|
|
2203
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2054
2204
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2055
2205
|
|
|
2056
2206
|
### waitForNavigation
|
|
2057
2207
|
|
|
2058
2208
|
Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
2059
2209
|
|
|
2060
|
-
See [Playwright's reference][
|
|
2210
|
+
See [Playwright's reference][37]
|
|
2061
2211
|
|
|
2062
2212
|
#### Parameters
|
|
2063
2213
|
|
|
@@ -2074,8 +2224,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
2074
2224
|
|
|
2075
2225
|
#### Parameters
|
|
2076
2226
|
|
|
2077
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
2078
|
-
- `sec` **[number][
|
|
2227
|
+
- `urlOrPredicate` **([string][8] | [function][19])**
|
|
2228
|
+
- `sec` **[number][18]?** seconds to wait
|
|
2079
2229
|
|
|
2080
2230
|
### waitForResponse
|
|
2081
2231
|
|
|
@@ -2088,8 +2238,8 @@ I.waitForResponse(response => response.url() === 'https://example.com' && respon
|
|
|
2088
2238
|
|
|
2089
2239
|
#### Parameters
|
|
2090
2240
|
|
|
2091
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
2092
|
-
- `sec` **[number][
|
|
2241
|
+
- `urlOrPredicate` **([string][8] | [function][19])**
|
|
2242
|
+
- `sec` **[number][18]?** number of seconds to wait
|
|
2093
2243
|
|
|
2094
2244
|
### waitForText
|
|
2095
2245
|
|
|
@@ -2105,7 +2255,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
2105
2255
|
#### Parameters
|
|
2106
2256
|
|
|
2107
2257
|
- `text` **[string][8]** to wait for.
|
|
2108
|
-
- `sec` **[number][
|
|
2258
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2109
2259
|
- `context` **([string][8] | [object][5])?** (optional) element located by CSS|XPath|strict locator.
|
|
2110
2260
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2111
2261
|
|
|
@@ -2121,7 +2271,7 @@ I.waitForValue('//input', "GoodValue");
|
|
|
2121
2271
|
|
|
2122
2272
|
- `field` **([string][8] | [object][5])** input field.
|
|
2123
2273
|
- `value` **[string][8]** expected value.
|
|
2124
|
-
- `sec` **[number][
|
|
2274
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2125
2275
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2126
2276
|
|
|
2127
2277
|
### waitForVisible
|
|
@@ -2136,8 +2286,8 @@ I.waitForVisible('#popup');
|
|
|
2136
2286
|
#### Parameters
|
|
2137
2287
|
|
|
2138
2288
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2139
|
-
- `sec` **[number][
|
|
2140
|
-
⚠️ returns a _promise_ which is synchronized internally by recorderThis method accepts [React selectors][
|
|
2289
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2290
|
+
⚠️ returns a _promise_ which is synchronized internally by recorderThis method accepts [React selectors][38].
|
|
2141
2291
|
|
|
2142
2292
|
### waitInUrl
|
|
2143
2293
|
|
|
@@ -2150,7 +2300,7 @@ I.waitInUrl('/info', 2);
|
|
|
2150
2300
|
#### Parameters
|
|
2151
2301
|
|
|
2152
2302
|
- `urlPart` **[string][8]** value to check.
|
|
2153
|
-
- `sec` **[number][
|
|
2303
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2154
2304
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2155
2305
|
|
|
2156
2306
|
### waitNumberOfVisibleElements
|
|
@@ -2164,8 +2314,8 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
2164
2314
|
#### Parameters
|
|
2165
2315
|
|
|
2166
2316
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2167
|
-
- `num` **[number][
|
|
2168
|
-
- `sec` **[number][
|
|
2317
|
+
- `num` **[number][18]** number of elements.
|
|
2318
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2169
2319
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2170
2320
|
|
|
2171
2321
|
### waitToHide
|
|
@@ -2180,7 +2330,7 @@ I.waitToHide('#popup');
|
|
|
2180
2330
|
#### Parameters
|
|
2181
2331
|
|
|
2182
2332
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2183
|
-
- `sec` **[number][
|
|
2333
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2184
2334
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2185
2335
|
|
|
2186
2336
|
### waitUrlEquals
|
|
@@ -2195,7 +2345,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2195
2345
|
#### Parameters
|
|
2196
2346
|
|
|
2197
2347
|
- `urlPart` **[string][8]** value to check.
|
|
2198
|
-
- `sec` **[number][
|
|
2348
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2199
2349
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2200
2350
|
|
|
2201
2351
|
[1]: https://github.com/microsoft/playwright
|
|
@@ -2214,72 +2364,74 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2214
2364
|
|
|
2215
2365
|
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
2216
2366
|
|
|
2217
|
-
[9]: https://
|
|
2367
|
+
[9]: https://www.example.com**
|
|
2368
|
+
|
|
2369
|
+
[10]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2218
2370
|
|
|
2219
|
-
[
|
|
2371
|
+
[11]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2220
2372
|
|
|
2221
|
-
[
|
|
2373
|
+
[12]: https://playwright.dev/docs/api/class-elementhandle#element-handle-check
|
|
2222
2374
|
|
|
2223
|
-
[
|
|
2375
|
+
[13]: https://playwright.dev/docs/actionability
|
|
2224
2376
|
|
|
2225
|
-
[
|
|
2377
|
+
[14]: https://playwright.dev/docs/api/class-locator#locator-clear
|
|
2226
2378
|
|
|
2227
|
-
[
|
|
2379
|
+
[15]: https://playwright.dev/docs/api/class-page#page-click
|
|
2228
2380
|
|
|
2229
|
-
[
|
|
2381
|
+
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
2230
2382
|
|
|
2231
|
-
[
|
|
2383
|
+
[17]: https://playwright.dev/docs/api/class-page#page-drag-and-drop
|
|
2232
2384
|
|
|
2233
|
-
[
|
|
2385
|
+
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2234
2386
|
|
|
2235
|
-
[
|
|
2387
|
+
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
2236
2388
|
|
|
2237
|
-
[
|
|
2389
|
+
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2238
2390
|
|
|
2239
|
-
[
|
|
2391
|
+
[21]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
2240
2392
|
|
|
2241
|
-
[
|
|
2393
|
+
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
2242
2394
|
|
|
2243
|
-
[
|
|
2395
|
+
[23]: https://playwright.dev/docs/api/class-consolemessage
|
|
2244
2396
|
|
|
2245
|
-
[
|
|
2397
|
+
[24]: https://codecept.io/helpers/FileSystem
|
|
2246
2398
|
|
|
2247
|
-
[
|
|
2399
|
+
[25]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
|
|
2248
2400
|
|
|
2249
|
-
[
|
|
2401
|
+
[26]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
|
|
2250
2402
|
|
|
2251
|
-
[
|
|
2403
|
+
[27]: https://playwright.dev/docs/network#handle-requests
|
|
2252
2404
|
|
|
2253
|
-
[
|
|
2405
|
+
[28]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
|
|
2254
2406
|
|
|
2255
|
-
[
|
|
2407
|
+
[29]: #fillfield
|
|
2256
2408
|
|
|
2257
|
-
[
|
|
2409
|
+
[30]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
2258
2410
|
|
|
2259
|
-
[
|
|
2411
|
+
[31]: #click
|
|
2260
2412
|
|
|
2261
|
-
[
|
|
2413
|
+
[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2262
2414
|
|
|
2263
|
-
[
|
|
2415
|
+
[33]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
|
|
2264
2416
|
|
|
2265
|
-
[
|
|
2417
|
+
[34]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
|
|
2266
2418
|
|
|
2267
|
-
[
|
|
2419
|
+
[35]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
|
|
2268
2420
|
|
|
2269
|
-
[
|
|
2421
|
+
[36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
|
|
2270
2422
|
|
|
2271
|
-
[
|
|
2423
|
+
[37]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
|
|
2272
2424
|
|
|
2273
|
-
[
|
|
2425
|
+
[38]: https://codecept.io/react
|
|
2274
2426
|
|
|
2275
|
-
[
|
|
2427
|
+
[39]: https://playwright.dev/docs/api/class-browsercontext
|
|
2276
2428
|
|
|
2277
|
-
[
|
|
2429
|
+
[40]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
|
|
2278
2430
|
|
|
2279
|
-
[
|
|
2431
|
+
[41]: https://playwright.dev/docs/trace-viewer
|
|
2280
2432
|
|
|
2281
|
-
[
|
|
2433
|
+
[42]: https://playwright.dev/docs/api/class-page#page-wait-for-navigation
|
|
2282
2434
|
|
|
2283
|
-
[
|
|
2435
|
+
[43]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
|
|
2284
2436
|
|
|
2285
|
-
[
|
|
2437
|
+
[44]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
|