Skip to content

Commit f92666c

Browse files
hatufaccikobenguyent
authored andcommitted
fix comments
1 parent 1fb146c commit f92666c

File tree

3 files changed

+109
-79
lines changed

3 files changed

+109
-79
lines changed

docs/helpers/Playwright.md

Lines changed: 84 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ Type: [object][5]
4141

4242
- `url` **[string][8]?** base url of website to be tested
4343
- `browser` **(`"chromium"` | `"firefox"` | `"webkit"` | `"electron"`)?** a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
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][40] but keeps running browser. Recommended by Playwright team to keep tests isolated.
44+
- `show` **[boolean][25]?** show browser window.
45+
- `restart` **([string][8] | [boolean][25])?** restart strategy between tests. Possible values:- 'context' or **false** - restarts [browser context][42] but keeps running browser. Recommended by Playwright team to keep tests isolated.
4646
- 'browser' or **true** - closes browser and opens it again between tests.
4747
- '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][20]?** - [timeout][41] in ms of all Playwright actions .
49-
- `disableScreenshots` **[boolean][32]?** don't save screenshot on failure.
48+
- `timeout` **[number][20]?** - [timeout][43] in ms of all Playwright actions .
49+
- `disableScreenshots` **[boolean][25]?** don't save screenshot on failure.
5050
- `emulate` **any?** browser in device emulation mode.
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][42] 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'.
51+
- `video` **[boolean][25]?** enables video recording for failed tests; videos are saved into `output/videos` folder
52+
- `keepVideoForPassedTests` **[boolean][25]?** save videos for passed tests; videos are saved into `output/videos` folder
53+
- `trace` **[boolean][25]?** record [tracing information][44] with screenshots and snapshots.
54+
- `keepTraceForPassedTests` **[boolean][25]?** save trace for passed tests.
55+
- `fullPageScreenshots` **[boolean][25]?** make full page screenshots on failure.
56+
- `uniqueScreenshotNames` **[boolean][25]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
57+
- `keepBrowserState` **[boolean][25]?** keep browser state between tests when `restart` is set to 'session'.
58+
- `keepCookies` **[boolean][25]?** keep cookies between tests when `restart` is set to 'session'.
5959
- `waitForAction` **[number][20]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
60-
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][38].
60+
- `waitForNavigation` **(`"load"` | `"domcontentloaded"` | `"commit"`)?** When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `commit`. Choose one of those options is possible. See [Playwright API][40].
6161
- `pressKeyDelay` **[number][20]?** Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
6262
- `getPageTimeout` **[number][20]?** config option to set maximum navigation time in milliseconds.
6363
- `waitForTimeout` **[number][20]?** default wait* timeout in ms. Default: 1000.
@@ -66,15 +66,15 @@ Type: [object][5]
6666
- `colorScheme` **(`"dark"` | `"light"` | `"no-preference"`)?** default color scheme. Possible values: `dark` | `light` | `no-preference`.
6767
- `userAgent` **[string][8]?** user-agent string.
6868
- `locale` **[string][8]?** locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
69-
- `manualStart` **[boolean][32]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
69+
- `manualStart` **[boolean][25]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
7070
- `chromium` **[object][5]?** pass additional chromium options
7171
- `firefox` **[object][5]?** pass additional firefox options
7272
- `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][43].
74-
- `ignoreLog` **[Array][10]<[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. Default: false. Note: only activate under verbose mode (--verbose).
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][45].
74+
- `ignoreLog` **[Array][10]<[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][46].
75+
- `ignoreHTTPSErrors` **[boolean][25]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
76+
- `bypassCSP` **[boolean][25]?** bypass Content Security Policy or CSP
77+
- `highlightElement` **[boolean][25]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
7878

7979

8080

@@ -991,6 +991,18 @@ console.log(JSON.stringify(errors));
991991

992992
Returns **[Promise][9]<[Array][10]<any>>**
993993

994+
### grabCheckedElementStatus
995+
996+
{{> grabCheckedElementStatus }}
997+
998+
#### Parameters
999+
1000+
- `locator`
1001+
- `options`
1002+
- `See` **[object][5]** [https://playwright.dev/docs/api/class-locator#locator-is-checked][24]
1003+
1004+
Returns **[Promise][9]<[boolean][25]>**
1005+
9941006
### grabCookie
9951007

9961008
Gets a cookie object by name.
@@ -1078,6 +1090,18 @@ let data = await I.grabDataFromPerformanceTiming();
10781090

10791091
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder
10801092

1093+
### grabDisabledElementStatus
1094+
1095+
{{> grabDisabledElementStatus }}
1096+
1097+
#### Parameters
1098+
1099+
- `locator`
1100+
- `options`
1101+
- `See` **[object][5]** [https://playwright.dev/docs/api/class-locator#locator-is-disabled][26]
1102+
1103+
Returns **[Promise][9]<[boolean][25]>**
1104+
10811105
### grabElementBoundingRect
10821106

10831107
Grab the width, height, location of given locator.
@@ -1362,7 +1386,7 @@ Returns **[Array][10]<any>**
13621386
Handles a file download. A file name is required to save the file on disk.
13631387
Files are saved to "output" directory.
13641388

1365-
Should be used with [FileSystem helper][24] to check that file were downloaded correctly.
1389+
Should be used with [FileSystem helper][27] to check that file were downloaded correctly.
13661390

13671391
```js
13681392
I.handleDownloads('downloads/avatar.jpg');
@@ -1379,7 +1403,7 @@ Returns **[Promise][9]<void>**
13791403

