codeceptjs 3.5.9-beta.1 → 3.5.9-beta.2
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/docs/build/Appium.js +6 -6
- package/docs/build/Playwright.js +63 -1
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/Playwright.md +341 -303
- package/docs/internal-api.md +111 -0
- package/docs/plugins.md +4 -2
- package/lib/command/run-multiple.js +1 -1
- package/lib/command/run-workers.js +30 -4
- package/lib/command/workers/runTests.js +23 -0
- package/lib/event.js +2 -0
- package/lib/helper/Appium.js +10 -10
- package/lib/helper/Playwright.js +76 -5
- package/lib/helper/Puppeteer.js +7 -3
- package/lib/helper/WebDriver.js +6 -2
- package/lib/interfaces/gherkin.js +8 -1
- package/lib/interfaces/scenarioConfig.js +1 -0
- package/lib/locator.js +2 -2
- package/lib/plugin/autoLogin.js +4 -2
- package/lib/plugin/retryFailedStep.js +5 -0
- package/lib/plugin/stepByStepReport.js +2 -2
- package/lib/ui.js +1 -0
- package/lib/workers.js +2 -0
- package/package.json +4 -4
- package/typings/promiseBasedTypes.d.ts +31 -1
- package/typings/types.d.ts +34 -1
|
@@ -39,46 +39,47 @@ Using playwright-core package, will prevent the download of browser binaries and
|
|
|
39
39
|
|
|
40
40
|
This helper should be configured in codecept.conf.(js|ts)
|
|
41
41
|
|
|
42
|
-
Type: [object][
|
|
42
|
+
Type: [object][6]
|
|
43
43
|
|
|
44
44
|
### Properties
|
|
45
45
|
|
|
46
|
-
- `url` **[string][
|
|
46
|
+
- `url` **[string][9]?** base url of website to be tested
|
|
47
47
|
- `browser` **(`"chromium"` | `"firefox"` | `"webkit"` | `"electron"`)?** a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
|
|
48
|
-
- `show` **[boolean][
|
|
49
|
-
- `restart` **([string][
|
|
48
|
+
- `show` **[boolean][26]?** show browser window.
|
|
49
|
+
- `restart` **([string][9] | [boolean][26])?** restart strategy between tests. Possible values:- 'context' or **false** - restarts [browser context][44] but keeps running browser. Recommended by Playwright team to keep tests isolated.
|
|
50
50
|
- 'browser' or **true** - closes browser and opens it again between tests.
|
|
51
51
|
- 'session' or 'keep' - keeps browser context and session, but cleans up cookies and localStorage between tests. The fastest option when running tests in windowed mode. Works with `keepCookies` and `keepBrowserState` options. This behavior was default before CodeceptJS 3.1
|
|
52
|
-
- `timeout` **[number][
|
|
53
|
-
- `disableScreenshots` **[boolean][
|
|
52
|
+
- `timeout` **[number][20]?** - [timeout][45] in ms of all Playwright actions .
|
|
53
|
+
- `disableScreenshots` **[boolean][26]?** don't save screenshot on failure.
|
|
54
54
|
- `emulate` **any?** browser in device emulation mode.
|
|
55
|
-
- `video` **[boolean][
|
|
56
|
-
- `keepVideoForPassedTests` **[boolean][
|
|
57
|
-
- `trace` **[boolean][
|
|
58
|
-
- `keepTraceForPassedTests` **[boolean][
|
|
59
|
-
- `fullPageScreenshots` **[boolean][
|
|
60
|
-
- `uniqueScreenshotNames` **[boolean][
|
|
61
|
-
- `keepBrowserState` **[boolean][
|
|
62
|
-
- `keepCookies` **[boolean][
|
|
63
|
-
- `waitForAction` **[number][
|
|
64
|
-
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][
|
|
65
|
-
- `pressKeyDelay` **[number][
|
|
66
|
-
- `getPageTimeout` **[number][
|
|
67
|
-
- `waitForTimeout` **[number][
|
|
68
|
-
- `basicAuth` **[object][
|
|
69
|
-
- `windowSize` **[string][
|
|
55
|
+
- `video` **[boolean][26]?** enables video recording for failed tests; videos are saved into `output/videos` folder
|
|
56
|
+
- `keepVideoForPassedTests` **[boolean][26]?** save videos for passed tests; videos are saved into `output/videos` folder
|
|
57
|
+
- `trace` **[boolean][26]?** record [tracing information][46] with screenshots and snapshots.
|
|
58
|
+
- `keepTraceForPassedTests` **[boolean][26]?** save trace for passed tests.
|
|
59
|
+
- `fullPageScreenshots` **[boolean][26]?** make full page screenshots on failure.
|
|
60
|
+
- `uniqueScreenshotNames` **[boolean][26]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
|
|
61
|
+
- `keepBrowserState` **[boolean][26]?** keep browser state between tests when `restart` is set to 'session'.
|
|
62
|
+
- `keepCookies` **[boolean][26]?** keep cookies between tests when `restart` is set to 'session'.
|
|
63
|
+
- `waitForAction` **[number][20]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
64
|
+
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][42].
|
|
65
|
+
- `pressKeyDelay` **[number][20]?** Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
|
|
66
|
+
- `getPageTimeout` **[number][20]?** config option to set maximum navigation time in milliseconds.
|
|
67
|
+
- `waitForTimeout` **[number][20]?** default wait* timeout in ms. Default: 1000.
|
|
68
|
+
- `basicAuth` **[object][6]?** the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
69
|
+
- `windowSize` **[string][9]?** default window size. Set a dimension like `640x480`.
|
|
70
70
|
- `colorScheme` **(`"dark"` | `"light"` | `"no-preference"`)?** default color scheme. Possible values: `dark` | `light` | `no-preference`.
|
|
71
|
-
- `userAgent` **[string][
|
|
72
|
-
- `locale` **[string][
|
|
73
|
-
- `manualStart` **[boolean][
|
|
74
|
-
- `chromium` **[object][
|
|
75
|
-
- `firefox` **[object][
|
|
76
|
-
- `electron` **[object][
|
|
77
|
-
- `channel` **any?** (While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge][
|
|
78
|
-
- `ignoreLog` **[Array][
|
|
79
|
-
- `ignoreHTTPSErrors` **[boolean][
|
|
80
|
-
- `bypassCSP` **[boolean][
|
|
81
|
-
- `highlightElement` **[boolean][
|
|
71
|
+
- `userAgent` **[string][9]?** user-agent string.
|
|
72
|
+
- `locale` **[string][9]?** locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
73
|
+
- `manualStart` **[boolean][26]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
74
|
+
- `chromium` **[object][6]?** pass additional chromium options
|
|
75
|
+
- `firefox` **[object][6]?** pass additional firefox options
|
|
76
|
+
- `electron` **[object][6]?** (pass additional electron options
|
|
77
|
+
- `channel` **any?** (While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge][47].
|
|
78
|
+
- `ignoreLog` **[Array][10]<[string][9]>?** 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][48].
|
|
79
|
+
- `ignoreHTTPSErrors` **[boolean][26]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
|
|
80
|
+
- `bypassCSP` **[boolean][26]?** bypass Content Security Policy or CSP
|
|
81
|
+
- `highlightElement` **[boolean][26]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
82
|
+
- `recordHar` **[object][6]?** record HAR and will be saved to `output/har`. See more of [HAR options][3].
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
|
|
@@ -99,6 +100,19 @@ Traces will be saved to `output/trace`
|
|
|
99
100
|
- `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
|
|
100
101
|
- `keepTraceForPassedTests`: - save trace for passed tests
|
|
101
102
|
|
|
103
|
+
#### HAR Recording Customization
|
|
104
|
+
|
|
105
|
+
A HAR file is an HTTP Archive file that contains a record of all the network requests that are made when a page is loaded.
|
|
106
|
+
It contains information about the request and response headers, cookies, content, timings, and more. You can use HAR files to mock network requests in your tests.
|
|
107
|
+
HAR will be saved to `output/har`. More info could be found here [https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har][3].
|
|
108
|
+
|
|
109
|
+
...
|
|
110
|
+
recordHar: {
|
|
111
|
+
mode: 'minimal', // possible values: 'minimal'|'full'.
|
|
112
|
+
content: 'embed' // possible values: "omit"|"embed"|"attach".
|
|
113
|
+
}
|
|
114
|
+
...
|
|
115
|
+
|
|
102
116
|
#### Example #1: Wait for 0 network connections.
|
|
103
117
|
|
|
104
118
|
```js
|
|
@@ -142,7 +156,7 @@ Traces will be saved to `output/trace`
|
|
|
142
156
|
}
|
|
143
157
|
```
|
|
144
158
|
|
|
145
|
-
#### Example #4: Connect to remote browser by specifying [websocket endpoint][
|
|
159
|
+
#### Example #4: Connect to remote browser by specifying [websocket endpoint][4]
|
|
146
160
|
|
|
147
161
|
```js
|
|
148
162
|
{
|
|
@@ -160,7 +174,7 @@ Traces will be saved to `output/trace`
|
|
|
160
174
|
|
|
161
175
|
#### Example #5: Testing with Chromium extensions
|
|
162
176
|
|
|
163
|
-
[official docs][
|
|
177
|
+
[official docs][5]
|
|
164
178
|
|
|
165
179
|
```js
|
|
166
180
|
{
|
|
@@ -283,7 +297,7 @@ Usually it should be run from a custom helper after call of `_startBrowser()`
|
|
|
283
297
|
|
|
284
298
|
#### Parameters
|
|
285
299
|
|
|
286
|
-
- `contextOptions` **[object][
|
|
300
|
+
- `contextOptions` **[object][6]?** See [https://playwright.dev/docs/api/class-browser#browser-new-context][7]
|
|
287
301
|
|
|
288
302
|
### _getPageUrl
|
|
289
303
|
|
|
@@ -359,13 +373,13 @@ Set current page
|
|
|
359
373
|
|
|
360
374
|
#### Parameters
|
|
361
375
|
|
|
362
|
-
- `page` **[object][
|
|
376
|
+
- `page` **[object][6]** page to set
|
|
363
377
|
|
|
364
378
|
### acceptPopup
|
|
365
379
|
|
|
366
380
|
Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
|
|
367
381
|
Don't confuse popups with modal windows, as created by [various
|
|
368
|
-
libraries][
|
|
382
|
+
libraries][8].
|
|
369
383
|
|
|
370
384
|
### amAcceptingPopups
|
|
371
385
|
|
|
@@ -402,7 +416,7 @@ I.amOnPage('/login'); // opens a login page
|
|
|
402
416
|
|
|
403
417
|
#### Parameters
|
|
404
418
|
|
|
405
|
-
- `url` **[string][
|
|
419
|
+
- `url` **[string][9]** url path or global url.
|
|
406
420
|
|
|
407
421
|
Returns **void** automatically synchronized promise through #recorder
|
|
408
422
|
|
|
@@ -419,8 +433,8 @@ I.appendField('password', secret('123456'));
|
|
|
419
433
|
|
|
420
434
|
#### Parameters
|
|
421
435
|
|
|
422
|
-
- `field` **([string][
|
|
423
|
-
- `value` **[string][
|
|
436
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator
|
|
437
|
+
- `value` **[string][9]** text value to append.
|
|
424
438
|
|
|
425
439
|
Returns **void** automatically synchronized promise through #recorder
|
|
426
440
|
|
|
@@ -437,8 +451,8 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
437
451
|
|
|
438
452
|
#### Parameters
|
|
439
453
|
|
|
440
|
-
- `locator` **([string][
|
|
441
|
-
- `pathToFile` **[string][
|
|
454
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
455
|
+
- `pathToFile` **[string][9]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
442
456
|
|
|
443
457
|
Returns **void** automatically synchronized promise through #recorder
|
|
444
458
|
|
|
@@ -461,12 +475,12 @@ I.blockTraffic(['http://example.com/css/style.css', 'http://example.com/css/*.cs
|
|
|
461
475
|
|
|
462
476
|
#### Parameters
|
|
463
477
|
|
|
464
|
-
- `urls` **([string][
|
|
478
|
+
- `urls` **([string][9] | [Array][10] | [RegExp][11])** URL or a list of URLs to block . URL can contain * for wildcards. Example: [https://www.example.com**][12] to block all traffic for that domain. Regexp are also supported.
|
|
465
479
|
|
|
466
480
|
### blur
|
|
467
481
|
|
|
468
482
|
Remove focus from a text input, button, etc.
|
|
469
|
-
Calls [blur][
|
|
483
|
+
Calls [blur][13] on the element.
|
|
470
484
|
|
|
471
485
|
Examples:
|
|
472
486
|
|
|
@@ -483,8 +497,8 @@ I.dontSee('#add-to-cart-btn');
|
|
|
483
497
|
|
|
484
498
|
#### Parameters
|
|
485
499
|
|
|
486
|
-
- `locator` **([string][
|
|
487
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
500
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
501
|
+
- `options` **any?** Playwright only: [Additional options][14] for available options object as 2nd argument.
|
|
488
502
|
|
|
489
503
|
Returns **void** automatically synchronized promise through #recorder
|
|
490
504
|
|
|
@@ -507,11 +521,11 @@ I.checkOption('agree', '//form');
|
|
|
507
521
|
|
|
508
522
|
#### Parameters
|
|
509
523
|
|
|
510
|
-
- `field` **([string][
|
|
511
|
-
- `context` **([string][
|
|
524
|
+
- `field` **([string][9] | [object][6])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
525
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
512
526
|
- `options`
|
|
513
527
|
|
|
514
|
-
Returns **void** automatically synchronized promise through #recorder[Additional options][
|
|
528
|
+
Returns **void** automatically synchronized promise through #recorder[Additional options][15] for check available as 3rd argument.Examples:```js
|
|
515
529
|
// click on element at position
|
|
516
530
|
I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
517
531
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -528,7 +542,7 @@ I.clearCookie('test'); // Playwright currently doesn't support clear a particula
|
|
|
528
542
|
|
|
529
543
|
#### Parameters
|
|
530
544
|
|
|
531
|
-
- `cookie` **[string][
|
|
545
|
+
- `cookie` **[string][9]?** (optional, `null` by default) cookie name
|
|
532
546
|
|
|
533
547
|
### clearField
|
|
534
548
|
|
|
@@ -543,12 +557,12 @@ I.clearField('.text-area')
|
|
|
543
557
|
I.clearField('#submit', { force: true })
|
|
544
558
|
```
|
|
545
559
|
|
|
546
|
-
Use `force` to bypass the [actionability][
|
|
560
|
+
Use `force` to bypass the [actionability][16] checks.
|
|
547
561
|
|
|
548
562
|
#### Parameters
|
|
549
563
|
|
|
550
|
-
- `locator` **([string][
|
|
551
|
-
- `options` **any?** [Additional options][
|
|
564
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
565
|
+
- `options` **any?** [Additional options][17] for available options object as 2nd argument.
|
|
552
566
|
|
|
553
567
|
### click
|
|
554
568
|
|
|
@@ -576,9 +590,9 @@ I.click({css: 'nav a.login'});
|
|
|
576
590
|
|
|
577
591
|
#### Parameters
|
|
578
592
|
|
|
579
|
-
- `locator` **([string][
|
|
580
|
-
- `context` **([string][
|
|
581
|
-
- `options` **any?** [Additional options][
|
|
593
|
+
- `locator` **([string][9] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
594
|
+
- `context` **([string][9]? | [object][6] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
595
|
+
- `options` **any?** [Additional options][18] for click available as 3rd argument.Examples:```js
|
|
582
596
|
// click on element at position
|
|
583
597
|
I.click('canvas', '.model', { position: { x: 20, y: 40 } })
|
|
584
598
|
|
|
@@ -625,8 +639,8 @@ I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
|
625
639
|
|
|
626
640
|
#### Parameters
|
|
627
641
|
|
|
628
|
-
- `text` **[string][
|
|
629
|
-
- `context` **([string][
|
|
642
|
+
- `text` **[string][9]** which is not present.
|
|
643
|
+
- `context` **([string][9] | [object][6])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
630
644
|
|
|
631
645
|
Returns **void** automatically synchronized promise through #recorder
|
|
632
646
|
|
|
@@ -642,7 +656,7 @@ I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
|
642
656
|
|
|
643
657
|
#### Parameters
|
|
644
658
|
|
|
645
|
-
- `field` **([string][
|
|
659
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
646
660
|
|
|
647
661
|
Returns **void** automatically synchronized promise through #recorder
|
|
648
662
|
|
|
@@ -656,7 +670,7 @@ I.dontSeeCookie('auth'); // no auth cookie
|
|
|
656
670
|
|
|
657
671
|
#### Parameters
|
|
658
672
|
|
|
659
|
-
- `name` **[string][
|
|
673
|
+
- `name` **[string][9]** cookie name.
|
|
660
674
|
|
|
661
675
|
Returns **void** automatically synchronized promise through #recorder
|
|
662
676
|
|
|
@@ -672,7 +686,7 @@ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also
|
|
|
672
686
|
|
|
673
687
|
#### Parameters
|
|
674
688
|
|
|
675
|
-
- `url` **[string][
|
|
689
|
+
- `url` **[string][9]** value to check.
|
|
676
690
|
|
|
677
691
|
Returns **void** automatically synchronized promise through #recorder
|
|
678
692
|
|
|
@@ -686,7 +700,7 @@ I.dontSeeElement('.modal'); // modal is not shown
|
|
|
686
700
|
|
|
687
701
|
#### Parameters
|
|
688
702
|
|
|
689
|
-
- `locator` **([string][
|
|
703
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|Strict locator.
|
|
690
704
|
|
|
691
705
|
Returns **void** automatically synchronized promise through #recorder
|
|
692
706
|
|
|
@@ -700,7 +714,7 @@ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or
|
|
|
700
714
|
|
|
701
715
|
#### Parameters
|
|
702
716
|
|
|
703
|
-
- `locator` **([string][
|
|
717
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|Strict locator.
|
|
704
718
|
|
|
705
719
|
Returns **void** automatically synchronized promise through #recorder
|
|
706
720
|
|
|
@@ -710,7 +724,7 @@ Checks that current url does not contain a provided fragment.
|
|
|
710
724
|
|
|
711
725
|
#### Parameters
|
|
712
726
|
|
|
713
|
-
- `url` **[string][
|
|
727
|
+
- `url` **[string][9]** value to check.
|
|
714
728
|
|
|
715
729
|
Returns **void** automatically synchronized promise through #recorder
|
|
716
730
|
|
|
@@ -726,8 +740,8 @@ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
|
726
740
|
|
|
727
741
|
#### Parameters
|
|
728
742
|
|
|
729
|
-
- `field` **([string][
|
|
730
|
-
- `value` **([string][
|
|
743
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
744
|
+
- `value` **([string][9] | [object][6])** value to check.
|
|
731
745
|
|
|
732
746
|
Returns **void** automatically synchronized promise through #recorder
|
|
733
747
|
|
|
@@ -742,7 +756,7 @@ I.dontSeeInSource('<!--'); // no comments in source
|
|
|
742
756
|
#### Parameters
|
|
743
757
|
|
|
744
758
|
- `text`
|
|
745
|
-
- `value` **[string][
|
|
759
|
+
- `value` **[string][9]** to check.
|
|
746
760
|
|
|
747
761
|
Returns **void** automatically synchronized promise through #recorder
|
|
748
762
|
|
|
@@ -756,7 +770,7 @@ I.dontSeeInTitle('Error');
|
|
|
756
770
|
|
|
757
771
|
#### Parameters
|
|
758
772
|
|
|
759
|
-
- `text` **[string][
|
|
773
|
+
- `text` **[string][9]** value to check.
|
|
760
774
|
|
|
761
775
|
Returns **void** automatically synchronized promise through #recorder
|
|
762
776
|
|
|
@@ -773,9 +787,9 @@ I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.exa
|
|
|
773
787
|
|
|
774
788
|
#### Parameters
|
|
775
789
|
|
|
776
|
-
- `opts` **[Object][
|
|
777
|
-
- `opts.name` **[string][
|
|
778
|
-
- `opts.url` **([string][
|
|
790
|
+
- `opts` **[Object][6]** options when checking the traffic network.
|
|
791
|
+
- `opts.name` **[string][9]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
|
|
792
|
+
- `opts.url` **([string][9] | [RegExp][11])** Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
779
793
|
|
|
780
794
|
### doubleClick
|
|
781
795
|
|
|
@@ -791,8 +805,8 @@ I.doubleClick('.btn.edit');
|
|
|
791
805
|
|
|
792
806
|
#### Parameters
|
|
793
807
|
|
|
794
|
-
- `locator` **([string][
|
|
795
|
-
- `context` **([string][
|
|
808
|
+
- `locator` **([string][9] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
809
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
796
810
|
|
|
797
811
|
Returns **void** automatically synchronized promise through #recorder
|
|
798
812
|
|
|
@@ -806,9 +820,9 @@ I.dragAndDrop('#dragHandle', '#container');
|
|
|
806
820
|
|
|
807
821
|
#### Parameters
|
|
808
822
|
|
|
809
|
-
- `srcElement` **([string][
|
|
810
|
-
- `destElement` **([string][
|
|
811
|
-
- `options` **any?** [Additional options][
|
|
823
|
+
- `srcElement` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
824
|
+
- `destElement` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
825
|
+
- `options` **any?** [Additional options][19] can be passed as 3rd argument.```js
|
|
812
826
|
// specify coordinates for source position
|
|
813
827
|
I.dragAndDrop('img.src', 'img.dst', { sourcePosition: {x: 10, y: 10} })
|
|
814
828
|
```> 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`
|
|
@@ -827,8 +841,8 @@ I.dragSlider('#slider', -70);
|
|
|
827
841
|
|
|
828
842
|
#### Parameters
|
|
829
843
|
|
|
830
|
-
- `locator` **([string][
|
|
831
|
-
- `offsetX` **[number][
|
|
844
|
+
- `locator` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
845
|
+
- `offsetX` **[number][20]** position to drag.
|
|
832
846
|
|
|
833
847
|
Returns **void** automatically synchronized promise through #recorder
|
|
834
848
|
|
|
@@ -857,10 +871,10 @@ If a function returns a Promise it will wait for its resolution.
|
|
|
857
871
|
|
|
858
872
|
#### Parameters
|
|
859
873
|
|
|
860
|
-
- `fn` **([string][
|
|
874
|
+
- `fn` **([string][9] | [function][21])** function to be executed in browser context.
|
|
861
875
|
- `arg` **any?** optional argument to pass to the function
|
|
862
876
|
|
|
863
|
-
Returns **[Promise][
|
|
877
|
+
Returns **[Promise][22]<any>**
|
|
864
878
|
|
|
865
879
|
### fillField
|
|
866
880
|
|
|
@@ -880,8 +894,8 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
880
894
|
|
|
881
895
|
#### Parameters
|
|
882
896
|
|
|
883
|
-
- `field` **([string][
|
|
884
|
-
- `value` **([string][
|
|
897
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
898
|
+
- `value` **([string][9] | [object][6])** text value to fill.
|
|
885
899
|
|
|
886
900
|
Returns **void** automatically synchronized promise through #recorder
|
|
887
901
|
|
|
@@ -895,7 +909,7 @@ Resets all recorded WS messages.
|
|
|
895
909
|
|
|
896
910
|
### focus
|
|
897
911
|
|
|
898
|
-
Calls [focus][
|
|
912
|
+
Calls [focus][13] on the matching element.
|
|
899
913
|
|
|
900
914
|
Examples:
|
|
901
915
|
|
|
@@ -907,8 +921,8 @@ I.see('#add-to-cart-bnt');
|
|
|
907
921
|
|
|
908
922
|
#### Parameters
|
|
909
923
|
|
|
910
|
-
- `locator` **([string][
|
|
911
|
-
- `options` **any?** Playwright only: [Additional options][
|
|
924
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
925
|
+
- `options` **any?** Playwright only: [Additional options][23] for available options object as 2nd argument.
|
|
912
926
|
|
|
913
927
|
Returns **void** automatically synchronized promise through #recorder
|
|
914
928
|
|
|
@@ -941,8 +955,8 @@ I.forceClick({css: 'nav a.login'});
|
|
|
941
955
|
|
|
942
956
|
#### Parameters
|
|
943
957
|
|
|
944
|
-
- `locator` **([string][
|
|
945
|
-
- `context` **([string][
|
|
958
|
+
- `locator` **([string][9] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
959
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
946
960
|
|
|
947
961
|
Returns **void** automatically synchronized promise through #recorder
|
|
948
962
|
|
|
@@ -958,10 +972,10 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
958
972
|
|
|
959
973
|
#### Parameters
|
|
960
974
|
|
|
961
|
-
- `locator` **([string][
|
|
962
|
-
- `attr` **[string][
|
|
975
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
976
|
+
- `attr` **[string][9]** attribute name.
|
|
963
977
|
|
|
964
|
-
Returns **[Promise][
|
|
978
|
+
Returns **[Promise][22]<[string][9]>** attribute value
|
|
965
979
|
|
|
966
980
|
### grabAttributeFromAll
|
|
967
981
|
|
|
@@ -974,10 +988,10 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
974
988
|
|
|
975
989
|
#### Parameters
|
|
976
990
|
|
|
977
|
-
- `locator` **([string][
|
|
978
|
-
- `attr` **[string][
|
|
991
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
992
|
+
- `attr` **[string][9]** attribute name.
|
|
979
993
|
|
|
980
|
-
Returns **[Promise][
|
|
994
|
+
Returns **[Promise][22]<[Array][10]<[string][9]>>** attribute value
|
|
981
995
|
|
|
982
996
|
### grabBrowserLogs
|
|
983
997
|
|
|
@@ -989,9 +1003,9 @@ const errors = logs.map(l => ({ type: l.type(), text: l.text() })).filter(l => l
|
|
|
989
1003
|
console.log(JSON.stringify(errors));
|
|
990
1004
|
```
|
|
991
1005
|
|
|
992
|
-
[Learn more about console messages][
|
|
1006
|
+
[Learn more about console messages][24]
|
|
993
1007
|
|
|
994
|
-
Returns **[Promise][
|
|
1008
|
+
Returns **[Promise][22]<[Array][10]<any>>**
|
|
995
1009
|
|
|
996
1010
|
### grabCheckedElementStatus
|
|
997
1011
|
|
|
@@ -999,10 +1013,10 @@ Return the checked status of given element.
|
|
|
999
1013
|
|
|
1000
1014
|
#### Parameters
|
|
1001
1015
|
|
|
1002
|
-
- `locator` **([string][
|
|
1003
|
-
- `options` **[object][
|
|
1016
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1017
|
+
- `options` **[object][6]?** See [https://playwright.dev/docs/api/class-locator#locator-is-checked][25]
|
|
1004
1018
|
|
|
1005
|
-
Returns **[Promise][
|
|
1019
|
+
Returns **[Promise][22]<[boolean][26]>**
|
|
1006
1020
|
|
|
1007
1021
|
### grabCookie
|
|
1008
1022
|
|
|
@@ -1017,7 +1031,7 @@ assert(cookie.value, '123456');
|
|
|
1017
1031
|
|
|
1018
1032
|
#### Parameters
|
|
1019
1033
|
|
|
1020
|
-
- `name` **[string][
|
|
1034
|
+
- `name` **[string][9]?** cookie name.
|
|
1021
1035
|
|
|
1022
1036
|
Returns **any** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
1023
1037
|
|
|
@@ -1033,10 +1047,10 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
1033
1047
|
|
|
1034
1048
|
#### Parameters
|
|
1035
1049
|
|
|
1036
|
-
- `locator` **([string][
|
|
1037
|
-
- `cssProperty` **[string][
|
|
1050
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1051
|
+
- `cssProperty` **[string][9]** CSS property name.
|
|
1038
1052
|
|
|
1039
|
-
Returns **[Promise][
|
|
1053
|
+
Returns **[Promise][22]<[string][9]>** CSS value
|
|
1040
1054
|
|
|
1041
1055
|
### grabCssPropertyFromAll
|
|
1042
1056
|
|
|
@@ -1049,10 +1063,10 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
1049
1063
|
|
|
1050
1064
|
#### Parameters
|
|
1051
1065
|
|
|
1052
|
-
- `locator` **([string][
|
|
1053
|
-
- `cssProperty` **[string][
|
|
1066
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1067
|
+
- `cssProperty` **[string][9]** CSS property name.
|
|
1054
1068
|
|
|
1055
|
-
Returns **[Promise][
|
|
1069
|
+
Returns **[Promise][22]<[Array][10]<[string][9]>>** CSS value
|
|
1056
1070
|
|
|
1057
1071
|
### grabCurrentUrl
|
|
1058
1072
|
|
|
@@ -1064,7 +1078,7 @@ let url = await I.grabCurrentUrl();
|
|
|
1064
1078
|
console.log(`Current URL is [${url}]`);
|
|
1065
1079
|
```
|
|
1066
1080
|
|
|
1067
|
-
Returns **[Promise][
|
|
1081
|
+
Returns **[Promise][22]<[string][9]>** current URL
|
|
1068
1082
|
|
|
1069
1083
|
### grabDataFromPerformanceTiming
|
|
1070
1084
|
|
|
@@ -1097,10 +1111,10 @@ Return the disabled status of given element.
|
|
|
1097
1111
|
|
|
1098
1112
|
#### Parameters
|
|
1099
1113
|
|
|
1100
|
-
- `locator` **([string][
|
|
1101
|
-
- `options` **[object][
|
|
1114
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1115
|
+
- `options` **[object][6]?** See [https://playwright.dev/docs/api/class-locator#locator-is-disabled][27]
|
|
1102
1116
|
|
|
1103
|
-
Returns **[Promise][
|
|
1117
|
+
Returns **[Promise][22]<[boolean][26]>**
|
|
1104
1118
|
|
|
1105
1119
|
### grabElementBoundingRect
|
|
1106
1120
|
|
|
@@ -1124,11 +1138,11 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
1124
1138
|
|
|
1125
1139
|
#### Parameters
|
|
1126
1140
|
|
|
1127
|
-
- `locator` **([string][
|
|
1141
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1128
1142
|
- `prop`
|
|
1129
|
-
- `elementSize` **[string][
|
|
1143
|
+
- `elementSize` **[string][9]?** x, y, width or height of the given element.
|
|
1130
1144
|
|
|
1131
|
-
Returns **([Promise][
|
|
1145
|
+
Returns **([Promise][22]<DOMRect> | [Promise][22]<[number][20]>)** Element bounding rectangle
|
|
1132
1146
|
|
|
1133
1147
|
### grabHTMLFrom
|
|
1134
1148
|
|
|
@@ -1143,9 +1157,9 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
1143
1157
|
#### Parameters
|
|
1144
1158
|
|
|
1145
1159
|
- `locator`
|
|
1146
|
-
- `element` **([string][
|
|
1160
|
+
- `element` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1147
1161
|
|
|
1148
|
-
Returns **[Promise][
|
|
1162
|
+
Returns **[Promise][22]<[string][9]>** HTML code for an element
|
|
1149
1163
|
|
|
1150
1164
|
### grabHTMLFromAll
|
|
1151
1165
|
|
|
@@ -1159,9 +1173,9 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
1159
1173
|
#### Parameters
|
|
1160
1174
|
|
|
1161
1175
|
- `locator`
|
|
1162
|
-
- `element` **([string][
|
|
1176
|
+
- `element` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1163
1177
|
|
|
1164
|
-
Returns **[Promise][
|
|
1178
|
+
Returns **[Promise][22]<[Array][10]<[string][9]>>** HTML code for an element
|
|
1165
1179
|
|
|
1166
1180
|
### grabMetrics
|
|
1167
1181
|
|
|
@@ -1215,7 +1229,7 @@ const metrics = await I.grabMetrics();
|
|
|
1215
1229
|
]
|
|
1216
1230
|
```
|
|
1217
1231
|
|
|
1218
|
-
Returns **[Promise][
|
|
1232
|
+
Returns **[Promise][22]<[Array][10]<[Object][6]>>**
|
|
1219
1233
|
|
|
1220
1234
|
### grabNumberOfOpenTabs
|
|
1221
1235
|
|
|
@@ -1226,7 +1240,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1226
1240
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
1227
1241
|
```
|
|
1228
1242
|
|
|
1229
|
-
Returns **[Promise][
|
|
1243
|
+
Returns **[Promise][22]<[number][20]>** number of open tabs
|
|
1230
1244
|
|
|
1231
1245
|
### grabNumberOfVisibleElements
|
|
1232
1246
|
|
|
@@ -1239,9 +1253,9 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
1239
1253
|
|
|
1240
1254
|
#### Parameters
|
|
1241
1255
|
|
|
1242
|
-
- `locator` **([string][
|
|
1256
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1243
1257
|
|
|
1244
|
-
Returns **[Promise][
|
|
1258
|
+
Returns **[Promise][22]<[number][20]>** number of visible elements
|
|
1245
1259
|
|
|
1246
1260
|
### grabPageScrollPosition
|
|
1247
1261
|
|
|
@@ -1252,7 +1266,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
1252
1266
|
let { x, y } = await I.grabPageScrollPosition();
|
|
1253
1267
|
```
|
|
1254
1268
|
|
|
1255
|
-
Returns **[Promise][
|
|
1269
|
+
Returns **[Promise][22]<PageScrollPosition>** scroll position
|
|
1256
1270
|
|
|
1257
1271
|
### grabPopupText
|
|
1258
1272
|
|
|
@@ -1262,7 +1276,7 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
1262
1276
|
await I.grabPopupText();
|
|
1263
1277
|
```
|
|
1264
1278
|
|
|
1265
|
-
Returns **[Promise][
|
|
1279
|
+
Returns **[Promise][22]<([string][9] | null)>**
|
|
1266
1280
|
|
|
1267
1281
|
### grabRecordedNetworkTraffics
|
|
1268
1282
|
|
|
@@ -1275,7 +1289,7 @@ expect(traffics[0].response.status).to.equal(200);
|
|
|
1275
1289
|
expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
1276
1290
|
```
|
|
1277
1291
|
|
|
1278
|
-
Returns **[Promise][
|
|
1292
|
+
Returns **[Promise][22]<[Array][10]<any>>**
|
|
1279
1293
|
|
|
1280
1294
|
### grabSource
|
|
1281
1295
|
|
|
@@ -1286,7 +1300,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1286
1300
|
let pageSource = await I.grabSource();
|
|
1287
1301
|
```
|
|
1288
1302
|
|
|
1289
|
-
Returns **[Promise][
|
|
1303
|
+
Returns **[Promise][22]<[string][9]>** source code
|
|
1290
1304
|
|
|
1291
1305
|
### grabTextFrom
|
|
1292
1306
|
|
|
@@ -1301,9 +1315,9 @@ If multiple elements found returns first element.
|
|
|
1301
1315
|
|
|
1302
1316
|
#### Parameters
|
|
1303
1317
|
|
|
1304
|
-
- `locator` **([string][
|
|
1318
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1305
1319
|
|
|
1306
|
-
Returns **[Promise][
|
|
1320
|
+
Returns **[Promise][22]<[string][9]>** attribute value
|
|
1307
1321
|
|
|
1308
1322
|
### grabTextFromAll
|
|
1309
1323
|
|
|
@@ -1316,9 +1330,9 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
1316
1330
|
|
|
1317
1331
|
#### Parameters
|
|
1318
1332
|
|
|
1319
|
-
- `locator` **([string][
|
|
1333
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1320
1334
|
|
|
1321
|
-
Returns **[Promise][
|
|
1335
|
+
Returns **[Promise][22]<[Array][10]<[string][9]>>** attribute value
|
|
1322
1336
|
|
|
1323
1337
|
### grabTitle
|
|
1324
1338
|
|
|
@@ -1329,7 +1343,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
1329
1343
|
let title = await I.grabTitle();
|
|
1330
1344
|
```
|
|
1331
1345
|
|
|
1332
|
-
Returns **[Promise][
|
|
1346
|
+
Returns **[Promise][22]<[string][9]>** title
|
|
1333
1347
|
|
|
1334
1348
|
### grabTrafficUrl
|
|
1335
1349
|
|
|
@@ -1337,12 +1351,12 @@ Returns full URL of request matching parameter "urlMatch".
|
|
|
1337
1351
|
|
|
1338
1352
|
#### Parameters
|
|
1339
1353
|
|
|
1340
|
-
- `urlMatch` **([string][
|
|
1354
|
+
- `urlMatch` **([string][9] | [RegExp][11])** Expected URL of request in network traffic. Can be a string or a regular expression.Examples:```js
|
|
1341
1355
|
I.grabTrafficUrl('https://api.example.com/session');
|
|
1342
1356
|
I.grabTrafficUrl(/session.*start/);
|
|
1343
1357
|
```
|
|
1344
1358
|
|
|
1345
|
-
Returns **[Promise][
|
|
1359
|
+
Returns **[Promise][22]<any>**
|
|
1346
1360
|
|
|
1347
1361
|
### grabValueFrom
|
|
1348
1362
|
|
|
@@ -1356,9 +1370,9 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
1356
1370
|
|
|
1357
1371
|
#### Parameters
|
|
1358
1372
|
|
|
1359
|
-
- `locator` **([string][
|
|
1373
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1360
1374
|
|
|
1361
|
-
Returns **[Promise][
|
|
1375
|
+
Returns **[Promise][22]<[string][9]>** attribute value
|
|
1362
1376
|
|
|
1363
1377
|
### grabValueFromAll
|
|
1364
1378
|
|
|
@@ -1371,22 +1385,22 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
1371
1385
|
|
|
1372
1386
|
#### Parameters
|
|
1373
1387
|
|
|
1374
|
-
- `locator` **([string][
|
|
1388
|
+
- `locator` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1375
1389
|
|
|
1376
|
-
Returns **[Promise][
|
|
1390
|
+
Returns **[Promise][22]<[Array][10]<[string][9]>>** attribute value
|
|
1377
1391
|
|
|
1378
1392
|
### grabWebSocketMessages
|
|
1379
1393
|
|
|
1380
1394
|
Grab the recording WS messages
|
|
1381
1395
|
|
|
1382
|
-
Returns **[Array][
|
|
1396
|
+
Returns **[Array][10]<any>**
|
|
1383
1397
|
|
|
1384
1398
|
### handleDownloads
|
|
1385
1399
|
|
|
1386
1400
|
Handles a file download. A file name is required to save the file on disk.
|
|
1387
1401
|
Files are saved to "output" directory.
|
|
1388
1402
|
|
|
1389
|
-
Should be used with [FileSystem helper][
|
|
1403
|
+
Should be used with [FileSystem helper][28] to check that file were downloaded correctly.
|
|
1390
1404
|
|
|
1391
1405
|
```js
|
|
1392
1406
|
I.handleDownloads('downloads/avatar.jpg');
|
|
@@ -1397,13 +1411,13 @@ I.waitForFile('avatar.jpg', 5);
|
|
|
1397
1411
|
|
|
1398
1412
|
#### Parameters
|
|
1399
1413
|
|
|
1400
|
-
- `fileName` **[string][
|
|
1414
|
+
- `fileName` **[string][9]** set filename for downloaded file
|
|
1401
1415
|
|
|
1402
|
-
Returns **[Promise][
|
|
1416
|
+
Returns **[Promise][22]<void>**
|
|
1403
1417
|
|
|
1404
1418
|
### makeApiRequest
|
|
1405
1419
|
|
|
1406
|
-
Performs [api request][
|
|
1420
|
+
Performs [api request][29] using
|
|
1407
1421
|
the cookies from the current browser session.
|
|
1408
1422
|
|
|
1409
1423
|
```js
|
|
@@ -1416,26 +1430,26 @@ I.makeApiRequest('PATCH', )
|
|
|
1416
1430
|
|
|
1417
1431
|
#### Parameters
|
|
1418
1432
|
|
|
1419
|
-
- `method` **[string][
|
|
1420
|
-
- `url` **[string][
|
|
1421
|
-
- `options` **[object][
|
|
1433
|
+
- `method` **[string][9]** HTTP method
|
|
1434
|
+
- `url` **[string][9]** endpoint
|
|
1435
|
+
- `options` **[object][6]** request options depending on method used
|
|
1422
1436
|
|
|
1423
|
-
Returns **[Promise][
|
|
1437
|
+
Returns **[Promise][22]<[object][6]>** response
|
|
1424
1438
|
|
|
1425
1439
|
### mockRoute
|
|
1426
1440
|
|
|
1427
|
-
Mocks network request using [`browserContext.route`][
|
|
1441
|
+
Mocks network request using [`browserContext.route`][30] of Playwright
|
|
1428
1442
|
|
|
1429
1443
|
```js
|
|
1430
1444
|
I.mockRoute(/(.png$)|(.jpg$)/, route => route.abort());
|
|
1431
1445
|
```
|
|
1432
1446
|
|
|
1433
|
-
This method allows intercepting and mocking requests & responses. [Learn more about it][
|
|
1447
|
+
This method allows intercepting and mocking requests & responses. [Learn more about it][31]
|
|
1434
1448
|
|
|
1435
1449
|
#### Parameters
|
|
1436
1450
|
|
|
1437
|
-
- `url` **([string][
|
|
1438
|
-
- `handler` **[function][
|
|
1451
|
+
- `url` **([string][9] | [RegExp][11])?** URL, regex or pattern for to match URL
|
|
1452
|
+
- `handler` **[function][21]?** a function to process reques
|
|
1439
1453
|
|
|
1440
1454
|
### mockTraffic
|
|
1441
1455
|
|
|
@@ -1468,9 +1482,9 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1468
1482
|
|
|
1469
1483
|
#### Parameters
|
|
1470
1484
|
|
|
1471
|
-
- `locator` **([string][
|
|
1472
|
-
- `offsetX` **[number][
|
|
1473
|
-
- `offsetY` **[number][
|
|
1485
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1486
|
+
- `offsetX` **[number][20]** (optional, `0` by default) X-axis offset.
|
|
1487
|
+
- `offsetY` **[number][20]** (optional, `0` by default) Y-axis offset.
|
|
1474
1488
|
|
|
1475
1489
|
Returns **void** automatically synchronized promise through #recorder
|
|
1476
1490
|
|
|
@@ -1482,7 +1496,7 @@ Open new tab and automatically switched to new tab
|
|
|
1482
1496
|
I.openNewTab();
|
|
1483
1497
|
```
|
|
1484
1498
|
|
|
1485
|
-
You can pass in [page options][
|
|
1499
|
+
You can pass in [page options][32] to emulate device on this page
|
|
1486
1500
|
|
|
1487
1501
|
```js
|
|
1488
1502
|
// enable mobile
|
|
@@ -1497,7 +1511,7 @@ I.openNewTab({ isMobile: true });
|
|
|
1497
1511
|
|
|
1498
1512
|
Presses a key in the browser (on a focused element).
|
|
1499
1513
|
|
|
1500
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1514
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][33].
|
|
1501
1515
|
|
|
1502
1516
|
```js
|
|
1503
1517
|
I.pressKey('Backspace');
|
|
@@ -1556,15 +1570,15 @@ Some of the supported key names are:
|
|
|
1556
1570
|
|
|
1557
1571
|
#### Parameters
|
|
1558
1572
|
|
|
1559
|
-
- `key` **([string][
|
|
1573
|
+
- `key` **([string][9] | [Array][10]<[string][9]>)** key or array of keys to press.
|
|
1560
1574
|
|
|
1561
|
-
Returns **void** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][
|
|
1575
|
+
Returns **void** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][34]).
|
|
1562
1576
|
|
|
1563
1577
|
### pressKeyDown
|
|
1564
1578
|
|
|
1565
1579
|
Presses a key in the browser and leaves it in a down state.
|
|
1566
1580
|
|
|
1567
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1581
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][35]).
|
|
1568
1582
|
|
|
1569
1583
|
```js
|
|
1570
1584
|
I.pressKeyDown('Control');
|
|
@@ -1574,7 +1588,7 @@ I.pressKeyUp('Control');
|
|
|
1574
1588
|
|
|
1575
1589
|
#### Parameters
|
|
1576
1590
|
|
|
1577
|
-
- `key` **[string][
|
|
1591
|
+
- `key` **[string][9]** name of key to press down.
|
|
1578
1592
|
|
|
1579
1593
|
Returns **void** automatically synchronized promise through #recorder
|
|
1580
1594
|
|
|
@@ -1582,7 +1596,7 @@ Returns **void** automatically synchronized promise through #recorder
|
|
|
1582
1596
|
|
|
1583
1597
|
Releases a key in the browser which was previously set to a down state.
|
|
1584
1598
|
|
|
1585
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1599
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][35]).
|
|
1586
1600
|
|
|
1587
1601
|
```js
|
|
1588
1602
|
I.pressKeyDown('Control');
|
|
@@ -1592,7 +1606,7 @@ I.pressKeyUp('Control');
|
|
|
1592
1606
|
|
|
1593
1607
|
#### Parameters
|
|
1594
1608
|
|
|
1595
|
-
- `key` **[string][
|
|
1609
|
+
- `key` **[string][9]** name of key to release.
|
|
1596
1610
|
|
|
1597
1611
|
Returns **void** automatically synchronized promise through #recorder
|
|
1598
1612
|
|
|
@@ -1606,6 +1620,26 @@ I.refreshPage();
|
|
|
1606
1620
|
|
|
1607
1621
|
Returns **void** automatically synchronized promise through #recorder
|
|
1608
1622
|
|
|
1623
|
+
### replayFromHar
|
|
1624
|
+
|
|
1625
|
+
Replaying from HAR
|
|
1626
|
+
|
|
1627
|
+
```js
|
|
1628
|
+
// Replay API requests from HAR.
|
|
1629
|
+
// Either use a matching response from the HAR,
|
|
1630
|
+
// or abort the request if nothing matches.
|
|
1631
|
+
I.replayFromHar('./output/har/something.har', { url: "*/**/api/v1/fruits" });
|
|
1632
|
+
I.amOnPage('https://demo.playwright.dev/api-mocking');
|
|
1633
|
+
I.see('CodeceptJS');
|
|
1634
|
+
```
|
|
1635
|
+
|
|
1636
|
+
#### Parameters
|
|
1637
|
+
|
|
1638
|
+
- `harFilePath` **[string][9]** Path to recorded HAR file
|
|
1639
|
+
- `opts` **[object][6]?** [Options for replaying from HAR][36]
|
|
1640
|
+
|
|
1641
|
+
Returns **any** Promise<void>
|
|
1642
|
+
|
|
1609
1643
|
### resizeWindow
|
|
1610
1644
|
|
|
1611
1645
|
Resize the current window to provided width and height.
|
|
@@ -1613,8 +1647,8 @@ First parameter can be set to `maximize`.
|
|
|
1613
1647
|
|
|
1614
1648
|
#### Parameters
|
|
1615
1649
|
|
|
1616
|
-
- `width` **[number][
|
|
1617
|
-
- `height` **[number][
|
|
1650
|
+
- `width` **[number][20]** width in pixels or `maximize`.
|
|
1651
|
+
- `height` **[number][20]** height in pixels.
|
|
1618
1652
|
|
|
1619
1653
|
Returns **void** automatically synchronized promise through #recorderUnlike other drivers Playwright changes the size of a viewport, not the window!
|
|
1620
1654
|
Playwright does not control the window of a browser so it can't adjust its real size.
|
|
@@ -1639,7 +1673,7 @@ I.restartBrowser({ permissions: ['clipboard-read', 'clipboard-write'] });
|
|
|
1639
1673
|
|
|
1640
1674
|
#### Parameters
|
|
1641
1675
|
|
|
1642
|
-
- `contextOptions` **[object][
|
|
1676
|
+
- `contextOptions` **[object][6]?** [Options for browser context][7] when starting new browser
|
|
1643
1677
|
|
|
1644
1678
|
### rightClick
|
|
1645
1679
|
|
|
@@ -1656,8 +1690,8 @@ I.rightClick('Click me', '.context');
|
|
|
1656
1690
|
|
|
1657
1691
|
#### Parameters
|
|
1658
1692
|
|
|
1659
|
-
- `locator` **([string][
|
|
1660
|
-
- `context` **([string][
|
|
1693
|
+
- `locator` **([string][9] | [object][6])** clickable element located by CSS|XPath|strict locator.
|
|
1694
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1661
1695
|
|
|
1662
1696
|
Returns **void** automatically synchronized promise through #recorder
|
|
1663
1697
|
|
|
@@ -1672,8 +1706,8 @@ I.saveElementScreenshot(`#submit`,'debug.png');
|
|
|
1672
1706
|
|
|
1673
1707
|
#### Parameters
|
|
1674
1708
|
|
|
1675
|
-
- `locator` **([string][
|
|
1676
|
-
- `fileName` **[string][
|
|
1709
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1710
|
+
- `fileName` **[string][9]** file name to save.
|
|
1677
1711
|
|
|
1678
1712
|
Returns **void** automatically synchronized promise through #recorder
|
|
1679
1713
|
|
|
@@ -1690,8 +1724,8 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1690
1724
|
|
|
1691
1725
|
#### Parameters
|
|
1692
1726
|
|
|
1693
|
-
- `fileName` **[string][
|
|
1694
|
-
- `fullPage` **[boolean][
|
|
1727
|
+
- `fileName` **[string][9]** file name to save.
|
|
1728
|
+
- `fullPage` **[boolean][26]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1695
1729
|
|
|
1696
1730
|
Returns **void** automatically synchronized promise through #recorder
|
|
1697
1731
|
|
|
@@ -1727,9 +1761,9 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1727
1761
|
|
|
1728
1762
|
#### Parameters
|
|
1729
1763
|
|
|
1730
|
-
- `locator` **([string][
|
|
1731
|
-
- `offsetX` **[number][
|
|
1732
|
-
- `offsetY` **[number][
|
|
1764
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1765
|
+
- `offsetX` **[number][20]** (optional, `0` by default) X-axis offset.
|
|
1766
|
+
- `offsetY` **[number][20]** (optional, `0` by default) Y-axis offset.
|
|
1733
1767
|
|
|
1734
1768
|
Returns **void** automatically synchronized promise through #recorder
|
|
1735
1769
|
|
|
@@ -1746,8 +1780,8 @@ I.see('Register', {css: 'form.register'}); // use strict locator
|
|
|
1746
1780
|
|
|
1747
1781
|
#### Parameters
|
|
1748
1782
|
|
|
1749
|
-
- `text` **[string][
|
|
1750
|
-
- `context` **([string][
|
|
1783
|
+
- `text` **[string][9]** expected on page.
|
|
1784
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1751
1785
|
|
|
1752
1786
|
Returns **void** automatically synchronized promise through #recorder
|
|
1753
1787
|
|
|
@@ -1761,8 +1795,8 @@ I.seeAttributesOnElements('//form', { method: "post"});
|
|
|
1761
1795
|
|
|
1762
1796
|
#### Parameters
|
|
1763
1797
|
|
|
1764
|
-
- `locator` **([string][
|
|
1765
|
-
- `attributes` **[object][
|
|
1798
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1799
|
+
- `attributes` **[object][6]** attributes and their values to check.
|
|
1766
1800
|
|
|
1767
1801
|
Returns **void** automatically synchronized promise through #recorder
|
|
1768
1802
|
|
|
@@ -1778,7 +1812,7 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
|
1778
1812
|
|
|
1779
1813
|
#### Parameters
|
|
1780
1814
|
|
|
1781
|
-
- `field` **([string][
|
|
1815
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
1782
1816
|
|
|
1783
1817
|
Returns **void** automatically synchronized promise through #recorder
|
|
1784
1818
|
|
|
@@ -1792,7 +1826,7 @@ I.seeCookie('Auth');
|
|
|
1792
1826
|
|
|
1793
1827
|
#### Parameters
|
|
1794
1828
|
|
|
1795
|
-
- `name` **[string][
|
|
1829
|
+
- `name` **[string][9]** cookie name.
|
|
1796
1830
|
|
|
1797
1831
|
Returns **void** automatically synchronized promise through #recorder
|
|
1798
1832
|
|
|
@@ -1806,8 +1840,8 @@ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
|
1806
1840
|
|
|
1807
1841
|
#### Parameters
|
|
1808
1842
|
|
|
1809
|
-
- `locator` **([string][
|
|
1810
|
-
- `cssProperties` **[object][
|
|
1843
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1844
|
+
- `cssProperties` **[object][6]** object with CSS properties and their values to check.
|
|
1811
1845
|
|
|
1812
1846
|
Returns **void** automatically synchronized promise through #recorder
|
|
1813
1847
|
|
|
@@ -1824,7 +1858,7 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
|
1824
1858
|
|
|
1825
1859
|
#### Parameters
|
|
1826
1860
|
|
|
1827
|
-
- `url` **[string][
|
|
1861
|
+
- `url` **[string][9]** value to check.
|
|
1828
1862
|
|
|
1829
1863
|
Returns **void** automatically synchronized promise through #recorder
|
|
1830
1864
|
|
|
@@ -1839,7 +1873,7 @@ I.seeElement('#modal');
|
|
|
1839
1873
|
|
|
1840
1874
|
#### Parameters
|
|
1841
1875
|
|
|
1842
|
-
- `locator` **([string][
|
|
1876
|
+
- `locator` **([string][9] | [object][6])** located by CSS|XPath|strict locator.
|
|
1843
1877
|
|
|
1844
1878
|
Returns **void** automatically synchronized promise through #recorder
|
|
1845
1879
|
|
|
@@ -1854,7 +1888,7 @@ I.seeElementInDOM('#modal');
|
|
|
1854
1888
|
|
|
1855
1889
|
#### Parameters
|
|
1856
1890
|
|
|
1857
|
-
- `locator` **([string][
|
|
1891
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1858
1892
|
|
|
1859
1893
|
Returns **void** automatically synchronized promise through #recorder
|
|
1860
1894
|
|
|
@@ -1868,7 +1902,7 @@ I.seeInCurrentUrl('/register'); // we are on registration page
|
|
|
1868
1902
|
|
|
1869
1903
|
#### Parameters
|
|
1870
1904
|
|
|
1871
|
-
- `url` **[string][
|
|
1905
|
+
- `url` **[string][9]** a fragment to check
|
|
1872
1906
|
|
|
1873
1907
|
Returns **void** automatically synchronized promise through #recorder
|
|
1874
1908
|
|
|
@@ -1886,8 +1920,8 @@ I.seeInField('#searchform input','Search');
|
|
|
1886
1920
|
|
|
1887
1921
|
#### Parameters
|
|
1888
1922
|
|
|
1889
|
-
- `field` **([string][
|
|
1890
|
-
- `value` **([string][
|
|
1923
|
+
- `field` **([string][9] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
1924
|
+
- `value` **([string][9] | [object][6])** value to check.
|
|
1891
1925
|
|
|
1892
1926
|
Returns **void** automatically synchronized promise through #recorder
|
|
1893
1927
|
|
|
@@ -1902,7 +1936,7 @@ I.seeInPopup('Popup text');
|
|
|
1902
1936
|
|
|
1903
1937
|
#### Parameters
|
|
1904
1938
|
|
|
1905
|
-
- `text` **[string][
|
|
1939
|
+
- `text` **[string][9]** value to check.
|
|
1906
1940
|
|
|
1907
1941
|
Returns **void** automatically synchronized promise through #recorder
|
|
1908
1942
|
|
|
@@ -1916,7 +1950,7 @@ I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
|
1916
1950
|
|
|
1917
1951
|
#### Parameters
|
|
1918
1952
|
|
|
1919
|
-
- `text` **[string][
|
|
1953
|
+
- `text` **[string][9]** value to check.
|
|
1920
1954
|
|
|
1921
1955
|
Returns **void** automatically synchronized promise through #recorder
|
|
1922
1956
|
|
|
@@ -1930,7 +1964,7 @@ I.seeInTitle('Home Page');
|
|
|
1930
1964
|
|
|
1931
1965
|
#### Parameters
|
|
1932
1966
|
|
|
1933
|
-
- `text` **[string][
|
|
1967
|
+
- `text` **[string][9]** text value to check.
|
|
1934
1968
|
|
|
1935
1969
|
Returns **void** automatically synchronized promise through #recorder
|
|
1936
1970
|
|
|
@@ -1945,8 +1979,8 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
1945
1979
|
|
|
1946
1980
|
#### Parameters
|
|
1947
1981
|
|
|
1948
|
-
- `locator` **([string][
|
|
1949
|
-
- `num` **[number][
|
|
1982
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1983
|
+
- `num` **[number][20]** number of elements.
|
|
1950
1984
|
|
|
1951
1985
|
Returns **void** automatically synchronized promise through #recorder
|
|
1952
1986
|
|
|
@@ -1961,8 +1995,8 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1961
1995
|
|
|
1962
1996
|
#### Parameters
|
|
1963
1997
|
|
|
1964
|
-
- `locator` **([string][
|
|
1965
|
-
- `num` **[number][
|
|
1998
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1999
|
+
- `num` **[number][20]** number of elements.
|
|
1966
2000
|
|
|
1967
2001
|
Returns **void** automatically synchronized promise through #recorder
|
|
1968
2002
|
|
|
@@ -1976,8 +2010,8 @@ I.seeTextEquals('text', 'h1');
|
|
|
1976
2010
|
|
|
1977
2011
|
#### Parameters
|
|
1978
2012
|
|
|
1979
|
-
- `text` **[string][
|
|
1980
|
-
- `context` **([string][
|
|
2013
|
+
- `text` **[string][9]** element value to check.
|
|
2014
|
+
- `context` **([string][9] | [object][6])?** element located by CSS|XPath|strict locator.
|
|
1981
2015
|
|
|
1982
2016
|
Returns **void** automatically synchronized promise through #recorder
|
|
1983
2017
|
|
|
@@ -1991,7 +2025,7 @@ I.seeTitleEquals('Test title.');
|
|
|
1991
2025
|
|
|
1992
2026
|
#### Parameters
|
|
1993
2027
|
|
|
1994
|
-
- `text` **[string][
|
|
2028
|
+
- `text` **[string][9]** value to check.
|
|
1995
2029
|
|
|
1996
2030
|
Returns **void** automatically synchronized promise through #recorder
|
|
1997
2031
|
|
|
@@ -2028,14 +2062,14 @@ await I.seeTraffic({
|
|
|
2028
2062
|
|
|
2029
2063
|
#### Parameters
|
|
2030
2064
|
|
|
2031
|
-
- `opts` **[Object][
|
|
2032
|
-
- `opts.name` **[string][
|
|
2033
|
-
- `opts.url` **[string][
|
|
2034
|
-
- `opts.parameters` **[Object][
|
|
2035
|
-
- `opts.requestPostData` **[Object][
|
|
2036
|
-
- `opts.timeout` **[number][
|
|
2065
|
+
- `opts` **[Object][6]** options when checking the traffic network.
|
|
2066
|
+
- `opts.name` **[string][9]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
|
|
2067
|
+
- `opts.url` **[string][9]** Expected URL of request in network traffic
|
|
2068
|
+
- `opts.parameters` **[Object][6]?** Expected parameters of that request in network traffic
|
|
2069
|
+
- `opts.requestPostData` **[Object][6]?** Expected that request contains post data in network traffic
|
|
2070
|
+
- `opts.timeout` **[number][20]?** Timeout to wait for request in seconds. Default is 10 seconds.
|
|
2037
2071
|
|
|
2038
|
-
Returns **[Promise][
|
|
2072
|
+
Returns **[Promise][22]<any>**
|
|
2039
2073
|
|
|
2040
2074
|
### selectOption
|
|
2041
2075
|
|
|
@@ -2060,8 +2094,8 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
2060
2094
|
|
|
2061
2095
|
#### Parameters
|
|
2062
2096
|
|
|
2063
|
-
- `select` **([string][
|
|
2064
|
-
- `option` **([string][
|
|
2097
|
+
- `select` **([string][9] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
2098
|
+
- `option` **([string][9] | [Array][10]<any>)** visible text or value of option.
|
|
2065
2099
|
|
|
2066
2100
|
Returns **void** automatically synchronized promise through #recorder
|
|
2067
2101
|
|
|
@@ -2083,7 +2117,7 @@ I.setCookie([
|
|
|
2083
2117
|
|
|
2084
2118
|
#### Parameters
|
|
2085
2119
|
|
|
2086
|
-
- `cookie` **(Cookie | [Array][
|
|
2120
|
+
- `cookie` **(Cookie | [Array][10]<Cookie>)** a cookie object or array of cookie objects.
|
|
2087
2121
|
|
|
2088
2122
|
Returns **void** automatically synchronized promise through #recorder
|
|
2089
2123
|
|
|
@@ -2099,7 +2133,7 @@ I.setPlaywrightRequestHeaders({
|
|
|
2099
2133
|
|
|
2100
2134
|
#### Parameters
|
|
2101
2135
|
|
|
2102
|
-
- `customHeaders` **[object][
|
|
2136
|
+
- `customHeaders` **[object][6]** headers to set
|
|
2103
2137
|
|
|
2104
2138
|
### startRecordingTraffic
|
|
2105
2139
|
|
|
@@ -2134,8 +2168,8 @@ If no handler is passed, all mock requests for the rote are disabled.
|
|
|
2134
2168
|
|
|
2135
2169
|
#### Parameters
|
|
2136
2170
|
|
|
2137
|
-
- `url` **([string][
|
|
2138
|
-
- `handler` **[function][
|
|
2171
|
+
- `url` **([string][9] | [RegExp][11])?** URL, regex or pattern for to match URL
|
|
2172
|
+
- `handler` **[function][21]?** a function to process reques
|
|
2139
2173
|
|
|
2140
2174
|
### stopRecordingTraffic
|
|
2141
2175
|
|
|
@@ -2164,7 +2198,7 @@ I.switchTo(); // switch back to main page
|
|
|
2164
2198
|
|
|
2165
2199
|
#### Parameters
|
|
2166
2200
|
|
|
2167
|
-
- `locator` **([string][
|
|
2201
|
+
- `locator` **([string][9]? | [object][6])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
2168
2202
|
|
|
2169
2203
|
Returns **void** automatically synchronized promise through #recorder
|
|
2170
2204
|
|
|
@@ -2179,7 +2213,7 @@ I.switchToNextTab(2);
|
|
|
2179
2213
|
|
|
2180
2214
|
#### Parameters
|
|
2181
2215
|
|
|
2182
|
-
- `num` **[number][
|
|
2216
|
+
- `num` **[number][20]**
|
|
2183
2217
|
|
|
2184
2218
|
### switchToPreviousTab
|
|
2185
2219
|
|
|
@@ -2192,13 +2226,13 @@ I.switchToPreviousTab(2);
|
|
|
2192
2226
|
|
|
2193
2227
|
#### Parameters
|
|
2194
2228
|
|
|
2195
|
-
- `num` **[number][
|
|
2229
|
+
- `num` **[number][20]**
|
|
2196
2230
|
|
|
2197
2231
|
### type
|
|
2198
2232
|
|
|
2199
2233
|
Types out the given text into an active field.
|
|
2200
2234
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
2201
|
-
_Note:_ Should be used when [`fillField`][
|
|
2235
|
+
_Note:_ Should be used when [`fillField`][33] is not an option.
|
|
2202
2236
|
|
|
2203
2237
|
```js
|
|
2204
2238
|
// passing in a string
|
|
@@ -2217,8 +2251,8 @@ I.type(secret('123456'));
|
|
|
2217
2251
|
#### Parameters
|
|
2218
2252
|
|
|
2219
2253
|
- `keys`
|
|
2220
|
-
- `delay` **[number][
|
|
2221
|
-
- `key` **([string][
|
|
2254
|
+
- `delay` **[number][20]?** (optional) delay in ms between key presses
|
|
2255
|
+
- `key` **([string][9] | [Array][10]<[string][9]>)** or array of keys to type.
|
|
2222
2256
|
|
|
2223
2257
|
Returns **void** automatically synchronized promise through #recorder
|
|
2224
2258
|
|
|
@@ -2237,11 +2271,11 @@ I.uncheckOption('agree', '//form');
|
|
|
2237
2271
|
|
|
2238
2272
|
#### Parameters
|
|
2239
2273
|
|
|
2240
|
-
- `field` **([string][
|
|
2241
|
-
- `context` **([string][
|
|
2274
|
+
- `field` **([string][9] | [object][6])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
2275
|
+
- `context` **([string][9]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2242
2276
|
- `options`
|
|
2243
2277
|
|
|
2244
|
-
Returns **void** automatically synchronized promise through #recorder[Additional options][
|
|
2278
|
+
Returns **void** automatically synchronized promise through #recorder[Additional options][37] for uncheck available as 3rd argument.Examples:```js
|
|
2245
2279
|
// click on element at position
|
|
2246
2280
|
I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
|
|
2247
2281
|
```> ⚠️ To avoid flakiness, option `force: true` is set by default
|
|
@@ -2253,7 +2287,7 @@ Use Playwright API inside a test.
|
|
|
2253
2287
|
First argument is a description of an action.
|
|
2254
2288
|
Second argument is async function that gets this helper as parameter.
|
|
2255
2289
|
|
|
2256
|
-
{ [`page`][
|
|
2290
|
+
{ [`page`][38], [`browserContext`][39] [`browser`][40] } objects from Playwright API are available.
|
|
2257
2291
|
|
|
2258
2292
|
```js
|
|
2259
2293
|
I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
@@ -2263,8 +2297,8 @@ I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
|
2263
2297
|
|
|
2264
2298
|
#### Parameters
|
|
2265
2299
|
|
|
2266
|
-
- `description` **[string][
|
|
2267
|
-
- `fn` **[function][
|
|
2300
|
+
- `description` **[string][9]** used to show in logs.
|
|
2301
|
+
- `fn` **[function][21]** async function that executed with Playwright helper as argumen
|
|
2268
2302
|
|
|
2269
2303
|
### wait
|
|
2270
2304
|
|
|
@@ -2276,7 +2310,7 @@ I.wait(2); // wait 2 secs
|
|
|
2276
2310
|
|
|
2277
2311
|
#### Parameters
|
|
2278
2312
|
|
|
2279
|
-
- `sec` **[number][
|
|
2313
|
+
- `sec` **[number][20]** number of second to wait.
|
|
2280
2314
|
|
|
2281
2315
|
Returns **void** automatically synchronized promise through #recorder
|
|
2282
2316
|
|
|
@@ -2292,9 +2326,9 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
|
2292
2326
|
|
|
2293
2327
|
#### Parameters
|
|
2294
2328
|
|
|
2295
|
-
- `locator` **([string][
|
|
2329
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2296
2330
|
- `waitTimeout`
|
|
2297
|
-
- `sec` **[number][
|
|
2331
|
+
- `sec` **[number][20]?** (optional, `1` by default) time in seconds to wait
|
|
2298
2332
|
|
|
2299
2333
|
Returns **void** automatically synchronized promise through #recorder
|
|
2300
2334
|
|
|
@@ -2309,8 +2343,8 @@ I.waitForDetached('#popup');
|
|
|
2309
2343
|
|
|
2310
2344
|
#### Parameters
|
|
2311
2345
|
|
|
2312
|
-
- `locator` **([string][
|
|
2313
|
-
- `sec` **[number][
|
|
2346
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2347
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2314
2348
|
|
|
2315
2349
|
Returns **void** automatically synchronized promise through #recorder
|
|
2316
2350
|
|
|
@@ -2326,8 +2360,8 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
2326
2360
|
|
|
2327
2361
|
#### Parameters
|
|
2328
2362
|
|
|
2329
|
-
- `locator` **([string][
|
|
2330
|
-
- `sec` **[number][
|
|
2363
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2364
|
+
- `sec` **[number][20]?** (optional, `1` by default) time in seconds to wait
|
|
2331
2365
|
|
|
2332
2366
|
Returns **void** automatically synchronized promise through #recorder
|
|
2333
2367
|
|
|
@@ -2338,8 +2372,8 @@ Element can be located by CSS or XPath.
|
|
|
2338
2372
|
|
|
2339
2373
|
#### Parameters
|
|
2340
2374
|
|
|
2341
|
-
- `locator` **([string][
|
|
2342
|
-
- `sec` **[number][
|
|
2375
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2376
|
+
- `sec` **[number][20]** (optional) time in seconds to wait, 1 by default.
|
|
2343
2377
|
|
|
2344
2378
|
Returns **void** automatically synchronized promise through #recorder
|
|
2345
2379
|
|
|
@@ -2360,9 +2394,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
2360
2394
|
|
|
2361
2395
|
#### Parameters
|
|
2362
2396
|
|
|
2363
|
-
- `fn` **([string][
|
|
2364
|
-
- `argsOrSec` **([Array][
|
|
2365
|
-
- `sec` **[number][
|
|
2397
|
+
- `fn` **([string][9] | [function][21])** to be executed in browser context.
|
|
2398
|
+
- `argsOrSec` **([Array][10]<any> | [number][20])?** (optional, `1` by default) arguments for function or seconds.
|
|
2399
|
+
- `sec` **[number][20]?** (optional, `1` by default) time in seconds to wait
|
|
2366
2400
|
|
|
2367
2401
|
Returns **void** automatically synchronized promise through #recorder
|
|
2368
2402
|
|
|
@@ -2377,8 +2411,8 @@ I.waitForInvisible('#popup');
|
|
|
2377
2411
|
|
|
2378
2412
|
#### Parameters
|
|
2379
2413
|
|
|
2380
|
-
- `locator` **([string][
|
|
2381
|
-
- `sec` **[number][
|
|
2414
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2415
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2382
2416
|
|
|
2383
2417
|
Returns **void** automatically synchronized promise through #recorder
|
|
2384
2418
|
|
|
@@ -2386,7 +2420,7 @@ Returns **void** automatically synchronized promise through #recorder
|
|
|
2386
2420
|
|
|
2387
2421
|
Waits for navigation to finish. By default, it takes configured `waitForNavigation` option.
|
|
2388
2422
|
|
|
2389
|
-
See [Playwright's reference][
|
|
2423
|
+
See [Playwright's reference][41]
|
|
2390
2424
|
|
|
2391
2425
|
#### Parameters
|
|
2392
2426
|
|
|
@@ -2403,8 +2437,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
2403
2437
|
|
|
2404
2438
|
#### Parameters
|
|
2405
2439
|
|
|
2406
|
-
- `urlOrPredicate` **([string][
|
|
2407
|
-
- `sec` **[number][
|
|
2440
|
+
- `urlOrPredicate` **([string][9] | [function][21])**
|
|
2441
|
+
- `sec` **[number][20]?** seconds to wait
|
|
2408
2442
|
|
|
2409
2443
|
### waitForResponse
|
|
2410
2444
|
|
|
@@ -2417,8 +2451,8 @@ I.waitForResponse(response => response.url() === 'https://example.com' && respon
|
|
|
2417
2451
|
|
|
2418
2452
|
#### Parameters
|
|
2419
2453
|
|
|
2420
|
-
- `urlOrPredicate` **([string][
|
|
2421
|
-
- `sec` **[number][
|
|
2454
|
+
- `urlOrPredicate` **([string][9] | [function][21])**
|
|
2455
|
+
- `sec` **[number][20]?** number of seconds to wait
|
|
2422
2456
|
|
|
2423
2457
|
### waitForText
|
|
2424
2458
|
|
|
@@ -2433,9 +2467,9 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
2433
2467
|
|
|
2434
2468
|
#### Parameters
|
|
2435
2469
|
|
|
2436
|
-
- `text` **[string][
|
|
2437
|
-
- `sec` **[number][
|
|
2438
|
-
- `context` **([string][
|
|
2470
|
+
- `text` **[string][9]** to wait for.
|
|
2471
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2472
|
+
- `context` **([string][9] | [object][6])?** (optional) element located by CSS|XPath|strict locator.
|
|
2439
2473
|
|
|
2440
2474
|
Returns **void** automatically synchronized promise through #recorder
|
|
2441
2475
|
|
|
@@ -2443,11 +2477,11 @@ Returns **void** automatically synchronized promise through #recorder
|
|
|
2443
2477
|
|
|
2444
2478
|
Waits for page navigates to a new URL or reloads. By default, it takes configured `waitForNavigation` option.
|
|
2445
2479
|
|
|
2446
|
-
See [Playwright's reference][
|
|
2480
|
+
See [Playwright's reference][42]
|
|
2447
2481
|
|
|
2448
2482
|
#### Parameters
|
|
2449
2483
|
|
|
2450
|
-
- `url` **([string][
|
|
2484
|
+
- `url` **([string][9] | [RegExp][11])** A glob pattern, regex pattern or predicate receiving URL to match while waiting for the navigation. Note that if the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to the string.
|
|
2451
2485
|
- `options` **any**
|
|
2452
2486
|
|
|
2453
2487
|
### waitForValue
|
|
@@ -2460,9 +2494,9 @@ I.waitForValue('//input', "GoodValue");
|
|
|
2460
2494
|
|
|
2461
2495
|
#### Parameters
|
|
2462
2496
|
|
|
2463
|
-
- `field` **([string][
|
|
2464
|
-
- `value` **[string][
|
|
2465
|
-
- `sec` **[number][
|
|
2497
|
+
- `field` **([string][9] | [object][6])** input field.
|
|
2498
|
+
- `value` **[string][9]** expected value.
|
|
2499
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2466
2500
|
|
|
2467
2501
|
Returns **void** automatically synchronized promise through #recorder
|
|
2468
2502
|
|
|
@@ -2477,10 +2511,10 @@ I.waitForVisible('#popup');
|
|
|
2477
2511
|
|
|
2478
2512
|
#### Parameters
|
|
2479
2513
|
|
|
2480
|
-
- `locator` **([string][
|
|
2481
|
-
- `sec` **[number][
|
|
2514
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2515
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2482
2516
|
|
|
2483
|
-
Returns **void** automatically synchronized promise through #recorderThis method accepts [React selectors][
|
|
2517
|
+
Returns **void** automatically synchronized promise through #recorderThis method accepts [React selectors][43].
|
|
2484
2518
|
|
|
2485
2519
|
### waitInUrl
|
|
2486
2520
|
|
|
@@ -2492,8 +2526,8 @@ I.waitInUrl('/info', 2);
|
|
|
2492
2526
|
|
|
2493
2527
|
#### Parameters
|
|
2494
2528
|
|
|
2495
|
-
- `urlPart` **[string][
|
|
2496
|
-
- `sec` **[number][
|
|
2529
|
+
- `urlPart` **[string][9]** value to check.
|
|
2530
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2497
2531
|
|
|
2498
2532
|
Returns **void** automatically synchronized promise through #recorder
|
|
2499
2533
|
|
|
@@ -2507,9 +2541,9 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
2507
2541
|
|
|
2508
2542
|
#### Parameters
|
|
2509
2543
|
|
|
2510
|
-
- `locator` **([string][
|
|
2511
|
-
- `num` **[number][
|
|
2512
|
-
- `sec` **[number][
|
|
2544
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2545
|
+
- `num` **[number][20]** number of elements.
|
|
2546
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2513
2547
|
|
|
2514
2548
|
Returns **void** automatically synchronized promise through #recorder
|
|
2515
2549
|
|
|
@@ -2524,8 +2558,8 @@ I.waitToHide('#popup');
|
|
|
2524
2558
|
|
|
2525
2559
|
#### Parameters
|
|
2526
2560
|
|
|
2527
|
-
- `locator` **([string][
|
|
2528
|
-
- `sec` **[number][
|
|
2561
|
+
- `locator` **([string][9] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2562
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2529
2563
|
|
|
2530
2564
|
Returns **void** automatically synchronized promise through #recorder
|
|
2531
2565
|
|
|
@@ -2540,8 +2574,8 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2540
2574
|
|
|
2541
2575
|
#### Parameters
|
|
2542
2576
|
|
|
2543
|
-
- `urlPart` **[string][
|
|
2544
|
-
- `sec` **[number][
|
|
2577
|
+
- `urlPart` **[string][9]** value to check.
|
|
2578
|
+
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
|
|
2545
2579
|
|
|
2546
2580
|
Returns **void** automatically synchronized promise through #recorder
|
|
2547
2581
|
|
|
@@ -2549,90 +2583,94 @@ Returns **void** automatically synchronized promise through #recorder
|
|
|
2549
2583
|
|
|
2550
2584
|
[2]: https://playwright.dev/docs/next/api/class-browser#browser-new-context
|
|
2551
2585
|
|
|
2552
|
-
[3]: https://playwright.dev/docs/api/class-
|
|
2586
|
+
[3]: https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har
|
|
2587
|
+
|
|
2588
|
+
[4]: https://playwright.dev/docs/api/class-browsertype#browsertypeconnectparams
|
|
2589
|
+
|
|
2590
|
+
[5]: https://github.com/microsoft/playwright/blob/v0.11.0/docs/api.md#working-with-chrome-extensions
|
|
2553
2591
|
|
|
2554
|
-
[
|
|
2592
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
2555
2593
|
|
|
2556
|
-
[
|
|
2594
|
+
[7]: https://playwright.dev/docs/api/class-browser#browser-new-context
|
|
2557
2595
|
|
|
2558
|
-
[
|
|
2596
|
+
[8]: http://jster.net/category/windows-modals-popups
|
|
2559
2597
|
|
|
2560
|
-
[
|
|
2598
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
2561
2599
|
|
|
2562
|
-
[
|
|
2600
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
2563
2601
|
|
|
2564
|
-
[
|
|
2602
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
2565
2603
|
|
|
2566
|
-
[
|
|
2604
|
+
[12]: https://www.example.com**
|
|
2567
2605
|
|
|
2568
|
-
[
|
|
2606
|
+
[13]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2569
2607
|
|
|
2570
|
-
[
|
|
2608
|
+
[14]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2571
2609
|
|
|
2572
|
-
[
|
|
2610
|
+
[15]: https://playwright.dev/docs/api/class-elementhandle#element-handle-check
|
|
2573
2611
|
|
|
2574
|
-
[
|
|
2612
|
+
[16]: https://playwright.dev/docs/actionability
|
|
2575
2613
|
|
|
2576
|
-
[
|
|
2614
|
+
[17]: https://playwright.dev/docs/api/class-locator#locator-clear
|
|
2577
2615
|
|
|
2578
|
-
[
|
|
2616
|
+
[18]: https://playwright.dev/docs/api/class-page#page-click
|
|
2579
2617
|
|
|
2580
|
-
[
|
|
2618
|
+
[19]: https://playwright.dev/docs/api/class-page#page-drag-and-drop
|
|
2581
2619
|
|
|
2582
|
-
[
|
|
2620
|
+
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2583
2621
|
|
|
2584
|
-
[
|
|
2622
|
+
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
2585
2623
|
|
|
2586
|
-
[
|
|
2624
|
+
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2587
2625
|
|
|
2588
|
-
[
|
|
2626
|
+
[23]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
2589
2627
|
|
|
2590
|
-
[
|
|
2628
|
+
[24]: https://playwright.dev/docs/api/class-consolemessage
|
|
2591
2629
|
|
|
2592
|
-
[
|
|
2630
|
+
[25]: https://playwright.dev/docs/api/class-locator#locator-is-checked
|
|
2593
2631
|
|
|
2594
|
-
[
|
|
2632
|
+
[26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2595
2633
|
|
|
2596
|
-
[
|
|
2634
|
+
[27]: https://playwright.dev/docs/api/class-locator#locator-is-disabled
|
|
2597
2635
|
|
|
2598
|
-
[
|
|
2636
|
+
[28]: https://codecept.io/helpers/FileSystem
|
|
2599
2637
|
|
|
2600
|
-
[
|
|
2638
|
+
[29]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
|
|
2601
2639
|
|
|
2602
|
-
[
|
|
2640
|
+
[30]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
|
|
2603
2641
|
|
|
2604
|
-
[
|
|
2642
|
+
[31]: https://playwright.dev/docs/network#handle-requests
|
|
2605
2643
|
|
|
2606
|
-
[
|
|
2644
|
+
[32]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
|
|
2607
2645
|
|
|
2608
|
-
[
|
|
2646
|
+
[33]: #fillfield
|
|
2609
2647
|
|
|
2610
|
-
[
|
|
2648
|
+
[34]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
2611
2649
|
|
|
2612
|
-
[
|
|
2650
|
+
[35]: #click
|
|
2613
2651
|
|
|
2614
|
-
[
|
|
2652
|
+
[36]: https://playwright.dev/docs/api/class-page#page-route-from-har
|
|
2615
2653
|
|
|
2616
|
-
[
|
|
2654
|
+
[37]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
|
|
2617
2655
|
|
|
2618
|
-
[
|
|
2656
|
+
[38]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
|
|
2619
2657
|
|
|
2620
|
-
[
|
|
2658
|
+
[39]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
|
|
2621
2659
|
|
|
2622
|
-
[
|
|
2660
|
+
[40]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
|
|
2623
2661
|
|
|
2624
|
-
[
|
|
2662
|
+
[41]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
|
|
2625
2663
|
|
|
2626
|
-
[
|
|
2664
|
+
[42]: https://playwright.dev/docs/api/class-page#page-wait-for-url
|
|
2627
2665
|
|
|
2628
|
-
[
|
|
2666
|
+
[43]: https://codecept.io/react
|
|
2629
2667
|
|
|
2630
|
-
[
|
|
2668
|
+
[44]: https://playwright.dev/docs/api/class-browsercontext
|
|
2631
2669
|
|
|
2632
|
-
[
|
|
2670
|
+
[45]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
|
|
2633
2671
|
|
|
2634
|
-
[
|
|
2672
|
+
[46]: https://playwright.dev/docs/trace-viewer
|
|
2635
2673
|
|
|
2636
|
-
[
|
|
2674
|
+
[47]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
|
|
2637
2675
|
|
|
2638
|
-
[
|
|
2676
|
+
[48]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
|