codeceptjs 3.5.1 → 3.5.3
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 +51 -0
- package/README.md +4 -5
- package/docs/basics.md +1 -2
- package/docs/build/OpenAI.js +14 -10
- package/docs/build/Playwright.js +462 -1
- package/docs/changelog.md +51 -0
- package/docs/custom-helpers.md +2 -2
- package/docs/data.md +6 -2
- package/docs/docker.md +2 -3
- package/docs/helpers/Playwright.md +289 -150
- package/docs/helpers/Protractor.md +1709 -0
- 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/OpenAI.js +14 -10
- package/lib/helper/Playwright.js +462 -1
- package/lib/plugin/standardActingHelpers.js +0 -2
- package/lib/plugin/wdio.js +0 -1
- package/lib/recorder.js +2 -1
- package/package.json +8 -10
- package/typings/index.d.ts +0 -1
- package/typings/promiseBasedTypes.d.ts +127 -0
- package/typings/types.d.ts +127 -25
- package/docs/nightmare.md +0 -223
|
@@ -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
|
|
|
@@ -422,10 +422,27 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
422
422
|
- `pathToFile` **[string][8]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
423
423
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
424
424
|
|
|
425
|
+
### blockTraffic
|
|
426
|
+
|
|
427
|
+
Blocks traffic for URL.
|
|
428
|
+
|
|
429
|
+
Examples:
|
|
430
|
+
|
|
431
|
+
```js
|
|
432
|
+
I.blockTraffic('http://example.com/css/style.css');
|
|
433
|
+
I.blockTraffic('http://example.com/css/*.css');
|
|
434
|
+
I.blockTraffic('http://example.com/**');
|
|
435
|
+
I.blockTraffic(/.css$/);
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
#### Parameters
|
|
439
|
+
|
|
440
|
+
- `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.
|
|
441
|
+
|
|
425
442
|
### blur
|
|
426
443
|
|
|
427
444
|
Remove focus from a text input, button, etc.
|
|
428
|
-
Calls [blur][
|
|
445
|
+
Calls [blur][10] on the element.
|
|
429
446
|
|
|
430
447
|
Examples:
|
|
431
448
|
|
|
@@ -443,7 +460,7 @@ I.dontSee('#add-to-cart-btn');
|
|
|
443
460
|
#### Parameters
|
|
444
461
|
|
|
445
462
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
446
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
463
|
+
- `options` **any?** Playwright only: [Additional options][11] for available options object as 2nd argument.
|
|
447
464
|
|
|
448
465
|
### cancelPopup
|
|
449
466
|
|
|
@@ -466,7 +483,7 @@ I.checkOption('agree', '//form');
|
|
|
466
483
|
|
|
467
484
|
- `field` **([string][8] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
468
485
|
- `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][
|
|
486
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][12] for check available as 3rd argument.Examples:```js
|
|
470
487
|
// click on element at position
|
|
471
488
|
I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
472
489
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -500,12 +517,12 @@ I.clearField('.text-area')
|
|
|
500
517
|
I.clearField('#submit', { force: true })
|
|
501
518
|
```
|
|
502
519
|
|
|
503
|
-
Use `force` to bypass the [actionability][
|
|
520
|
+
Use `force` to bypass the [actionability][13] checks.
|
|
504
521
|
|
|
505
522
|
#### Parameters
|
|
506
523
|
|
|
507
524
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
508
|
-
- `options` **any?** [Additional options][
|
|
525
|
+
- `options` **any?** [Additional options][14] for available options object as 2nd argument.
|
|
509
526
|
|
|
510
527
|
### click
|
|
511
528
|
|
|
@@ -536,7 +553,7 @@ I.click({css: 'nav a.login'});
|
|
|
536
553
|
- `locator` **([string][8] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
537
554
|
- `context` **([string][8]? | [object][5] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
538
555
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
539
|
-
- `options` **any?** [Additional options][
|
|
556
|
+
- `options` **any?** [Additional options][15] for click available as 3rd argument.Examples:```js
|
|
540
557
|
// click on element at position
|
|
541
558
|
I.click('canvas', '.model', { position: { x: 20, y: 40 } })
|
|
542
559
|
|
|
@@ -706,6 +723,23 @@ I.dontSeeInTitle('Error');
|
|
|
706
723
|
- `text` **[string][8]** value to check.
|
|
707
724
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
708
725
|
|
|
726
|
+
### dontSeeTraffic
|
|
727
|
+
|
|
728
|
+
Verifies that a certain request is not part of network traffic.
|
|
729
|
+
|
|
730
|
+
Examples:
|
|
731
|
+
|
|
732
|
+
```js
|
|
733
|
+
I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
|
|
734
|
+
I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### Parameters
|
|
738
|
+
|
|
739
|
+
- `opts` **[Object][5]** options when checking the traffic network.
|
|
740
|
+
- `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.
|
|
741
|
+
- `opts.url` **([string][8] | [RegExp][16])** Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
742
|
+
|
|
709
743
|
### doubleClick
|
|
710
744
|
|
|
711
745
|
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
@@ -737,7 +771,7 @@ I.dragAndDrop('#dragHandle', '#container');
|
|
|
737
771
|
- `srcElement` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
738
772
|
- `destElement` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
739
773
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
740
|
-
- `options` **any?** [Additional options][
|
|
774
|
+
- `options` **any?** [Additional options][17] can be passed as 3rd argument.```js
|
|
741
775
|
// specify coordinates for source position
|
|
742
776
|
I.dragAndDrop('img.src', 'img.dst', { sourcePosition: {x: 10, y: 10} })
|
|
743
777
|
```> 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 +789,7 @@ I.dragSlider('#slider', -70);
|
|
|
755
789
|
#### Parameters
|
|
756
790
|
|
|
757
791
|
- `locator` **([string][8] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
758
|
-
- `offsetX` **[number][
|
|
792
|
+
- `offsetX` **[number][18]** position to drag.
|
|
759
793
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
760
794
|
|
|
761
795
|
### executeScript
|
|
@@ -783,10 +817,10 @@ If a function returns a Promise it will wait for its resolution.
|
|
|
783
817
|
|
|
784
818
|
#### Parameters
|
|
785
819
|
|
|
786
|
-
- `fn` **([string][8] | [function][
|
|
820
|
+
- `fn` **([string][8] | [function][19])** function to be executed in browser context.
|
|
787
821
|
- `arg` **any?** optional argument to pass to the function
|
|
788
822
|
|
|
789
|
-
Returns **[Promise][
|
|
823
|
+
Returns **[Promise][20]<any>**
|
|
790
824
|
|
|
791
825
|
### fillField
|
|
792
826
|
|
|
@@ -810,9 +844,13 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
810
844
|
- `value` **([string][8] | [object][5])** text value to fill.
|
|
811
845
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
812
846
|
|
|
847
|
+
### flushNetworkTraffics
|
|
848
|
+
|
|
849
|
+
Resets all recorded network requests.
|
|
850
|
+
|
|
813
851
|
### focus
|
|
814
852
|
|
|
815
|
-
Calls [focus][
|
|
853
|
+
Calls [focus][10] on the matching element.
|
|
816
854
|
|
|
817
855
|
Examples:
|
|
818
856
|
|
|
@@ -825,7 +863,7 @@ I.see('#add-to-cart-bnt');
|
|
|
825
863
|
#### Parameters
|
|
826
864
|
|
|
827
865
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
828
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
866
|
+
- `options` **any?** Playwright only: [Additional options][21] for available options object as 2nd argument.
|
|
829
867
|
|
|
830
868
|
### forceClick
|
|
831
869
|
|
|
@@ -875,7 +913,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
875
913
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
876
914
|
- `attr` **[string][8]** attribute name.
|
|
877
915
|
|
|
878
|
-
Returns **[Promise][
|
|
916
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
879
917
|
|
|
880
918
|
### grabAttributeFromAll
|
|
881
919
|
|
|
@@ -891,7 +929,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
891
929
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
892
930
|
- `attr` **[string][8]** attribute name.
|
|
893
931
|
|
|
894
|
-
Returns **[Promise][
|
|
932
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
895
933
|
|
|
896
934
|
### grabBrowserLogs
|
|
897
935
|
|
|
@@ -903,9 +941,9 @@ const errors = logs.map(l => ({ type: l.type(), text: l.text() })).filter(l => l
|
|
|
903
941
|
console.log(JSON.stringify(errors));
|
|
904
942
|
```
|
|
905
943
|
|
|
906
|
-
[Learn more about console messages][
|
|
944
|
+
[Learn more about console messages][23]
|
|
907
945
|
|
|
908
|
-
Returns **[Promise][
|
|
946
|
+
Returns **[Promise][20]<[Array][22]<any>>**
|
|
909
947
|
|
|
910
948
|
### grabCookie
|
|
911
949
|
|
|
@@ -922,7 +960,7 @@ assert(cookie.value, '123456');
|
|
|
922
960
|
|
|
923
961
|
- `name` **[string][8]?** cookie name.
|
|
924
962
|
|
|
925
|
-
Returns **([Promise][
|
|
963
|
+
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
964
|
|
|
927
965
|
### grabCssPropertyFrom
|
|
928
966
|
|
|
@@ -939,7 +977,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
939
977
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
940
978
|
- `cssProperty` **[string][8]** CSS property name.
|
|
941
979
|
|
|
942
|
-
Returns **[Promise][
|
|
980
|
+
Returns **[Promise][20]<[string][8]>** CSS value
|
|
943
981
|
|
|
944
982
|
### grabCssPropertyFromAll
|
|
945
983
|
|
|
@@ -955,7 +993,7 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
955
993
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
956
994
|
- `cssProperty` **[string][8]** CSS property name.
|
|
957
995
|
|
|
958
|
-
Returns **[Promise][
|
|
996
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** CSS value
|
|
959
997
|
|
|
960
998
|
### grabCurrentUrl
|
|
961
999
|
|
|
@@ -967,7 +1005,7 @@ let url = await I.grabCurrentUrl();
|
|
|
967
1005
|
console.log(`Current URL is [${url}]`);
|
|
968
1006
|
```
|
|
969
1007
|
|
|
970
|
-
Returns **[Promise][
|
|
1008
|
+
Returns **[Promise][20]<[string][8]>** current URL
|
|
971
1009
|
|
|
972
1010
|
### grabDataFromPerformanceTiming
|
|
973
1011
|
|
|
@@ -992,7 +1030,7 @@ let data = await I.grabDataFromPerformanceTiming();
|
|
|
992
1030
|
}
|
|
993
1031
|
```
|
|
994
1032
|
|
|
995
|
-
Returns **[Promise][
|
|
1033
|
+
Returns **[Promise][20]<any>** automatically synchronized promise through #recorder
|
|
996
1034
|
|
|
997
1035
|
### grabElementBoundingRect
|
|
998
1036
|
|
|
@@ -1020,7 +1058,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
1020
1058
|
- `prop`
|
|
1021
1059
|
- `elementSize` **[string][8]?** x, y, width or height of the given element.
|
|
1022
1060
|
|
|
1023
|
-
Returns **([Promise][
|
|
1061
|
+
Returns **([Promise][20]<DOMRect> | [Promise][20]<[number][18]>)** Element bounding rectangle
|
|
1024
1062
|
|
|
1025
1063
|
### grabHTMLFrom
|
|
1026
1064
|
|
|
@@ -1037,7 +1075,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
1037
1075
|
- `locator`
|
|
1038
1076
|
- `element` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1039
1077
|
|
|
1040
|
-
Returns **[Promise][
|
|
1078
|
+
Returns **[Promise][20]<[string][8]>** HTML code for an element
|
|
1041
1079
|
|
|
1042
1080
|
### grabHTMLFromAll
|
|
1043
1081
|
|
|
@@ -1053,7 +1091,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
1053
1091
|
- `locator`
|
|
1054
1092
|
- `element` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1055
1093
|
|
|
1056
|
-
Returns **[Promise][
|
|
1094
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** HTML code for an element
|
|
1057
1095
|
|
|
1058
1096
|
### grabNumberOfOpenTabs
|
|
1059
1097
|
|
|
@@ -1064,7 +1102,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1064
1102
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
1065
1103
|
```
|
|
1066
1104
|
|
|
1067
|
-
Returns **[Promise][
|
|
1105
|
+
Returns **[Promise][20]<[number][18]>** number of open tabs
|
|
1068
1106
|
|
|
1069
1107
|
### grabNumberOfVisibleElements
|
|
1070
1108
|
|
|
@@ -1079,7 +1117,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
1079
1117
|
|
|
1080
1118
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1081
1119
|
|
|
1082
|
-
Returns **[Promise][
|
|
1120
|
+
Returns **[Promise][20]<[number][18]>** number of visible elements
|
|
1083
1121
|
|
|
1084
1122
|
### grabPageScrollPosition
|
|
1085
1123
|
|
|
@@ -1090,7 +1128,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
1090
1128
|
let { x, y } = await I.grabPageScrollPosition();
|
|
1091
1129
|
```
|
|
1092
1130
|
|
|
1093
|
-
Returns **[Promise][
|
|
1131
|
+
Returns **[Promise][20]<PageScrollPosition>** scroll position
|
|
1094
1132
|
|
|
1095
1133
|
### grabPopupText
|
|
1096
1134
|
|
|
@@ -1100,7 +1138,13 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
1100
1138
|
await I.grabPopupText();
|
|
1101
1139
|
```
|
|
1102
1140
|
|
|
1103
|
-
Returns **[Promise][
|
|
1141
|
+
Returns **[Promise][20]<([string][8] | null)>**
|
|
1142
|
+
|
|
1143
|
+
### grabRecordedNetworkTraffics
|
|
1144
|
+
|
|
1145
|
+
Grab the recording network traffics
|
|
1146
|
+
|
|
1147
|
+
Returns **[Array][22]<any>**
|
|
1104
1148
|
|
|
1105
1149
|
### grabSource
|
|
1106
1150
|
|
|
@@ -1111,7 +1155,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1111
1155
|
let pageSource = await I.grabSource();
|
|
1112
1156
|
```
|
|
1113
1157
|
|
|
1114
|
-
Returns **[Promise][
|
|
1158
|
+
Returns **[Promise][20]<[string][8]>** source code
|
|
1115
1159
|
|
|
1116
1160
|
### grabTextFrom
|
|
1117
1161
|
|
|
@@ -1128,7 +1172,7 @@ If multiple elements found returns first element.
|
|
|
1128
1172
|
|
|
1129
1173
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1130
1174
|
|
|
1131
|
-
Returns **[Promise][
|
|
1175
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
1132
1176
|
|
|
1133
1177
|
### grabTextFromAll
|
|
1134
1178
|
|
|
@@ -1143,7 +1187,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
1143
1187
|
|
|
1144
1188
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1145
1189
|
|
|
1146
|
-
Returns **[Promise][
|
|
1190
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
1147
1191
|
|
|
1148
1192
|
### grabTitle
|
|
1149
1193
|
|
|
@@ -1154,7 +1198,20 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
1154
1198
|
let title = await I.grabTitle();
|
|
1155
1199
|
```
|
|
1156
1200
|
|
|
1157
|
-
Returns **[Promise][
|
|
1201
|
+
Returns **[Promise][20]<[string][8]>** title
|
|
1202
|
+
|
|
1203
|
+
### grabTrafficUrl
|
|
1204
|
+
|
|
1205
|
+
Returns full URL of request matching parameter "urlMatch".
|
|
1206
|
+
|
|
1207
|
+
#### Parameters
|
|
1208
|
+
|
|
1209
|
+
- `urlMatch` **([string][8] | [RegExp][16])** Expected URL of request in network traffic. Can be a string or a regular expression.Examples:```js
|
|
1210
|
+
I.grabTrafficUrl('https://api.example.com/session');
|
|
1211
|
+
I.grabTrafficUrl(/session.*start/);
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
Returns **[Promise][20]<any>**
|
|
1158
1215
|
|
|
1159
1216
|
### grabValueFrom
|
|
1160
1217
|
|
|
@@ -1170,7 +1227,7 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
1170
1227
|
|
|
1171
1228
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1172
1229
|
|
|
1173
|
-
Returns **[Promise][
|
|
1230
|
+
Returns **[Promise][20]<[string][8]>** attribute value
|
|
1174
1231
|
|
|
1175
1232
|
### grabValueFromAll
|
|
1176
1233
|
|
|
@@ -1185,14 +1242,14 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
1185
1242
|
|
|
1186
1243
|
- `locator` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1187
1244
|
|
|
1188
|
-
Returns **[Promise][
|
|
1245
|
+
Returns **[Promise][20]<[Array][22]<[string][8]>>** attribute value
|
|
1189
1246
|
|
|
1190
1247
|
### handleDownloads
|
|
1191
1248
|
|
|
1192
1249
|
Handles a file download. A file name is required to save the file on disk.
|
|
1193
1250
|
Files are saved to "output" directory.
|
|
1194
1251
|
|
|
1195
|
-
Should be used with [FileSystem helper][
|
|
1252
|
+
Should be used with [FileSystem helper][24] to check that file were downloaded correctly.
|
|
1196
1253
|
|
|
1197
1254
|
```js
|
|
1198
1255
|
I.handleDownloads('downloads/avatar.jpg');
|
|
@@ -1205,7 +1262,7 @@ I.waitForFile('avatar.jpg', 5);
|
|
|
1205
1262
|
|
|
1206
1263
|
- `fileName` **[string][8]** set filename for downloaded file
|
|
1207
1264
|
|
|
1208
|
-
Returns **[Promise][
|
|
1265
|
+
Returns **[Promise][20]<void>**
|
|
1209
1266
|
|
|
1210
1267
|
### haveRequestHeaders
|
|
1211
1268
|
|
|
@@ -1223,7 +1280,7 @@ I.haveRequestHeaders({
|
|
|
1223
1280
|
|
|
1224
1281
|
### makeApiRequest
|
|
1225
1282
|
|
|
1226
|
-
Performs [api request][
|
|
1283
|
+
Performs [api request][25] using
|
|
1227
1284
|
the cookies from the current browser session.
|
|
1228
1285
|
|
|
1229
1286
|
```js
|
|
@@ -1240,22 +1297,41 @@ I.makeApiRequest('PATCH', )
|
|
|
1240
1297
|
- `url` **[string][8]** endpoint
|
|
1241
1298
|
- `options` **[object][5]** request options depending on method used
|
|
1242
1299
|
|
|
1243
|
-
Returns **[Promise][
|
|
1300
|
+
Returns **[Promise][20]<[object][5]>** response
|
|
1244
1301
|
|
|
1245
1302
|
### mockRoute
|
|
1246
1303
|
|
|
1247
|
-
Mocks network request using [`browserContext.route`][
|
|
1304
|
+
Mocks network request using [`browserContext.route`][26] of Playwright
|
|
1248
1305
|
|
|
1249
1306
|
```js
|
|
1250
1307
|
I.mockRoute(/(.png$)|(.jpg$)/, route => route.abort());
|
|
1251
1308
|
```
|
|
1252
1309
|
|
|
1253
|
-
This method allows intercepting and mocking requests & responses. [Learn more about it][
|
|
1310
|
+
This method allows intercepting and mocking requests & responses. [Learn more about it][27]
|
|
1311
|
+
|
|
1312
|
+
#### Parameters
|
|
1313
|
+
|
|
1314
|
+
- `url` **([string][8] | [RegExp][16])?** URL, regex or pattern for to match URL
|
|
1315
|
+
- `handler` **[function][19]?** a function to process reques
|
|
1316
|
+
|
|
1317
|
+
### mockTraffic
|
|
1318
|
+
|
|
1319
|
+
Mocks traffic for URL(s).
|
|
1320
|
+
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.
|
|
1321
|
+
|
|
1322
|
+
Examples:
|
|
1323
|
+
|
|
1324
|
+
```js
|
|
1325
|
+
I.mockTraffic('/api/users/1', '{ id: 1, name: 'John Doe' }');
|
|
1326
|
+
I.mockTraffic('/api/users/*', JSON.stringify({ id: 1, name: 'John Doe' }));
|
|
1327
|
+
I.mockTraffic([/^https://api.example.com/v1/, 'https://api.example.com/v2/**'], 'Internal Server Error', 'text/html');
|
|
1328
|
+
```
|
|
1254
1329
|
|
|
1255
1330
|
#### Parameters
|
|
1256
1331
|
|
|
1257
|
-
- `
|
|
1258
|
-
- `
|
|
1332
|
+
- `urls` string|Array These are the URL(s) to mock, e.g. "/fooapi/_" or "['/fooapi_1/_', '/barapi_2/*']". Regular expressions are also supported.
|
|
1333
|
+
- `responseString` string The string to return in fake response's body.
|
|
1334
|
+
- `contentType` Content type of fake response. If not specified default value 'application/json' is used.
|
|
1259
1335
|
|
|
1260
1336
|
### moveCursorTo
|
|
1261
1337
|
|
|
@@ -1270,8 +1346,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1270
1346
|
#### Parameters
|
|
1271
1347
|
|
|
1272
1348
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1273
|
-
- `offsetX` **[number][
|
|
1274
|
-
- `offsetY` **[number][
|
|
1349
|
+
- `offsetX` **[number][18]** (optional, `0` by default) X-axis offset.
|
|
1350
|
+
- `offsetY` **[number][18]** (optional, `0` by default) Y-axis offset.
|
|
1275
1351
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1276
1352
|
|
|
1277
1353
|
### openNewTab
|
|
@@ -1282,7 +1358,7 @@ Open new tab and automatically switched to new tab
|
|
|
1282
1358
|
I.openNewTab();
|
|
1283
1359
|
```
|
|
1284
1360
|
|
|
1285
|
-
You can pass in [page options][
|
|
1361
|
+
You can pass in [page options][28] to emulate device on this page
|
|
1286
1362
|
|
|
1287
1363
|
```js
|
|
1288
1364
|
// enable mobile
|
|
@@ -1297,7 +1373,7 @@ I.openNewTab({ isMobile: true });
|
|
|
1297
1373
|
|
|
1298
1374
|
Presses a key in the browser (on a focused element).
|
|
1299
1375
|
|
|
1300
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1376
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][29].
|
|
1301
1377
|
|
|
1302
1378
|
```js
|
|
1303
1379
|
I.pressKey('Backspace');
|
|
@@ -1356,14 +1432,14 @@ Some of the supported key names are:
|
|
|
1356
1432
|
|
|
1357
1433
|
#### Parameters
|
|
1358
1434
|
|
|
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][
|
|
1435
|
+
- `key` **([string][8] | [Array][22]<[string][8]>)** key or array of keys to press.
|
|
1436
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][30]).
|
|
1361
1437
|
|
|
1362
1438
|
### pressKeyDown
|
|
1363
1439
|
|
|
1364
1440
|
Presses a key in the browser and leaves it in a down state.
|
|
1365
1441
|
|
|
1366
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1442
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
|
|
1367
1443
|
|
|
1368
1444
|
```js
|
|
1369
1445
|
I.pressKeyDown('Control');
|
|
@@ -1380,7 +1456,7 @@ I.pressKeyUp('Control');
|
|
|
1380
1456
|
|
|
1381
1457
|
Releases a key in the browser which was previously set to a down state.
|
|
1382
1458
|
|
|
1383
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1459
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
|
|
1384
1460
|
|
|
1385
1461
|
```js
|
|
1386
1462
|
I.pressKeyDown('Control');
|
|
@@ -1410,8 +1486,8 @@ First parameter can be set to `maximize`.
|
|
|
1410
1486
|
|
|
1411
1487
|
#### Parameters
|
|
1412
1488
|
|
|
1413
|
-
- `width` **[number][
|
|
1414
|
-
- `height` **[number][
|
|
1489
|
+
- `width` **[number][18]** width in pixels or `maximize`.
|
|
1490
|
+
- `height` **[number][18]** height in pixels.
|
|
1415
1491
|
⚠️ returns a _promise_ which is synchronized internally by recorderUnlike other drivers Playwright changes the size of a viewport, not the window!
|
|
1416
1492
|
Playwright does not control the window of a browser so it can't adjust its real size.
|
|
1417
1493
|
It also can't maximize a window.Update configuration to change real window size on start:```js
|
|
@@ -1485,7 +1561,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1485
1561
|
#### Parameters
|
|
1486
1562
|
|
|
1487
1563
|
- `fileName` **[string][8]** file name to save.
|
|
1488
|
-
- `fullPage` **[boolean][
|
|
1564
|
+
- `fullPage` **[boolean][32]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1489
1565
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1490
1566
|
|
|
1491
1567
|
### scrollPageToBottom
|
|
@@ -1521,8 +1597,8 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1521
1597
|
#### Parameters
|
|
1522
1598
|
|
|
1523
1599
|
- `locator` **([string][8] | [object][5])** located by CSS|XPath|strict locator.
|
|
1524
|
-
- `offsetX` **[number][
|
|
1525
|
-
- `offsetY` **[number][
|
|
1600
|
+
- `offsetX` **[number][18]** (optional, `0` by default) X-axis offset.
|
|
1601
|
+
- `offsetY` **[number][18]** (optional, `0` by default) Y-axis offset.
|
|
1526
1602
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1527
1603
|
|
|
1528
1604
|
### see
|
|
@@ -1725,7 +1801,7 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
1725
1801
|
#### Parameters
|
|
1726
1802
|
|
|
1727
1803
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1728
|
-
- `num` **[number][
|
|
1804
|
+
- `num` **[number][18]** number of elements.
|
|
1729
1805
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1730
1806
|
|
|
1731
1807
|
### seeNumberOfVisibleElements
|
|
@@ -1740,7 +1816,7 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1740
1816
|
#### Parameters
|
|
1741
1817
|
|
|
1742
1818
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1743
|
-
- `num` **[number][
|
|
1819
|
+
- `num` **[number][18]** number of elements.
|
|
1744
1820
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1745
1821
|
|
|
1746
1822
|
### seeTextEquals
|
|
@@ -1770,6 +1846,48 @@ I.seeTitleEquals('Test title.');
|
|
|
1770
1846
|
- `text` **[string][8]** value to check.
|
|
1771
1847
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1772
1848
|
|
|
1849
|
+
### seeTraffic
|
|
1850
|
+
|
|
1851
|
+
Verifies that a certain request is part of network traffic.
|
|
1852
|
+
|
|
1853
|
+
```js
|
|
1854
|
+
// checking the request url contains certain query strings
|
|
1855
|
+
I.amOnPage('https://openai.com/blog/chatgpt');
|
|
1856
|
+
I.startRecordingTraffic();
|
|
1857
|
+
await I.seeTraffic({
|
|
1858
|
+
name: 'sentry event',
|
|
1859
|
+
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
|
|
1860
|
+
parameters: {
|
|
1861
|
+
width: '1919',
|
|
1862
|
+
height: '1138',
|
|
1863
|
+
},
|
|
1864
|
+
});
|
|
1865
|
+
```
|
|
1866
|
+
|
|
1867
|
+
```js
|
|
1868
|
+
// checking the request url contains certain post data
|
|
1869
|
+
I.amOnPage('https://openai.com/blog/chatgpt');
|
|
1870
|
+
I.startRecordingTraffic();
|
|
1871
|
+
await I.seeTraffic({
|
|
1872
|
+
name: 'event',
|
|
1873
|
+
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
|
|
1874
|
+
requestPostData: {
|
|
1875
|
+
st: 2,
|
|
1876
|
+
},
|
|
1877
|
+
});
|
|
1878
|
+
```
|
|
1879
|
+
|
|
1880
|
+
#### Parameters
|
|
1881
|
+
|
|
1882
|
+
- `opts` **[Object][5]** options when checking the traffic network.
|
|
1883
|
+
- `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.
|
|
1884
|
+
- `opts.url` **[string][8]** Expected URL of request in network traffic
|
|
1885
|
+
- `opts.parameters` **[Object][5]?** Expected parameters of that request in network traffic
|
|
1886
|
+
- `opts.requestPostData` **[Object][5]?** Expected that request contains post data in network traffic
|
|
1887
|
+
- `opts.timeout` **[number][18]?** Timeout to wait for request in seconds. Default is 10 seconds.
|
|
1888
|
+
|
|
1889
|
+
Returns **[Promise][20]<any>**
|
|
1890
|
+
|
|
1773
1891
|
### selectOption
|
|
1774
1892
|
|
|
1775
1893
|
Selects an option in a drop-down select.
|
|
@@ -1794,7 +1912,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1794
1912
|
#### Parameters
|
|
1795
1913
|
|
|
1796
1914
|
- `select` **([string][8] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1797
|
-
- `option` **([string][8] | [Array][
|
|
1915
|
+
- `option` **([string][8] | [Array][22]<any>)** visible text or value of option.
|
|
1798
1916
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1799
1917
|
|
|
1800
1918
|
### setCookie
|
|
@@ -1815,9 +1933,20 @@ I.setCookie([
|
|
|
1815
1933
|
|
|
1816
1934
|
#### Parameters
|
|
1817
1935
|
|
|
1818
|
-
- `cookie` **(Cookie | [Array][
|
|
1936
|
+
- `cookie` **(Cookie | [Array][22]<Cookie>)** a cookie object or array of cookie objects.
|
|
1819
1937
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1820
1938
|
|
|
1939
|
+
### startRecordingTraffic
|
|
1940
|
+
|
|
1941
|
+
Starts recording of network traffic.
|
|
1942
|
+
This also resets recorded network requests.
|
|
1943
|
+
|
|
1944
|
+
```js
|
|
1945
|
+
I.startRecordingTraffic();
|
|
1946
|
+
```
|
|
1947
|
+
|
|
1948
|
+
Returns **[Promise][20]<void>**
|
|
1949
|
+
|
|
1821
1950
|
### stopMockingRoute
|
|
1822
1951
|
|
|
1823
1952
|
Stops network mocking created by `mockRoute`.
|
|
@@ -1831,8 +1960,16 @@ If no handler is passed, all mock requests for the rote are disabled.
|
|
|
1831
1960
|
|
|
1832
1961
|
#### Parameters
|
|
1833
1962
|
|
|
1834
|
-
- `url` **([string][8] | [RegExp][
|
|
1835
|
-
- `handler` **[function][
|
|
1963
|
+
- `url` **([string][8] | [RegExp][16])?** URL, regex or pattern for to match URL
|
|
1964
|
+
- `handler` **[function][19]?** a function to process reques
|
|
1965
|
+
|
|
1966
|
+
### stopRecordingTraffic
|
|
1967
|
+
|
|
1968
|
+
Stops recording of network traffic. Recorded traffic is not flashed.
|
|
1969
|
+
|
|
1970
|
+
```js
|
|
1971
|
+
I.stopRecordingTraffic();
|
|
1972
|
+
```
|
|
1836
1973
|
|
|
1837
1974
|
### switchTo
|
|
1838
1975
|
|
|
@@ -1859,7 +1996,7 @@ I.switchToNextTab(2);
|
|
|
1859
1996
|
|
|
1860
1997
|
#### Parameters
|
|
1861
1998
|
|
|
1862
|
-
- `num` **[number][
|
|
1999
|
+
- `num` **[number][18]**
|
|
1863
2000
|
|
|
1864
2001
|
### switchToPreviousTab
|
|
1865
2002
|
|
|
@@ -1872,13 +2009,13 @@ I.switchToPreviousTab(2);
|
|
|
1872
2009
|
|
|
1873
2010
|
#### Parameters
|
|
1874
2011
|
|
|
1875
|
-
- `num` **[number][
|
|
2012
|
+
- `num` **[number][18]**
|
|
1876
2013
|
|
|
1877
2014
|
### type
|
|
1878
2015
|
|
|
1879
2016
|
Types out the given text into an active field.
|
|
1880
2017
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
1881
|
-
_Note:_ Should be used when [`fillField`][
|
|
2018
|
+
_Note:_ Should be used when [`fillField`][29] is not an option.
|
|
1882
2019
|
|
|
1883
2020
|
```js
|
|
1884
2021
|
// passing in a string
|
|
@@ -1897,9 +2034,9 @@ I.type(secret('123456'));
|
|
|
1897
2034
|
#### Parameters
|
|
1898
2035
|
|
|
1899
2036
|
- `keys`
|
|
1900
|
-
- `delay` **[number][
|
|
2037
|
+
- `delay` **[number][18]?** (optional) delay in ms between key presses
|
|
1901
2038
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1902
|
-
- `key` **([string][8] | [Array][
|
|
2039
|
+
- `key` **([string][8] | [Array][22]<[string][8]>)** or array of keys to type.
|
|
1903
2040
|
|
|
1904
2041
|
### uncheckOption
|
|
1905
2042
|
|
|
@@ -1918,7 +2055,7 @@ I.uncheckOption('agree', '//form');
|
|
|
1918
2055
|
|
|
1919
2056
|
- `field` **([string][8] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
1920
2057
|
- `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][
|
|
2058
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder[Additional options][33] for uncheck available as 3rd argument.Examples:```js
|
|
1922
2059
|
// click on element at position
|
|
1923
2060
|
I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
1924
2061
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -1931,7 +2068,7 @@ Use Playwright API inside a test.
|
|
|
1931
2068
|
First argument is a description of an action.
|
|
1932
2069
|
Second argument is async function that gets this helper as parameter.
|
|
1933
2070
|
|
|
1934
|
-
{ [`page`][
|
|
2071
|
+
{ [`page`][34], [`browserContext`][35] [`browser`][36] } objects from Playwright API are available.
|
|
1935
2072
|
|
|
1936
2073
|
```js
|
|
1937
2074
|
I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
@@ -1942,7 +2079,7 @@ I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
|
1942
2079
|
#### Parameters
|
|
1943
2080
|
|
|
1944
2081
|
- `description` **[string][8]** used to show in logs.
|
|
1945
|
-
- `fn` **[function][
|
|
2082
|
+
- `fn` **[function][19]** async function that executed with Playwright helper as argumen
|
|
1946
2083
|
|
|
1947
2084
|
### wait
|
|
1948
2085
|
|
|
@@ -1954,7 +2091,7 @@ I.wait(2); // wait 2 secs
|
|
|
1954
2091
|
|
|
1955
2092
|
#### Parameters
|
|
1956
2093
|
|
|
1957
|
-
- `sec` **[number][
|
|
2094
|
+
- `sec` **[number][18]** number of second to wait.
|
|
1958
2095
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1959
2096
|
|
|
1960
2097
|
### waitForClickable
|
|
@@ -1971,7 +2108,7 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
|
1971
2108
|
|
|
1972
2109
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1973
2110
|
- `waitTimeout`
|
|
1974
|
-
- `sec` **[number][
|
|
2111
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
1975
2112
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1976
2113
|
|
|
1977
2114
|
### waitForDetached
|
|
@@ -1986,7 +2123,7 @@ I.waitForDetached('#popup');
|
|
|
1986
2123
|
#### Parameters
|
|
1987
2124
|
|
|
1988
2125
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1989
|
-
- `sec` **[number][
|
|
2126
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
1990
2127
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1991
2128
|
|
|
1992
2129
|
### waitForElement
|
|
@@ -2002,7 +2139,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
2002
2139
|
#### Parameters
|
|
2003
2140
|
|
|
2004
2141
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2005
|
-
- `sec` **[number][
|
|
2142
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
2006
2143
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2007
2144
|
|
|
2008
2145
|
### waitForEnabled
|
|
@@ -2013,7 +2150,7 @@ Element can be located by CSS or XPath.
|
|
|
2013
2150
|
#### Parameters
|
|
2014
2151
|
|
|
2015
2152
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2016
|
-
- `sec` **[number][
|
|
2153
|
+
- `sec` **[number][18]** (optional) time in seconds to wait, 1 by default.
|
|
2017
2154
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2018
2155
|
|
|
2019
2156
|
### waitForFunction
|
|
@@ -2033,9 +2170,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
2033
2170
|
|
|
2034
2171
|
#### Parameters
|
|
2035
2172
|
|
|
2036
|
-
- `fn` **([string][8] | [function][
|
|
2037
|
-
- `argsOrSec` **([Array][
|
|
2038
|
-
- `sec` **[number][
|
|
2173
|
+
- `fn` **([string][8] | [function][19])** to be executed in browser context.
|
|
2174
|
+
- `argsOrSec` **([Array][22]<any> | [number][18])?** (optional, `1` by default) arguments for function or seconds.
|
|
2175
|
+
- `sec` **[number][18]?** (optional, `1` by default) time in seconds to wait
|
|
2039
2176
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2040
2177
|
|
|
2041
2178
|
### waitForInvisible
|
|
@@ -2050,14 +2187,14 @@ I.waitForInvisible('#popup');
|
|
|
2050
2187
|
#### Parameters
|
|
2051
2188
|
|
|
2052
2189
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2053
|
-
- `sec` **[number][
|
|
2190
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2054
2191
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2055
2192
|
|
|
2056
2193
|
### waitForNavigation
|
|
2057
2194
|
|
|
2058
2195
|
Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
2059
2196
|
|
|
2060
|
-
See [Playwright's reference][
|
|
2197
|
+
See [Playwright's reference][37]
|
|
2061
2198
|
|
|
2062
2199
|
#### Parameters
|
|
2063
2200
|
|
|
@@ -2074,8 +2211,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
2074
2211
|
|
|
2075
2212
|
#### Parameters
|
|
2076
2213
|
|
|
2077
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
2078
|
-
- `sec` **[number][
|
|
2214
|
+
- `urlOrPredicate` **([string][8] | [function][19])**
|
|
2215
|
+
- `sec` **[number][18]?** seconds to wait
|
|
2079
2216
|
|
|
2080
2217
|
### waitForResponse
|
|
2081
2218
|
|
|
@@ -2088,8 +2225,8 @@ I.waitForResponse(response => response.url() === 'https://example.com' && respon
|
|
|
2088
2225
|
|
|
2089
2226
|
#### Parameters
|
|
2090
2227
|
|
|
2091
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
2092
|
-
- `sec` **[number][
|
|
2228
|
+
- `urlOrPredicate` **([string][8] | [function][19])**
|
|
2229
|
+
- `sec` **[number][18]?** number of seconds to wait
|
|
2093
2230
|
|
|
2094
2231
|
### waitForText
|
|
2095
2232
|
|
|
@@ -2105,7 +2242,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
2105
2242
|
#### Parameters
|
|
2106
2243
|
|
|
2107
2244
|
- `text` **[string][8]** to wait for.
|
|
2108
|
-
- `sec` **[number][
|
|
2245
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2109
2246
|
- `context` **([string][8] | [object][5])?** (optional) element located by CSS|XPath|strict locator.
|
|
2110
2247
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2111
2248
|
|
|
@@ -2121,7 +2258,7 @@ I.waitForValue('//input', "GoodValue");
|
|
|
2121
2258
|
|
|
2122
2259
|
- `field` **([string][8] | [object][5])** input field.
|
|
2123
2260
|
- `value` **[string][8]** expected value.
|
|
2124
|
-
- `sec` **[number][
|
|
2261
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2125
2262
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2126
2263
|
|
|
2127
2264
|
### waitForVisible
|
|
@@ -2136,8 +2273,8 @@ I.waitForVisible('#popup');
|
|
|
2136
2273
|
#### Parameters
|
|
2137
2274
|
|
|
2138
2275
|
- `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][
|
|
2276
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2277
|
+
⚠️ returns a _promise_ which is synchronized internally by recorderThis method accepts [React selectors][38].
|
|
2141
2278
|
|
|
2142
2279
|
### waitInUrl
|
|
2143
2280
|
|
|
@@ -2150,7 +2287,7 @@ I.waitInUrl('/info', 2);
|
|
|
2150
2287
|
#### Parameters
|
|
2151
2288
|
|
|
2152
2289
|
- `urlPart` **[string][8]** value to check.
|
|
2153
|
-
- `sec` **[number][
|
|
2290
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2154
2291
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2155
2292
|
|
|
2156
2293
|
### waitNumberOfVisibleElements
|
|
@@ -2164,8 +2301,8 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
2164
2301
|
#### Parameters
|
|
2165
2302
|
|
|
2166
2303
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2167
|
-
- `num` **[number][
|
|
2168
|
-
- `sec` **[number][
|
|
2304
|
+
- `num` **[number][18]** number of elements.
|
|
2305
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2169
2306
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2170
2307
|
|
|
2171
2308
|
### waitToHide
|
|
@@ -2180,7 +2317,7 @@ I.waitToHide('#popup');
|
|
|
2180
2317
|
#### Parameters
|
|
2181
2318
|
|
|
2182
2319
|
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
|
|
2183
|
-
- `sec` **[number][
|
|
2320
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2184
2321
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2185
2322
|
|
|
2186
2323
|
### waitUrlEquals
|
|
@@ -2195,7 +2332,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2195
2332
|
#### Parameters
|
|
2196
2333
|
|
|
2197
2334
|
- `urlPart` **[string][8]** value to check.
|
|
2198
|
-
- `sec` **[number][
|
|
2335
|
+
- `sec` **[number][18]** (optional, `1` by default) time in seconds to wait
|
|
2199
2336
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2200
2337
|
|
|
2201
2338
|
[1]: https://github.com/microsoft/playwright
|
|
@@ -2214,72 +2351,74 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2214
2351
|
|
|
2215
2352
|
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
2216
2353
|
|
|
2217
|
-
[9]: https://
|
|
2354
|
+
[9]: https://www.example.com**
|
|
2355
|
+
|
|
2356
|
+
[10]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2218
2357
|
|
|
2219
|
-
[
|
|
2358
|
+
[11]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2220
2359
|
|
|
2221
|
-
[
|
|
2360
|
+
[12]: https://playwright.dev/docs/api/class-elementhandle#element-handle-check
|
|
2222
2361
|
|
|
2223
|
-
[
|
|
2362
|
+
[13]: https://playwright.dev/docs/actionability
|
|
2224
2363
|
|
|
2225
|
-
[
|
|
2364
|
+
[14]: https://playwright.dev/docs/api/class-locator#locator-clear
|
|
2226
2365
|
|
|
2227
|
-
[
|
|
2366
|
+
[15]: https://playwright.dev/docs/api/class-page#page-click
|
|
2228
2367
|
|
|
2229
|
-
[
|
|
2368
|
+
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
2230
2369
|
|
|
2231
|
-
[
|
|
2370
|
+
[17]: https://playwright.dev/docs/api/class-page#page-drag-and-drop
|
|
2232
2371
|
|
|
2233
|
-
[
|
|
2372
|
+
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2234
2373
|
|
|
2235
|
-
[
|
|
2374
|
+
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
2236
2375
|
|
|
2237
|
-
[
|
|
2376
|
+
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2238
2377
|
|
|
2239
|
-
[
|
|
2378
|
+
[21]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
2240
2379
|
|
|
2241
|
-
[
|
|
2380
|
+
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
2242
2381
|
|
|
2243
|
-
[
|
|
2382
|
+
[23]: https://playwright.dev/docs/api/class-consolemessage
|
|
2244
2383
|
|
|
2245
|
-
[
|
|
2384
|
+
[24]: https://codecept.io/helpers/FileSystem
|
|
2246
2385
|
|
|
2247
|
-
[
|
|
2386
|
+
[25]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
|
|
2248
2387
|
|
|
2249
|
-
[
|
|
2388
|
+
[26]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
|
|
2250
2389
|
|
|
2251
|
-
[
|
|
2390
|
+
[27]: https://playwright.dev/docs/network#handle-requests
|
|
2252
2391
|
|
|
2253
|
-
[
|
|
2392
|
+
[28]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
|
|
2254
2393
|
|
|
2255
|
-
[
|
|
2394
|
+
[29]: #fillfield
|
|
2256
2395
|
|
|
2257
|
-
[
|
|
2396
|
+
[30]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
2258
2397
|
|
|
2259
|
-
[
|
|
2398
|
+
[31]: #click
|
|
2260
2399
|
|
|
2261
|
-
[
|
|
2400
|
+
[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2262
2401
|
|
|
2263
|
-
[
|
|
2402
|
+
[33]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
|
|
2264
2403
|
|
|
2265
|
-
[
|
|
2404
|
+
[34]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
|
|
2266
2405
|
|
|
2267
|
-
[
|
|
2406
|
+
[35]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
|
|
2268
2407
|
|
|
2269
|
-
[
|
|
2408
|
+
[36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
|
|
2270
2409
|
|
|
2271
|
-
[
|
|
2410
|
+
[37]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
|
|
2272
2411
|
|
|
2273
|
-
[
|
|
2412
|
+
[38]: https://codecept.io/react
|
|
2274
2413
|
|
|
2275
|
-
[
|
|
2414
|
+
[39]: https://playwright.dev/docs/api/class-browsercontext
|
|
2276
2415
|
|
|
2277
|
-
[
|
|
2416
|
+
[40]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
|
|
2278
2417
|
|
|
2279
|
-
[
|
|
2418
|
+
[41]: https://playwright.dev/docs/trace-viewer
|
|
2280
2419
|
|
|
2281
|
-
[
|
|
2420
|
+
[42]: https://playwright.dev/docs/api/class-page#page-wait-for-navigation
|
|
2282
2421
|
|
|
2283
|
-
[
|
|
2422
|
+
[43]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
|
|
2284
2423
|
|
|
2285
|
-
[
|
|
2424
|
+
[44]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
|