13801404
### makeApiRequest
13811405

1382-
Performs [api request][25] using
1406+
Performs [api request][28] using
13831407
the cookies from the current browser session.
13841408

13851409
```js
@@ -1400,13 +1424,13 @@ Returns **[Promise][9]<[object][5]>** response
14001424

14011425
### mockRoute
14021426

1403-
Mocks network request using [`browserContext.route`][26] of Playwright
1427+
Mocks network request using [`browserContext.route`][29] of Playwright
14041428

14051429
```js
14061430
I.mockRoute(/(.png$)|(.jpg$)/, route => route.abort());
14071431
```
14081432

1409-
This method allows intercepting and mocking requests & responses. [Learn more about it][27]
1433+
This method allows intercepting and mocking requests & responses. [Learn more about it][30]
14101434

14111435
#### Parameters
14121436

@@ -1458,7 +1482,7 @@ Open new tab and automatically switched to new tab
14581482
I.openNewTab();
14591483
```
14601484

1461-
You can pass in [page options][28] to emulate device on this page
1485+
You can pass in [page options][31] to emulate device on this page
14621486

14631487
```js
14641488
// enable mobile
@@ -1473,7 +1497,7 @@ I.openNewTab({ isMobile: true });
14731497

14741498
Presses a key in the browser (on a focused element).
14751499

1476-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][29].
1500+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][32].
14771501

14781502
```js
14791503
I.pressKey('Backspace');
@@ -1534,13 +1558,13 @@ Some of the supported key names are:
15341558

15351559
- `key` **([string][8] | [Array][10]<[string][8]>)** key or array of keys to press.
15361560

1537-
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][30]).
1561+
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][33]).
15381562

15391563
### pressKeyDown
15401564

15411565
Presses a key in the browser and leaves it in a down state.
15421566

1543-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1567+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][34]).
15441568

15451569
```js
15461570
I.pressKeyDown('Control');
@@ -1558,7 +1582,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
15581582

15591583
Releases a key in the browser which was previously set to a down state.
15601584

1561-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1585+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][34]).
15621586

15631587
```js
15641588
I.pressKeyDown('Control');
@@ -1667,7 +1691,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
16671691
#### Parameters
16681692

16691693
- `fileName` **[string][8]** file name to save.
1670-
- `fullPage` **[boolean][32]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
1694+
- `fullPage` **[boolean][25]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
16711695

16721696
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder
16731697

@@ -2174,7 +2198,7 @@ I.switchToPreviousTab(2);
21742198

21752199
Types out the given text into an active field.
21762200
To slow down typing use a second parameter, to set interval between key presses.
2177-
_Note:_ Should be used when [`fillField`][29] is not an option.
2201+
_Note:_ Should be used when [`fillField`][32] is not an option.
21782202

21792203
```js
21802204
// passing in a string
@@ -2217,7 +2241,7 @@ I.uncheckOption('agree', '//form');
22172241
- `context` **([string][8]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
22182242
- `options`
22192243

2220-
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder[Additional options][33] for uncheck available as 3rd argument.Examples:```js
2244+
Returns **[Promise][9]<void>** automatically synchronized promise through #recorder[Additional options][35] for uncheck available as 3rd argument.Examples:```js
22212245
// click on element at position
22222246
I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
22232247
```> ⚠️ To avoid flakiness, option `force: true` is set by default
@@ -2229,7 +2253,7 @@ Use Playwright API inside a test.
22292253
First argument is a description of an action.
22302254
Second argument is async function that gets this helper as parameter.
22312255

2232-
{ [`page`][34], [`browserContext`][35] [`browser`][36] } objects from Playwright API are available.
2256+
{ [`page`][36], [`browserContext`][37] [`browser`][38] } objects from Playwright API are available.
22332257

22342258
```js
22352259
I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
@@ -2362,7 +2386,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
23622386

23632387
Waits for navigation to finish. By default, it takes configured `waitForNavigation` option.
23642388

2365-
See [Playwright's reference][37]
2389+
See [Playwright's reference][39]
23662390

23672391
#### Parameters
23682392

@@ -2419,7 +2443,7 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
24192443

24202444
Waits for page navigates to a new URL or reloads. By default, it takes configured `waitForNavigation` option.
24212445

2422-
See [Playwright's reference][38]
2446+
See [Playwright's reference][40]
24232447

24242448
#### Parameters
24252449

@@ -2456,7 +2480,7 @@ I.waitForVisible('#popup');
24562480
- `locator` **([string][8] | [object][5])** element located by CSS|XPath|strict locator.
24572481
- `sec` **[number][20]** (optional, `1` by default) time in seconds to wait
24582482

2459-
Returns **[Promise][9]<void>** automatically synchronized promise through #recorderThis method accepts [React selectors][39].
2483+
Returns **[Promise][9]<void>** automatically synchronized promise through #recorderThis method accepts [React selectors][41].
24602484

24612485
### waitInUrl
24622486

@@ -2567,44 +2591,48 @@ Returns **[Promise][9]<void>** automatically synchronized promise through #re
25672591

25682592
[23]: https://playwright.dev/docs/api/class-consolemessage
25692593

2570-
[24]: https://codecept.io/helpers/FileSystem
2594+
[24]: https://playwright.dev/docs/api/class-locator#locator-is-checked
2595+
2596+
[25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
2597+
2598+
[26]: https://playwright.dev/docs/api/class-locator#locator-is-disabled
25712599

2572-
[25]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
2600+
[27]: https://codecept.io/helpers/FileSystem
25732601

2574-
[26]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
2602+
[28]: https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get
25752603

2576-
[27]: https://playwright.dev/docs/network#handle-requests
2604+
[29]: https://playwright.dev/docs/api/class-browsercontext#browser-context-route
25772605

2578-
[28]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
2606+
[30]: https://playwright.dev/docs/network#handle-requests
25792607

2580-
[29]: #fillfield
2608+
[31]: https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions
25812609

2582-
[30]: https://github.com/GoogleChrome/puppeteer/issues/1313
2610+
[32]: #fillfield
25832611

2584-
[31]: #click
2612+
[33]: https://github.com/GoogleChrome/puppeteer/issues/1313
25852613

2586-
[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
2614+
[34]: #click
25872615

2588-
[33]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
2616+
[35]: https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck
25892617

2590-
[34]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
2618+
[36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md
25912619

2592-
[35]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
2620+
[37]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md
25932621

2594-
[36]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
2622+
[38]: https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md
25952623

2596-
[37]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
2624+
[39]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
25972625

2598-
[38]: https://playwright.dev/docs/api/class-page#page-wait-for-url
2626+
[40]: https://playwright.dev/docs/api/class-page#page-wait-for-url
25992627

2600-
[39]: https://codecept.io/react
2628+
[41]: https://codecept.io/react
26012629

2602-
[40]: https://playwright.dev/docs/api/class-browsercontext
2630+
[42]: https://playwright.dev/docs/api/class-browsercontext
26032631

2604-
[41]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
2632+
[43]: https://playwright.dev/docs/api/class-page#page-set-default-timeout
26052633

2606-
[42]: https://playwright.dev/docs/trace-viewer
2634+
[44]: https://playwright.dev/docs/trace-viewer
26072635

2608-
[43]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
2636+
[45]: https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge
26092637

2610-
[44]: https://playwright.dev/docs/api/class-consolemessage#console-message-type
2638+
[46]: https://playwright.dev/docs/api/class-consolemessage#console-message-type

lib/helper/Playwright.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,13 +994,13 @@ class Playwright extends Helper {
994994
return this._waitForAction();
995995
}
996996
/**
997-
* {{> isElementChecked }}
997+
* {{> grabCheckedElementStatus }}
998998
* @param {object} See https://playwright.dev/docs/api/class-locator#locator-is-checked
999999
* @return {Promise<boolean>}
10001000
*
10011001
*/
10021002

1003-
async isElementChecked(locator, options = {}) {
1003+
async grabCheckedElementStatus(locator, options = {}) {
10041004
const el = await this._locateElement(locator);
10051005
const type = await el.getAttribute('type');
10061006

@@ -1010,13 +1010,13 @@ class Playwright extends Helper {
10101010
throw new Error('Element is not a checkbox or radio input');
10111011
}
10121012
/**
1013-
* {{> isElementDisabled }}
1013+
* {{> grabDisabledElementStatus }}
10141014
* @param {object} See https://playwright.dev/docs/api/class-locator#locator-is-disabled
10151015
* @return {Promise<boolean>}
10161016
*
10171017
*/
10181018

1019-
async isElementDisabled(locator, options = {}) {
1019+
async grabDisabledElementStatus(locator, options = {}) {
10201020
const el = await this._locateElement(locator);
10211021
return el.isDisabled(options);
10221022
}

test/helper/Playwright_test.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,30 @@ describe('Playwright', function () {
117117
await I.click('Hello World');
118118
});
119119
});
120-
it('check isElementChecked', async () => {
121-
await I.amOnPage('/invisible_elements');
122-
let result = await I.isElementChecked({ id: 'html' });
123-
assert.equal(result, true);
124-
result = await I.isElementChecked({ id: 'css' });
125-
assert.equal(result, false);
126-
result = await I.isElementChecked({ id: 'js' });
127-
assert.equal(result, true);
128-
result = await I.isElementChecked({ id: 'ts' });
129-
assert.equal(result, false);
130-
try {
131-
result = await I.isElementChecked({ id: 'basic' });
132-
} catch (e) {
133-
assert.equal(e.message, 'Element is not a checkbox or radio input');
134-
}
135-
});
136-
describe('#isElementDisabled', () => {
120+
describe('#grabCheckedElementStatus', () => {
121+
it('check grabCheckedElementStatus', async () => {
122+
await I.amOnPage('/invisible_elements');
123+
let result = await I.grabCheckedElementStatus({ id: 'html' });
124+
assert.equal(result, true);
125+
result = await I.grabCheckedElementStatus({ id: 'css' });
126+
assert.equal(result, false);
127+
result = await I.grabCheckedElementStatus({ id: 'js' });
128+
assert.equal(result, true);
129+
result = await I.grabCheckedElementStatus({ id: 'ts' });
130+
assert.equal(result, false);
131+
try {
132+
result = await I.grabCheckedElementStatus({ id: 'basic' });
133+
} catch (e) {
134+
assert.equal(e.message, 'Element is not a checkbox or radio input');
135+
}
136+
});
137+
});
138+
describe('#grabDisabledElementStatus', () => {
137139
it('check isElementDisabled', async () => {
138140
await I.amOnPage('/invisible_elements');
139-
let result = await I.isElementDisabled({ id: 'fortran' });
141+
let result = await I.grabDisabledElementStatus({ id: 'fortran' });
140142
assert.equal(result, true);
141-
result = await I.isElementDisabled({ id: 'basic' });
143+
result = await I.grabDisabledElementStatus({ id: 'basic' });
142144
assert.equal(result, false);
143145
});
144146
});

0 commit comments

Comments
 (0)