codeceptjs 2.4.3 → 2.6.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/CHANGELOG.md +117 -0
- package/README.md +32 -7
- package/bin/codecept.js +3 -0
- package/docs/basics.md +11 -5
- package/docs/bdd.md +4 -4
- package/docs/build/MockRequest.js +3 -0
- package/docs/build/Nightmare.js +10 -2
- package/docs/build/Playwright.js +3187 -0
- package/docs/build/Protractor.js +16 -2
- package/docs/build/Puppeteer.js +126 -19
- package/docs/build/REST.js +3 -1
- package/docs/build/TestCafe.js +11 -3
- package/docs/build/WebDriver.js +361 -28
- package/docs/changelog.md +116 -0
- package/docs/configuration.md +2 -2
- package/docs/custom-helpers.md +55 -10
- package/docs/helpers/Appium.md +81 -1
- package/docs/helpers/MockRequest.md +281 -38
- package/docs/helpers/Nightmare.md +10 -2
- package/docs/helpers/Playwright.md +1770 -0
- package/docs/helpers/Protractor.md +15 -3
- package/docs/helpers/Puppeteer-firefox.md +32 -1
- package/docs/helpers/Puppeteer.md +126 -76
- package/docs/helpers/TestCafe.md +10 -2
- package/docs/helpers/WebDriver.md +208 -118
- package/docs/locators.md +2 -0
- package/docs/playwright.md +306 -0
- package/docs/plugins.md +103 -0
- package/docs/reports.md +12 -0
- package/docs/shadow.md +68 -0
- package/docs/visual.md +0 -73
- package/docs/webapi/forceClick.mustache +27 -0
- package/docs/webapi/seeInPopup.mustache +7 -0
- package/docs/webapi/setCookie.mustache +10 -2
- package/docs/webapi/type.mustache +12 -0
- package/docs/webdriver.md +7 -3
- package/lib/codecept.js +1 -1
- package/lib/command/definitions.js +2 -2
- package/lib/command/generate.js +4 -4
- package/lib/command/gherkin/snippets.js +4 -4
- package/lib/command/init.js +1 -1
- package/lib/command/interactive.js +3 -0
- package/lib/command/run-multiple.js +2 -2
- package/lib/command/run-rerun.js +2 -0
- package/lib/command/run-workers.js +22 -8
- package/lib/command/run.js +2 -0
- package/lib/command/workers/runTests.js +1 -0
- package/lib/container.js +1 -1
- package/lib/event.js +2 -0
- package/lib/helper/MockRequest.js +3 -0
- package/lib/helper/Playwright.js +2422 -0
- package/lib/helper/Protractor.js +1 -2
- package/lib/helper/Puppeteer.js +84 -19
- package/lib/helper/REST.js +3 -1
- package/lib/helper/TestCafe.js +1 -1
- package/lib/helper/WebDriver.js +313 -26
- package/lib/helper/extras/PlaywrightPropEngine.js +53 -0
- package/lib/helper/scripts/isElementClickable.js +54 -14
- package/lib/interfaces/gherkin.js +1 -1
- package/lib/listener/helpers.js +3 -0
- package/lib/locator.js +5 -0
- package/lib/mochaFactory.js +12 -10
- package/lib/plugin/allure.js +8 -1
- package/lib/plugin/autoDelay.js +1 -8
- package/lib/plugin/commentStep.js +133 -0
- package/lib/plugin/screenshotOnFail.js +3 -10
- package/lib/plugin/selenoid.js +2 -2
- package/lib/plugin/standardActingHelpers.js +13 -0
- package/lib/plugin/stepByStepReport.js +1 -8
- package/lib/plugin/wdio.js +10 -1
- package/lib/reporter/cli.js +30 -1
- package/lib/session.js +7 -4
- package/package.json +13 -10
- package/typings/Mocha.d.ts +567 -16
- package/typings/index.d.ts +9 -5
- package/typings/types.d.ts +1634 -74
|
@@ -0,0 +1,1770 @@
|
|
|
1
|
+
---
|
|
2
|
+
permalink: /helpers/Playwright
|
|
3
|
+
editLink: false
|
|
4
|
+
sidebar: auto
|
|
5
|
+
title: Playwright
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
9
|
+
|
|
10
|
+
## Playwright
|
|
11
|
+
|
|
12
|
+
**Extends Helper**
|
|
13
|
+
|
|
14
|
+
Uses [Playwright][1] library to run tests inside:
|
|
15
|
+
|
|
16
|
+
- Chromium
|
|
17
|
+
- Firefox
|
|
18
|
+
- Webkit (Safari)
|
|
19
|
+
|
|
20
|
+
This helper works with a browser out of the box with no additional tools required to install.
|
|
21
|
+
|
|
22
|
+
Requires `playwright` package version ^0.12.1 to be installed:
|
|
23
|
+
|
|
24
|
+
npm i playwright@^0.12.1 --save
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
This helper should be configured in codecept.json or codecept.conf.js
|
|
29
|
+
|
|
30
|
+
- `url`: base url of website to be tested
|
|
31
|
+
- `browser`: a browser to test on, either: `chromium`, `firefox`, `webkit`. Default: chromium.
|
|
32
|
+
- `show`: - show browser window.
|
|
33
|
+
- `restart`: - restart browser between tests.
|
|
34
|
+
- `disableScreenshots`: - don't save screenshot on failure.
|
|
35
|
+
- `emulate`: launch browser in device emulation mode.
|
|
36
|
+
- `fullPageScreenshots` - make full page screenshots on failure.
|
|
37
|
+
- `uniqueScreenshotNames`: - option to prevent screenshot override if you have scenarios with the same name in different suites.
|
|
38
|
+
- `keepBrowserState`: - keep browser state between tests when `restart` is set to false.
|
|
39
|
+
- `keepCookies`: - keep cookies between tests when `restart` is set to false.
|
|
40
|
+
- `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
41
|
+
- `waitForNavigation`: . When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. Choose one of those options is possible. See [Playwright API][2].
|
|
42
|
+
- `pressKeyDelay`: . Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
|
|
43
|
+
- `getPageTimeout` config option to set maximum navigation time in milliseconds.
|
|
44
|
+
- `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
|
|
45
|
+
- `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
46
|
+
- `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
47
|
+
- `userAgent`: (optional) user-agent string.
|
|
48
|
+
- `manualStart`: - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
49
|
+
- `chromium`: (optional) pass additional chromium options
|
|
50
|
+
|
|
51
|
+
#### Example #1: Wait for 0 network connections.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
{
|
|
55
|
+
helpers: {
|
|
56
|
+
Playwright : {
|
|
57
|
+
url: "http://localhost",
|
|
58
|
+
restart: false,
|
|
59
|
+
waitForNavigation: "networkidle0",
|
|
60
|
+
waitForAction: 500
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Example #2: Wait for DOMContentLoaded event
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
{
|
|
70
|
+
helpers: {
|
|
71
|
+
Playwright : {
|
|
72
|
+
url: "http://localhost",
|
|
73
|
+
restart: false,
|
|
74
|
+
waitForNavigation: "domcontentloaded",
|
|
75
|
+
waitForAction: 500
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Example #3: Debug in window mode
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
{
|
|
85
|
+
helpers: {
|
|
86
|
+
Playwright : {
|
|
87
|
+
url: "http://localhost",
|
|
88
|
+
show: true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Example #4: Connect to remote browser by specifying [websocket endpoint][3]
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
{
|
|
98
|
+
helpers: {
|
|
99
|
+
Playwright: {
|
|
100
|
+
url: "http://localhost",
|
|
101
|
+
chromium: {
|
|
102
|
+
browserWSEndpoint: "ws://localhost:9222/devtools/browser/c5aa6160-b5bc-4d53-bb49-6ecb36cd2e0a"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Example #5: Testing with Chromium extensions
|
|
110
|
+
|
|
111
|
+
[official docs][4]
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
{
|
|
115
|
+
helpers: {
|
|
116
|
+
Playwright: {
|
|
117
|
+
url: "http://localhost",
|
|
118
|
+
show: true // headless mode not supported for extensions
|
|
119
|
+
chromium: {
|
|
120
|
+
args: [
|
|
121
|
+
`--disable-extensions-except=${pathToExtension}`,
|
|
122
|
+
`--load-extension=${pathToExtension}`
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Example #6: Lunach tests emulating iPhone 6
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const { devices } = require('playwright');
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
helpers: {
|
|
137
|
+
Playwright: {
|
|
138
|
+
url: "http://localhost",
|
|
139
|
+
emulate: devices['iPhone 6'],
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
146
|
+
|
|
147
|
+
## Access From Helpers
|
|
148
|
+
|
|
149
|
+
Receive Playwright client from a custom helper by accessing `browser` for the Browser object or `page` for the current Page object:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
const { browser } = this.helpers.Playwright;
|
|
153
|
+
await browser.pages(); // List of pages in the browser
|
|
154
|
+
|
|
155
|
+
// get current page
|
|
156
|
+
const { page } = this.helpers.Playwright;
|
|
157
|
+
await page.url(); // Get the url of the current page
|
|
158
|
+
|
|
159
|
+
const { browserContext } = this.helpers.Playwright;
|
|
160
|
+
await browserContext.cookies(); // get current browser context
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Methods
|
|
164
|
+
|
|
165
|
+
### Parameters
|
|
166
|
+
|
|
167
|
+
- `config`
|
|
168
|
+
|
|
169
|
+
### _addPopupListener
|
|
170
|
+
|
|
171
|
+
Add the 'dialog' event listener to a page
|
|
172
|
+
|
|
173
|
+
#### Parameters
|
|
174
|
+
|
|
175
|
+
- `page`
|
|
176
|
+
|
|
177
|
+
### _getPageUrl
|
|
178
|
+
|
|
179
|
+
Gets page URL including hash.
|
|
180
|
+
|
|
181
|
+
### _locate
|
|
182
|
+
|
|
183
|
+
Get elements by different locator types, including strict locator
|
|
184
|
+
Should be used in custom helpers:
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
const elements = await this.helpers['Playwright']._locate({name: 'password'});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Parameters
|
|
191
|
+
|
|
192
|
+
- `locator`
|
|
193
|
+
|
|
194
|
+
### _locateCheckable
|
|
195
|
+
|
|
196
|
+
Find a checkbox by providing human readable text:
|
|
197
|
+
NOTE: Assumes the checkable element exists
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
this.helpers['Playwright']._locateCheckable('I agree with terms and conditions').then // ...
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Parameters
|
|
204
|
+
|
|
205
|
+
- `locator`
|
|
206
|
+
- `providedContext`
|
|
207
|
+
|
|
208
|
+
### _locateClickable
|
|
209
|
+
|
|
210
|
+
Find a clickable element by providing human readable text:
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
this.helpers['Playwright']._locateClickable('Next page').then // ...
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Parameters
|
|
217
|
+
|
|
218
|
+
- `locator`
|
|
219
|
+
|
|
220
|
+
### _locateFields
|
|
221
|
+
|
|
222
|
+
Find field elements by providing human readable text:
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
this.helpers['Playwright']._locateFields('Your email').then // ...
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Parameters
|
|
229
|
+
|
|
230
|
+
- `locator`
|
|
231
|
+
|
|
232
|
+
### _setPage
|
|
233
|
+
|
|
234
|
+
Set current page
|
|
235
|
+
|
|
236
|
+
#### Parameters
|
|
237
|
+
|
|
238
|
+
- `page` **[object][5]** page to set
|
|
239
|
+
|
|
240
|
+
### acceptPopup
|
|
241
|
+
|
|
242
|
+
Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
|
|
243
|
+
Don't confuse popups with modal windows, as created by [various
|
|
244
|
+
libraries][6].
|
|
245
|
+
|
|
246
|
+
### amAcceptingPopups
|
|
247
|
+
|
|
248
|
+
Set the automatic popup response to Accept.
|
|
249
|
+
This must be set before a popup is triggered.
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
I.amAcceptingPopups();
|
|
253
|
+
I.click('#triggerPopup');
|
|
254
|
+
I.acceptPopup();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### amCancellingPopups
|
|
258
|
+
|
|
259
|
+
Set the automatic popup response to Cancel/Dismiss.
|
|
260
|
+
This must be set before a popup is triggered.
|
|
261
|
+
|
|
262
|
+
```js
|
|
263
|
+
I.amCancellingPopups();
|
|
264
|
+
I.click('#triggerPopup');
|
|
265
|
+
I.cancelPopup();
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### amOnPage
|
|
269
|
+
|
|
270
|
+
Opens a web page in a browser. Requires relative or absolute url.
|
|
271
|
+
If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
I.amOnPage('/'); // opens main page of website
|
|
275
|
+
I.amOnPage('https://github.com'); // opens github
|
|
276
|
+
I.amOnPage('/login'); // opens a login page
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### Parameters
|
|
280
|
+
|
|
281
|
+
- `url` **[string][7]** url path or global url.
|
|
282
|
+
|
|
283
|
+
### appendField
|
|
284
|
+
|
|
285
|
+
Appends text to a input field or textarea.
|
|
286
|
+
Field is located by name, label, CSS or XPath
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
I.appendField('#myTextField', 'appended');
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### Parameters
|
|
293
|
+
|
|
294
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator
|
|
295
|
+
- `value` **[string][7]** text value to append.
|
|
296
|
+
|
|
297
|
+
### attachFile
|
|
298
|
+
|
|
299
|
+
Attaches a file to element located by label, name, CSS or XPath
|
|
300
|
+
Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
|
|
301
|
+
File will be uploaded to remote system (if tests are running remotely).
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
I.attachFile('Avatar', 'data/avatar.jpg');
|
|
305
|
+
I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### Parameters
|
|
309
|
+
|
|
310
|
+
- `locator` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
311
|
+
- `pathToFile` **[string][7]** local file path relative to codecept.json config file.
|
|
312
|
+
|
|
313
|
+
### cancelPopup
|
|
314
|
+
|
|
315
|
+
Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
|
|
316
|
+
|
|
317
|
+
### checkOption
|
|
318
|
+
|
|
319
|
+
Selects a checkbox or radio button.
|
|
320
|
+
Element is located by label or name or CSS or XPath.
|
|
321
|
+
|
|
322
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
I.checkOption('#agree');
|
|
326
|
+
I.checkOption('I Agree to Terms and Conditions');
|
|
327
|
+
I.checkOption('agree', '//form');
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
#### Parameters
|
|
331
|
+
|
|
332
|
+
- `field` **([string][7] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
333
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
334
|
+
|
|
335
|
+
### clearCookie
|
|
336
|
+
|
|
337
|
+
Clears a cookie by name,
|
|
338
|
+
if none provided clears all cookies.
|
|
339
|
+
|
|
340
|
+
```js
|
|
341
|
+
I.clearCookie();
|
|
342
|
+
I.clearCookie('test');
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### Parameters
|
|
346
|
+
|
|
347
|
+
- `cookie` **[string][7]?** (optional, `null` by default) cookie name
|
|
348
|
+
|
|
349
|
+
### clearField
|
|
350
|
+
|
|
351
|
+
Clears a `<textarea>` or text `<input>` element's value.
|
|
352
|
+
|
|
353
|
+
```js
|
|
354
|
+
I.clearField('Email');
|
|
355
|
+
I.clearField('user[email]');
|
|
356
|
+
I.clearField('#email');
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### Parameters
|
|
360
|
+
|
|
361
|
+
- `field`
|
|
362
|
+
- `editable` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
363
|
+
|
|
364
|
+
### click
|
|
365
|
+
|
|
366
|
+
Perform a click on a link or a button, given by a locator.
|
|
367
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
368
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
369
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
370
|
+
|
|
371
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
372
|
+
|
|
373
|
+
```js
|
|
374
|
+
// simple link
|
|
375
|
+
I.click('Logout');
|
|
376
|
+
// button of form
|
|
377
|
+
I.click('Submit');
|
|
378
|
+
// CSS button
|
|
379
|
+
I.click('#form input[type=submit]');
|
|
380
|
+
// XPath
|
|
381
|
+
I.click('//form/*[@type=submit]');
|
|
382
|
+
// link in context
|
|
383
|
+
I.click('Logout', '#nav');
|
|
384
|
+
// using strict locator
|
|
385
|
+
I.click({css: 'nav a.login'});
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### Parameters
|
|
389
|
+
|
|
390
|
+
- `locator` **([string][7] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
391
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
392
|
+
|
|
393
|
+
### clickLink
|
|
394
|
+
|
|
395
|
+
Clicks link and waits for navigation (deprecated)
|
|
396
|
+
|
|
397
|
+
#### Parameters
|
|
398
|
+
|
|
399
|
+
- `locator`
|
|
400
|
+
- `context`
|
|
401
|
+
|
|
402
|
+
### closeCurrentTab
|
|
403
|
+
|
|
404
|
+
Close current tab and switches to previous.
|
|
405
|
+
|
|
406
|
+
```js
|
|
407
|
+
I.closeCurrentTab();
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### closeOtherTabs
|
|
411
|
+
|
|
412
|
+
Close all tabs except for the current one.
|
|
413
|
+
|
|
414
|
+
```js
|
|
415
|
+
I.closeOtherTabs();
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### dontSee
|
|
419
|
+
|
|
420
|
+
Opposite to `see`. Checks that a text is not present on a page.
|
|
421
|
+
Use context parameter to narrow down the search.
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
I.dontSee('Login'); // assume we are already logged in.
|
|
425
|
+
I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### Parameters
|
|
429
|
+
|
|
430
|
+
- `text` **[string][7]** which is not present.
|
|
431
|
+
- `context` **([string][7] | [object][5])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
432
|
+
|
|
433
|
+
### dontSeeCheckboxIsChecked
|
|
434
|
+
|
|
435
|
+
Verifies that the specified checkbox is not checked.
|
|
436
|
+
|
|
437
|
+
```js
|
|
438
|
+
I.dontSeeCheckboxIsChecked('#agree'); // located by ID
|
|
439
|
+
I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
440
|
+
I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### Parameters
|
|
444
|
+
|
|
445
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
446
|
+
|
|
447
|
+
### dontSeeCookie
|
|
448
|
+
|
|
449
|
+
Checks that cookie with given name does not exist.
|
|
450
|
+
|
|
451
|
+
```js
|
|
452
|
+
I.dontSeeCookie('auth'); // no auth cookie
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
#### Parameters
|
|
456
|
+
|
|
457
|
+
- `name` **[string][7]** cookie name.
|
|
458
|
+
|
|
459
|
+
### dontSeeCurrentUrlEquals
|
|
460
|
+
|
|
461
|
+
Checks that current url is not equal to provided one.
|
|
462
|
+
If a relative url provided, a configured url will be prepended to it.
|
|
463
|
+
|
|
464
|
+
```js
|
|
465
|
+
I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
|
|
466
|
+
I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### Parameters
|
|
470
|
+
|
|
471
|
+
- `url` **[string][7]** value to check.
|
|
472
|
+
|
|
473
|
+
### dontSeeElement
|
|
474
|
+
|
|
475
|
+
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
476
|
+
|
|
477
|
+
```js
|
|
478
|
+
I.dontSeeElement('.modal'); // modal is not shown
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
#### Parameters
|
|
482
|
+
|
|
483
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|Strict locator.
|
|
484
|
+
|
|
485
|
+
### dontSeeElementInDOM
|
|
486
|
+
|
|
487
|
+
Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
488
|
+
|
|
489
|
+
```js
|
|
490
|
+
I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
#### Parameters
|
|
494
|
+
|
|
495
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|Strict locator.
|
|
496
|
+
|
|
497
|
+
### dontSeeInCurrentUrl
|
|
498
|
+
|
|
499
|
+
Checks that current url does not contain a provided fragment.
|
|
500
|
+
|
|
501
|
+
#### Parameters
|
|
502
|
+
|
|
503
|
+
- `url` **[string][7]** value to check.
|
|
504
|
+
|
|
505
|
+
### dontSeeInField
|
|
506
|
+
|
|
507
|
+
Checks that value of input field or textarea doesn't equal to given value
|
|
508
|
+
Opposite to `seeInField`.
|
|
509
|
+
|
|
510
|
+
```js
|
|
511
|
+
I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
512
|
+
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
#### Parameters
|
|
516
|
+
|
|
517
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
518
|
+
- `value` **[string][7]** value to check.
|
|
519
|
+
|
|
520
|
+
### dontSeeInSource
|
|
521
|
+
|
|
522
|
+
Checks that the current page does not contains the given string in its raw source code.
|
|
523
|
+
|
|
524
|
+
```js
|
|
525
|
+
I.dontSeeInSource('<!--'); // no comments in source
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
#### Parameters
|
|
529
|
+
|
|
530
|
+
- `text`
|
|
531
|
+
- `value` **[string][7]** to check.
|
|
532
|
+
|
|
533
|
+
### dontSeeInTitle
|
|
534
|
+
|
|
535
|
+
Checks that title does not contain text.
|
|
536
|
+
|
|
537
|
+
```js
|
|
538
|
+
I.dontSeeInTitle('Error');
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
#### Parameters
|
|
542
|
+
|
|
543
|
+
- `text` **[string][7]** value to check.
|
|
544
|
+
|
|
545
|
+
### doubleClick
|
|
546
|
+
|
|
547
|
+
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
548
|
+
Context can be specified as second parameter to narrow search.
|
|
549
|
+
|
|
550
|
+
```js
|
|
551
|
+
I.doubleClick('Edit');
|
|
552
|
+
I.doubleClick('Edit', '.actions');
|
|
553
|
+
I.doubleClick({css: 'button.accept'});
|
|
554
|
+
I.doubleClick('.btn.edit');
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
#### Parameters
|
|
558
|
+
|
|
559
|
+
- `locator` **([string][7] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
560
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
561
|
+
|
|
562
|
+
### dragAndDrop
|
|
563
|
+
|
|
564
|
+
Drag an item to a destination element.
|
|
565
|
+
|
|
566
|
+
```js
|
|
567
|
+
I.dragAndDrop('#dragHandle', '#container');
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
#### Parameters
|
|
571
|
+
|
|
572
|
+
- `srcElement` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
573
|
+
- `destElement` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
574
|
+
|
|
575
|
+
### dragSlider
|
|
576
|
+
|
|
577
|
+
Drag the scrubber of a slider to a given position
|
|
578
|
+
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
579
|
+
|
|
580
|
+
```js
|
|
581
|
+
I.dragSlider('#slider', 30);
|
|
582
|
+
I.dragSlider('#slider', -70);
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
#### Parameters
|
|
586
|
+
|
|
587
|
+
- `locator` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
588
|
+
- `offsetX` **[number][8]** position to drag.
|
|
589
|
+
|
|
590
|
+
### executeScript
|
|
591
|
+
|
|
592
|
+
Executes a script on the page:
|
|
593
|
+
|
|
594
|
+
```js
|
|
595
|
+
I.executeScript(() => window.alert('Hello world'));
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
Additional parameters of the function can be passed as an object argument:
|
|
599
|
+
|
|
600
|
+
```js
|
|
601
|
+
I.executeScript(({x, y}) => x + y, {x, y});
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
You can pass only one parameter into a function
|
|
605
|
+
but you can pass in array or object.
|
|
606
|
+
|
|
607
|
+
```js
|
|
608
|
+
I.executeScript(([x, y]) => x + y, [x, y]);
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
If a function returns a Promise it will wait for its resolution.
|
|
612
|
+
|
|
613
|
+
#### Parameters
|
|
614
|
+
|
|
615
|
+
- `fn`
|
|
616
|
+
- `arg`
|
|
617
|
+
|
|
618
|
+
### fillField
|
|
619
|
+
|
|
620
|
+
Fills a text field or textarea, after clearing its value, with the given string.
|
|
621
|
+
Field is located by name, label, CSS, or XPath.
|
|
622
|
+
|
|
623
|
+
```js
|
|
624
|
+
// by label
|
|
625
|
+
I.fillField('Email', 'hello@world.com');
|
|
626
|
+
// by name
|
|
627
|
+
I.fillField('password', secret('123456'));
|
|
628
|
+
// by CSS
|
|
629
|
+
I.fillField('form#login input[name=username]', 'John');
|
|
630
|
+
// or by strict locator
|
|
631
|
+
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
#### Parameters
|
|
635
|
+
|
|
636
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
637
|
+
- `value` **[string][7]** text value to fill.
|
|
638
|
+
|
|
639
|
+
### forceClick
|
|
640
|
+
|
|
641
|
+
Force clicks an element without waiting for it to become visible and not animating.
|
|
642
|
+
|
|
643
|
+
```js
|
|
644
|
+
I.forceClick('#hiddenButton');
|
|
645
|
+
I.forceClick('Click me', '#hidden');
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
#### Parameters
|
|
649
|
+
|
|
650
|
+
- `locator`
|
|
651
|
+
- `context`
|
|
652
|
+
|
|
653
|
+
### grabAttributeFrom
|
|
654
|
+
|
|
655
|
+
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
656
|
+
An array as a result will be returned if there are more than one matched element.
|
|
657
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
658
|
+
|
|
659
|
+
```js
|
|
660
|
+
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
#### Parameters
|
|
664
|
+
|
|
665
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
666
|
+
- `attr` **[string][7]** attribute name.
|
|
667
|
+
|
|
668
|
+
Returns **[Promise][9]<[string][7]>** attribute value
|
|
669
|
+
|
|
670
|
+
### grabBrowserLogs
|
|
671
|
+
|
|
672
|
+
Get JS log from browser.
|
|
673
|
+
|
|
674
|
+
```js
|
|
675
|
+
let logs = await I.grabBrowserLogs();
|
|
676
|
+
console.log(JSON.stringify(logs))
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
Returns **[Promise][9]<[Array][10]<any>>**
|
|
680
|
+
|
|
681
|
+
### grabCookie
|
|
682
|
+
|
|
683
|
+
Gets a cookie object by name.
|
|
684
|
+
If none provided gets all cookies.
|
|
685
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
686
|
+
|
|
687
|
+
```js
|
|
688
|
+
let cookie = await I.grabCookie('auth');
|
|
689
|
+
assert(cookie.value, '123456');
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### Parameters
|
|
693
|
+
|
|
694
|
+
- `name` **[string][7]?** cookie name.
|
|
695
|
+
|
|
696
|
+
Returns **[Promise][9]<[string][7]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
697
|
+
|
|
698
|
+
### grabCssPropertyFrom
|
|
699
|
+
|
|
700
|
+
Grab CSS property for given locator
|
|
701
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
702
|
+
|
|
703
|
+
```js
|
|
704
|
+
const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
#### Parameters
|
|
708
|
+
|
|
709
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
710
|
+
- `cssProperty` **[string][7]** CSS property name.
|
|
711
|
+
|
|
712
|
+
Returns **[Promise][9]<[string][7]>** CSS value
|
|
713
|
+
|
|
714
|
+
### grabCurrentUrl
|
|
715
|
+
|
|
716
|
+
Get current URL from browser.
|
|
717
|
+
Resumes test execution, so should be used inside an async function.
|
|
718
|
+
|
|
719
|
+
```js
|
|
720
|
+
let url = await I.grabCurrentUrl();
|
|
721
|
+
console.log(`Current URL is [${url}]`);
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
Returns **[Promise][9]<[string][7]>** current URL
|
|
725
|
+
|
|
726
|
+
### grabDataFromPerformanceTiming
|
|
727
|
+
|
|
728
|
+
Grab the data from performance timing using Navigation Timing API.
|
|
729
|
+
The returned data will contain following things in ms:
|
|
730
|
+
|
|
731
|
+
- responseEnd,
|
|
732
|
+
- domInteractive,
|
|
733
|
+
- domContentLoadedEventEnd,
|
|
734
|
+
- loadEventEnd
|
|
735
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
736
|
+
|
|
737
|
+
```js
|
|
738
|
+
await I.amOnPage('https://example.com');
|
|
739
|
+
let data = await I.grabDataFromPerformanceTiming();
|
|
740
|
+
//Returned data
|
|
741
|
+
{ // all results are in [ms]
|
|
742
|
+
responseEnd: 23,
|
|
743
|
+
domInteractive: 44,
|
|
744
|
+
domContentLoadedEventEnd: 196,
|
|
745
|
+
loadEventEnd: 241
|
|
746
|
+
}
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
### grabElementBoundingRect
|
|
750
|
+
|
|
751
|
+
Grab the width, height, location of given locator.
|
|
752
|
+
Provide `width` or `height`as second param to get your desired prop.
|
|
753
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
754
|
+
|
|
755
|
+
Returns an object with `x`, `y`, `width`, `height` keys.
|
|
756
|
+
|
|
757
|
+
```js
|
|
758
|
+
const value = await I.grabElementBoundingRect('h3');
|
|
759
|
+
// value is like { x: 226.5, y: 89, width: 527, height: 220 }
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
To get only one metric use second parameter:
|
|
763
|
+
|
|
764
|
+
```js
|
|
765
|
+
const width = await I.grabElementBoundingRect('h3', 'width');
|
|
766
|
+
// width == 527
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
#### Parameters
|
|
770
|
+
|
|
771
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
772
|
+
- `prop`
|
|
773
|
+
- `elementSize` **[string][7]** x, y, width or height of the given element.
|
|
774
|
+
|
|
775
|
+
Returns **[object][5]** Element bounding rectangle
|
|
776
|
+
|
|
777
|
+
### grabHTMLFrom
|
|
778
|
+
|
|
779
|
+
Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
780
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
781
|
+
If more than one element is found - an array of HTMLs returned.
|
|
782
|
+
|
|
783
|
+
```js
|
|
784
|
+
let postHTML = await I.grabHTMLFrom('#post');
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
#### Parameters
|
|
788
|
+
|
|
789
|
+
- `locator`
|
|
790
|
+
- `element` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
791
|
+
|
|
792
|
+
Returns **[Promise][9]<[string][7]>** HTML code for an element
|
|
793
|
+
|
|
794
|
+
### grabNumberOfOpenTabs
|
|
795
|
+
|
|
796
|
+
Grab number of open tabs.
|
|
797
|
+
|
|
798
|
+
```js
|
|
799
|
+
let tabs = await I.grabNumberOfOpenTabs();
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
Returns **[Promise][9]<[number][8]>** number of open tabs
|
|
803
|
+
|
|
804
|
+
### grabNumberOfVisibleElements
|
|
805
|
+
|
|
806
|
+
Grab number of visible elements by locator.
|
|
807
|
+
|
|
808
|
+
```js
|
|
809
|
+
let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
#### Parameters
|
|
813
|
+
|
|
814
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
815
|
+
|
|
816
|
+
Returns **[Promise][9]<[number][8]>** number of visible elements
|
|
817
|
+
|
|
818
|
+
### grabPageScrollPosition
|
|
819
|
+
|
|
820
|
+
Retrieves a page scroll position and returns it to test.
|
|
821
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
822
|
+
|
|
823
|
+
```js
|
|
824
|
+
let { x, y } = await I.grabPageScrollPosition();
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
Returns **[Promise][9]<[Object][5]<[string][7], any>>** scroll position
|
|
828
|
+
|
|
829
|
+
### grabPopupText
|
|
830
|
+
|
|
831
|
+
Grab the text within the popup. If no popup is visible then it will return null
|
|
832
|
+
|
|
833
|
+
```js
|
|
834
|
+
await I.grabPopupText();
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
Returns **[Promise][9]<([string][7] | null)>**
|
|
838
|
+
|
|
839
|
+
### grabSource
|
|
840
|
+
|
|
841
|
+
Retrieves page source and returns it to test.
|
|
842
|
+
Resumes test execution, so should be used inside an async function.
|
|
843
|
+
|
|
844
|
+
```js
|
|
845
|
+
let pageSource = await I.grabSource();
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
Returns **[Promise][9]<[string][7]>** source code
|
|
849
|
+
|
|
850
|
+
### grabTextFrom
|
|
851
|
+
|
|
852
|
+
Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
853
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
854
|
+
|
|
855
|
+
```js
|
|
856
|
+
let pin = await I.grabTextFrom('#pin');
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
If multiple elements found returns an array of texts.
|
|
860
|
+
|
|
861
|
+
#### Parameters
|
|
862
|
+
|
|
863
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
864
|
+
|
|
865
|
+
Returns **[Promise][9]<([string][7] | [Array][10]<[string][7]>)>** attribute value
|
|
866
|
+
|
|
867
|
+
### grabTitle
|
|
868
|
+
|
|
869
|
+
Retrieves a page title and returns it to test.
|
|
870
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
871
|
+
|
|
872
|
+
```js
|
|
873
|
+
let title = await I.grabTitle();
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
Returns **[Promise][9]<[string][7]>** title
|
|
877
|
+
|
|
878
|
+
### grabValueFrom
|
|
879
|
+
|
|
880
|
+
Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
881
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
882
|
+
|
|
883
|
+
```js
|
|
884
|
+
let email = await I.grabValueFrom('input[name=email]');
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
#### Parameters
|
|
888
|
+
|
|
889
|
+
- `locator` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
890
|
+
|
|
891
|
+
Returns **[Promise][9]<[string][7]>** attribute value
|
|
892
|
+
|
|
893
|
+
### handleDownloads
|
|
894
|
+
|
|
895
|
+
Handles a file download.Aa file name is required to save the file on disk.
|
|
896
|
+
Files are saved to "output" directory.
|
|
897
|
+
|
|
898
|
+
Should be used with [FileSystem helper][11] to check that file were downloaded correctly.
|
|
899
|
+
|
|
900
|
+
```js
|
|
901
|
+
I.handleDownloads('downloads/avatar.jpg');
|
|
902
|
+
I.click('Download Avatar');
|
|
903
|
+
I.amInPath('output/downloads');
|
|
904
|
+
I.waitForFile('downloads/avatar.jpg', 5);
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### Parameters
|
|
908
|
+
|
|
909
|
+
- `fileName` **[string][7]?** set filename for downloaded file
|
|
910
|
+
|
|
911
|
+
### haveRequestHeaders
|
|
912
|
+
|
|
913
|
+
Set headers for all next requests
|
|
914
|
+
|
|
915
|
+
```js
|
|
916
|
+
I.haveRequestHeaders({
|
|
917
|
+
'X-Sent-By': 'CodeceptJS',
|
|
918
|
+
});
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
#### Parameters
|
|
922
|
+
|
|
923
|
+
- `customHeaders` **[object][5]** headers to set
|
|
924
|
+
|
|
925
|
+
### moveCursorTo
|
|
926
|
+
|
|
927
|
+
Moves cursor to element matched by locator.
|
|
928
|
+
Extra shift can be set with offsetX and offsetY options.
|
|
929
|
+
|
|
930
|
+
```js
|
|
931
|
+
I.moveCursorTo('.tooltip');
|
|
932
|
+
I.moveCursorTo('#submit', 5,5);
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
#### Parameters
|
|
936
|
+
|
|
937
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
938
|
+
- `offsetX` **[number][8]** (optional, `0` by default) X-axis offset.
|
|
939
|
+
- `offsetY` **[number][8]** (optional, `0` by default) Y-axis offset.
|
|
940
|
+
|
|
941
|
+
### openNewTab
|
|
942
|
+
|
|
943
|
+
Open new tab and switch to it
|
|
944
|
+
|
|
945
|
+
```js
|
|
946
|
+
I.openNewTab();
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
You can pass in [page options][12] to emulate device on this page
|
|
950
|
+
|
|
951
|
+
```js
|
|
952
|
+
// enable mobile
|
|
953
|
+
I.openNewTab({ isMobile: true });
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
#### Parameters
|
|
957
|
+
|
|
958
|
+
- `options`
|
|
959
|
+
|
|
960
|
+
### pressKey
|
|
961
|
+
|
|
962
|
+
Presses a key in the browser (on a focused element).
|
|
963
|
+
|
|
964
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][13].
|
|
965
|
+
|
|
966
|
+
```js
|
|
967
|
+
I.pressKey('Backspace');
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
To press a key in combination with modifier keys, pass the sequence as an array. All modifier keys (`'Alt'`, `'Control'`, `'Meta'`, `'Shift'`) will be released afterwards.
|
|
971
|
+
|
|
972
|
+
```js
|
|
973
|
+
I.pressKey(['Control', 'Z']);
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
For specifying operation modifier key based on operating system it is suggested to use `'CommandOrControl'`.
|
|
977
|
+
This will press `'Command'` (also known as `'Meta'`) on macOS machines and `'Control'` on non-macOS machines.
|
|
978
|
+
|
|
979
|
+
```js
|
|
980
|
+
I.pressKey(['CommandOrControl', 'Z']);
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
Some of the supported key names are:
|
|
984
|
+
|
|
985
|
+
- `'AltLeft'` or `'Alt'`
|
|
986
|
+
- `'AltRight'`
|
|
987
|
+
- `'ArrowDown'`
|
|
988
|
+
- `'ArrowLeft'`
|
|
989
|
+
- `'ArrowRight'`
|
|
990
|
+
- `'ArrowUp'`
|
|
991
|
+
- `'Backspace'`
|
|
992
|
+
- `'Clear'`
|
|
993
|
+
- `'ControlLeft'` or `'Control'`
|
|
994
|
+
- `'ControlRight'`
|
|
995
|
+
- `'Command'`
|
|
996
|
+
- `'CommandOrControl'`
|
|
997
|
+
- `'Delete'`
|
|
998
|
+
- `'End'`
|
|
999
|
+
- `'Enter'`
|
|
1000
|
+
- `'Escape'`
|
|
1001
|
+
- `'F1'` to `'F12'`
|
|
1002
|
+
- `'Home'`
|
|
1003
|
+
- `'Insert'`
|
|
1004
|
+
- `'MetaLeft'` or `'Meta'`
|
|
1005
|
+
- `'MetaRight'`
|
|
1006
|
+
- `'Numpad0'` to `'Numpad9'`
|
|
1007
|
+
- `'NumpadAdd'`
|
|
1008
|
+
- `'NumpadDecimal'`
|
|
1009
|
+
- `'NumpadDivide'`
|
|
1010
|
+
- `'NumpadMultiply'`
|
|
1011
|
+
- `'NumpadSubtract'`
|
|
1012
|
+
- `'PageDown'`
|
|
1013
|
+
- `'PageUp'`
|
|
1014
|
+
- `'Pause'`
|
|
1015
|
+
- `'Return'`
|
|
1016
|
+
- `'ShiftLeft'` or `'Shift'`
|
|
1017
|
+
- `'ShiftRight'`
|
|
1018
|
+
- `'Space'`
|
|
1019
|
+
- `'Tab'`
|
|
1020
|
+
|
|
1021
|
+
#### Parameters
|
|
1022
|
+
|
|
1023
|
+
- `key` **([string][7] | [Array][10]<[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313][14]).
|
|
1024
|
+
|
|
1025
|
+
### pressKeyDown
|
|
1026
|
+
|
|
1027
|
+
Presses a key in the browser and leaves it in a down state.
|
|
1028
|
+
|
|
1029
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]).
|
|
1030
|
+
|
|
1031
|
+
```js
|
|
1032
|
+
I.pressKeyDown('Control');
|
|
1033
|
+
I.click('#element');
|
|
1034
|
+
I.pressKeyUp('Control');
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
#### Parameters
|
|
1038
|
+
|
|
1039
|
+
- `key` **[string][7]** name of key to press down.
|
|
1040
|
+
|
|
1041
|
+
### pressKeyUp
|
|
1042
|
+
|
|
1043
|
+
Releases a key in the browser which was previously set to a down state.
|
|
1044
|
+
|
|
1045
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]).
|
|
1046
|
+
|
|
1047
|
+
```js
|
|
1048
|
+
I.pressKeyDown('Control');
|
|
1049
|
+
I.click('#element');
|
|
1050
|
+
I.pressKeyUp('Control');
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
#### Parameters
|
|
1054
|
+
|
|
1055
|
+
- `key` **[string][7]** name of key to release.
|
|
1056
|
+
|
|
1057
|
+
### refreshPage
|
|
1058
|
+
|
|
1059
|
+
Reload the current page.
|
|
1060
|
+
|
|
1061
|
+
```js
|
|
1062
|
+
I.refreshPage();
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
### resizeWindow
|
|
1066
|
+
|
|
1067
|
+
Resize the current window to provided width and height.
|
|
1068
|
+
First parameter can be set to `maximize`.
|
|
1069
|
+
|
|
1070
|
+
#### Parameters
|
|
1071
|
+
|
|
1072
|
+
- `width` **[number][8]** width in pixels or `maximize`.
|
|
1073
|
+
- `height` **[number][8]** height in pixels.Unlike other drivers Playwright changes the size of a viewport, not the window!
|
|
1074
|
+
Playwright does not control the window of a browser so it can't adjust its real size.
|
|
1075
|
+
It also can't maximize a window.Update configuration to change real window size on start:```js
|
|
1076
|
+
// inside codecept.conf.js
|
|
1077
|
+
// @codeceptjs/configure package must be installed
|
|
1078
|
+
{ setWindowSize } = require('@codeceptjs/configure');
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
### rightClick
|
|
1082
|
+
|
|
1083
|
+
Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
1084
|
+
|
|
1085
|
+
```js
|
|
1086
|
+
// right click element with id el
|
|
1087
|
+
I.rightClick('#el');
|
|
1088
|
+
// right click link or button with text "Click me"
|
|
1089
|
+
I.rightClick('Click me');
|
|
1090
|
+
// right click button with text "Click me" inside .context
|
|
1091
|
+
I.rightClick('Click me', '.context');
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
#### Parameters
|
|
1095
|
+
|
|
1096
|
+
- `locator` **([string][7] | [object][5])** clickable element located by CSS|XPath|strict locator.
|
|
1097
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1098
|
+
|
|
1099
|
+
### saveScreenshot
|
|
1100
|
+
|
|
1101
|
+
Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
|
|
1102
|
+
Filename is relative to output folder.
|
|
1103
|
+
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
|
|
1104
|
+
|
|
1105
|
+
```js
|
|
1106
|
+
I.saveScreenshot('debug.png');
|
|
1107
|
+
I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
#### Parameters
|
|
1111
|
+
|
|
1112
|
+
- `fileName` **[string][7]** file name to save.
|
|
1113
|
+
- `fullPage` **[boolean][16]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1114
|
+
|
|
1115
|
+
### scrollPageToBottom
|
|
1116
|
+
|
|
1117
|
+
Scroll page to the bottom.
|
|
1118
|
+
|
|
1119
|
+
```js
|
|
1120
|
+
I.scrollPageToBottom();
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
### scrollPageToTop
|
|
1124
|
+
|
|
1125
|
+
Scroll page to the top.
|
|
1126
|
+
|
|
1127
|
+
```js
|
|
1128
|
+
I.scrollPageToTop();
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
### scrollTo
|
|
1132
|
+
|
|
1133
|
+
Scrolls to element matched by locator.
|
|
1134
|
+
Extra shift can be set with offsetX and offsetY options.
|
|
1135
|
+
|
|
1136
|
+
```js
|
|
1137
|
+
I.scrollTo('footer');
|
|
1138
|
+
I.scrollTo('#submit', 5, 5);
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
#### Parameters
|
|
1142
|
+
|
|
1143
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
1144
|
+
- `offsetX` **[number][8]** (optional, `0` by default) X-axis offset.
|
|
1145
|
+
- `offsetY` **[number][8]** (optional, `0` by default) Y-axis offset.
|
|
1146
|
+
|
|
1147
|
+
### see
|
|
1148
|
+
|
|
1149
|
+
Checks that a page contains a visible text.
|
|
1150
|
+
Use context parameter to narrow down the search.
|
|
1151
|
+
|
|
1152
|
+
```js
|
|
1153
|
+
I.see('Welcome'); // text welcome on a page
|
|
1154
|
+
I.see('Welcome', '.content'); // text inside .content div
|
|
1155
|
+
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
#### Parameters
|
|
1159
|
+
|
|
1160
|
+
- `text` **[string][7]** expected on page.
|
|
1161
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1162
|
+
|
|
1163
|
+
### seeAttributesOnElements
|
|
1164
|
+
|
|
1165
|
+
Checks that all elements with given locator have given attributes.
|
|
1166
|
+
|
|
1167
|
+
```js
|
|
1168
|
+
I.seeAttributesOnElements('//form', { method: "post"});
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
#### Parameters
|
|
1172
|
+
|
|
1173
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
1174
|
+
- `attributes` **[object][5]** attributes and their values to check.
|
|
1175
|
+
|
|
1176
|
+
### seeCheckboxIsChecked
|
|
1177
|
+
|
|
1178
|
+
Verifies that the specified checkbox is checked.
|
|
1179
|
+
|
|
1180
|
+
```js
|
|
1181
|
+
I.seeCheckboxIsChecked('Agree');
|
|
1182
|
+
I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1183
|
+
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
#### Parameters
|
|
1187
|
+
|
|
1188
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
1189
|
+
|
|
1190
|
+
### seeCookie
|
|
1191
|
+
|
|
1192
|
+
Checks that cookie with given name exists.
|
|
1193
|
+
|
|
1194
|
+
```js
|
|
1195
|
+
I.seeCookie('Auth');
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
#### Parameters
|
|
1199
|
+
|
|
1200
|
+
- `name` **[string][7]** cookie name.
|
|
1201
|
+
|
|
1202
|
+
### seeCssPropertiesOnElements
|
|
1203
|
+
|
|
1204
|
+
Checks that all elements with given locator have given CSS properties.
|
|
1205
|
+
|
|
1206
|
+
```js
|
|
1207
|
+
I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
#### Parameters
|
|
1211
|
+
|
|
1212
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
1213
|
+
- `cssProperties` **[object][5]** object with CSS properties and their values to check.
|
|
1214
|
+
|
|
1215
|
+
### seeCurrentUrlEquals
|
|
1216
|
+
|
|
1217
|
+
Checks that current url is equal to provided one.
|
|
1218
|
+
If a relative url provided, a configured url will be prepended to it.
|
|
1219
|
+
So both examples will work:
|
|
1220
|
+
|
|
1221
|
+
```js
|
|
1222
|
+
I.seeCurrentUrlEquals('/register');
|
|
1223
|
+
I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
#### Parameters
|
|
1227
|
+
|
|
1228
|
+
- `url` **[string][7]** value to check.
|
|
1229
|
+
|
|
1230
|
+
### seeElement
|
|
1231
|
+
|
|
1232
|
+
Checks that a given Element is visible
|
|
1233
|
+
Element is located by CSS or XPath.
|
|
1234
|
+
|
|
1235
|
+
```js
|
|
1236
|
+
I.seeElement('#modal');
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
#### Parameters
|
|
1240
|
+
|
|
1241
|
+
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
1242
|
+
|
|
1243
|
+
### seeElementInDOM
|
|
1244
|
+
|
|
1245
|
+
Checks that a given Element is present in the DOM
|
|
1246
|
+
Element is located by CSS or XPath.
|
|
1247
|
+
|
|
1248
|
+
```js
|
|
1249
|
+
I.seeElementInDOM('#modal');
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
#### Parameters
|
|
1253
|
+
|
|
1254
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1255
|
+
|
|
1256
|
+
### seeInCurrentUrl
|
|
1257
|
+
|
|
1258
|
+
Checks that current url contains a provided fragment.
|
|
1259
|
+
|
|
1260
|
+
```js
|
|
1261
|
+
I.seeInCurrentUrl('/register'); // we are on registration page
|
|
1262
|
+
```
|
|
1263
|
+
|
|
1264
|
+
#### Parameters
|
|
1265
|
+
|
|
1266
|
+
- `url` **[string][7]** a fragment to check
|
|
1267
|
+
|
|
1268
|
+
### seeInField
|
|
1269
|
+
|
|
1270
|
+
Checks that the given input field or textarea equals to given value.
|
|
1271
|
+
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1272
|
+
|
|
1273
|
+
```js
|
|
1274
|
+
I.seeInField('Username', 'davert');
|
|
1275
|
+
I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1276
|
+
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1277
|
+
I.seeInField('#searchform input','Search');
|
|
1278
|
+
```
|
|
1279
|
+
|
|
1280
|
+
#### Parameters
|
|
1281
|
+
|
|
1282
|
+
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
1283
|
+
- `value` **[string][7]** value to check.
|
|
1284
|
+
|
|
1285
|
+
### seeInPopup
|
|
1286
|
+
|
|
1287
|
+
Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1288
|
+
given string.
|
|
1289
|
+
|
|
1290
|
+
```js
|
|
1291
|
+
I.seeInPopup('Popup text');
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
#### Parameters
|
|
1295
|
+
|
|
1296
|
+
- `text` **[string][7]** value to check.
|
|
1297
|
+
|
|
1298
|
+
### seeInSource
|
|
1299
|
+
|
|
1300
|
+
Checks that the current page contains the given string in its raw source code.
|
|
1301
|
+
|
|
1302
|
+
```js
|
|
1303
|
+
I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
#### Parameters
|
|
1307
|
+
|
|
1308
|
+
- `text` **[string][7]** value to check.
|
|
1309
|
+
|
|
1310
|
+
### seeInTitle
|
|
1311
|
+
|
|
1312
|
+
Checks that title contains text.
|
|
1313
|
+
|
|
1314
|
+
```js
|
|
1315
|
+
I.seeInTitle('Home Page');
|
|
1316
|
+
```
|
|
1317
|
+
|
|
1318
|
+
#### Parameters
|
|
1319
|
+
|
|
1320
|
+
- `text` **[string][7]** text value to check.
|
|
1321
|
+
|
|
1322
|
+
### seeNumberOfElements
|
|
1323
|
+
|
|
1324
|
+
Asserts that an element appears a given number of times in the DOM.
|
|
1325
|
+
Element is located by label or name or CSS or XPath.
|
|
1326
|
+
|
|
1327
|
+
```js
|
|
1328
|
+
I.seeNumberOfElements('#submitBtn', 1);
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
#### Parameters
|
|
1332
|
+
|
|
1333
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1334
|
+
- `num` **[number][8]** number of elements.
|
|
1335
|
+
|
|
1336
|
+
### seeNumberOfVisibleElements
|
|
1337
|
+
|
|
1338
|
+
Asserts that an element is visible a given number of times.
|
|
1339
|
+
Element is located by CSS or XPath.
|
|
1340
|
+
|
|
1341
|
+
```js
|
|
1342
|
+
I.seeNumberOfVisibleElements('.buttons', 3);
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
#### Parameters
|
|
1346
|
+
|
|
1347
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1348
|
+
- `num` **[number][8]** number of elements.
|
|
1349
|
+
|
|
1350
|
+
### seeTextEquals
|
|
1351
|
+
|
|
1352
|
+
Checks that text is equal to provided one.
|
|
1353
|
+
|
|
1354
|
+
```js
|
|
1355
|
+
I.seeTextEquals('text', 'h1');
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
#### Parameters
|
|
1359
|
+
|
|
1360
|
+
- `text` **[string][7]** element value to check.
|
|
1361
|
+
- `context` **([string][7] | [object][5]?)** element located by CSS|XPath|strict locator.
|
|
1362
|
+
|
|
1363
|
+
### seeTitleEquals
|
|
1364
|
+
|
|
1365
|
+
Checks that title is equal to provided one.
|
|
1366
|
+
|
|
1367
|
+
```js
|
|
1368
|
+
I.seeTitleEquals('Test title.');
|
|
1369
|
+
```
|
|
1370
|
+
|
|
1371
|
+
#### Parameters
|
|
1372
|
+
|
|
1373
|
+
- `text`
|
|
1374
|
+
|
|
1375
|
+
### selectOption
|
|
1376
|
+
|
|
1377
|
+
Selects an option in a drop-down select.
|
|
1378
|
+
Field is searched by label | name | CSS | XPath.
|
|
1379
|
+
Option is selected by visible text or by value.
|
|
1380
|
+
|
|
1381
|
+
```js
|
|
1382
|
+
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
1383
|
+
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
1384
|
+
I.selectOption('subscription', '0'); // or by value
|
|
1385
|
+
I.selectOption('//form/select[@name=account]','Premium');
|
|
1386
|
+
I.selectOption('form select[name=account]', 'Premium');
|
|
1387
|
+
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
Provide an array for the second argument to select multiple options.
|
|
1391
|
+
|
|
1392
|
+
```js
|
|
1393
|
+
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1394
|
+
```
|
|
1395
|
+
|
|
1396
|
+
#### Parameters
|
|
1397
|
+
|
|
1398
|
+
- `select` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1399
|
+
- `option` **([string][7] | [Array][10]<any>)** visible text or value of option.
|
|
1400
|
+
|
|
1401
|
+
### setCookie
|
|
1402
|
+
|
|
1403
|
+
Sets cookie(s).
|
|
1404
|
+
|
|
1405
|
+
Can be a single cookie object or an array of cookies:
|
|
1406
|
+
|
|
1407
|
+
```js
|
|
1408
|
+
I.setCookie({name: 'auth', value: true});
|
|
1409
|
+
|
|
1410
|
+
// as array
|
|
1411
|
+
I.setCookie([
|
|
1412
|
+
{name: 'auth', value: true},
|
|
1413
|
+
{name: 'agree', value: true}
|
|
1414
|
+
]);
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
#### Parameters
|
|
1418
|
+
|
|
1419
|
+
- `cookie` **([object][5] | [array][10])** a cookie object or array of cookie objects.
|
|
1420
|
+
|
|
1421
|
+
### switchTo
|
|
1422
|
+
|
|
1423
|
+
Switches frame or in case of null locator reverts to parent.
|
|
1424
|
+
|
|
1425
|
+
```js
|
|
1426
|
+
I.switchTo('iframe'); // switch to first iframe
|
|
1427
|
+
I.switchTo(); // switch back to main page
|
|
1428
|
+
```
|
|
1429
|
+
|
|
1430
|
+
#### Parameters
|
|
1431
|
+
|
|
1432
|
+
- `locator` **([string][7]? | [object][5])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1433
|
+
|
|
1434
|
+
### switchToNextTab
|
|
1435
|
+
|
|
1436
|
+
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
|
|
1437
|
+
|
|
1438
|
+
```js
|
|
1439
|
+
I.switchToNextTab();
|
|
1440
|
+
I.switchToNextTab(2);
|
|
1441
|
+
```
|
|
1442
|
+
|
|
1443
|
+
#### Parameters
|
|
1444
|
+
|
|
1445
|
+
- `num` **[number][8]**
|
|
1446
|
+
|
|
1447
|
+
### switchToPreviousTab
|
|
1448
|
+
|
|
1449
|
+
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
|
|
1450
|
+
|
|
1451
|
+
```js
|
|
1452
|
+
I.switchToPreviousTab();
|
|
1453
|
+
I.switchToPreviousTab(2);
|
|
1454
|
+
```
|
|
1455
|
+
|
|
1456
|
+
#### Parameters
|
|
1457
|
+
|
|
1458
|
+
- `num` **[number][8]**
|
|
1459
|
+
|
|
1460
|
+
### uncheckOption
|
|
1461
|
+
|
|
1462
|
+
Unselects a checkbox or radio button.
|
|
1463
|
+
Element is located by label or name or CSS or XPath.
|
|
1464
|
+
|
|
1465
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1466
|
+
|
|
1467
|
+
```js
|
|
1468
|
+
I.uncheckOption('#agree');
|
|
1469
|
+
I.uncheckOption('I Agree to Terms and Conditions');
|
|
1470
|
+
I.uncheckOption('agree', '//form');
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
#### Parameters
|
|
1474
|
+
|
|
1475
|
+
- `field` **([string][7] | [object][5])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
1476
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1477
|
+
|
|
1478
|
+
### wait
|
|
1479
|
+
|
|
1480
|
+
Pauses execution for a number of seconds.
|
|
1481
|
+
|
|
1482
|
+
```js
|
|
1483
|
+
I.wait(2); // wait 2 secs
|
|
1484
|
+
```
|
|
1485
|
+
|
|
1486
|
+
#### Parameters
|
|
1487
|
+
|
|
1488
|
+
- `sec` **[number][8]** number of second to wait.
|
|
1489
|
+
|
|
1490
|
+
### waitForClickable
|
|
1491
|
+
|
|
1492
|
+
Waits for element to be clickable (by default waits for 1sec).
|
|
1493
|
+
Element can be located by CSS or XPath.
|
|
1494
|
+
|
|
1495
|
+
```js
|
|
1496
|
+
I.waitForClickable('.btn.continue');
|
|
1497
|
+
I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
1498
|
+
```
|
|
1499
|
+
|
|
1500
|
+
#### Parameters
|
|
1501
|
+
|
|
1502
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1503
|
+
- `waitTimeout`
|
|
1504
|
+
- `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
|
|
1505
|
+
|
|
1506
|
+
### waitForDetached
|
|
1507
|
+
|
|
1508
|
+
Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
1509
|
+
Element can be located by CSS or XPath.
|
|
1510
|
+
|
|
1511
|
+
```js
|
|
1512
|
+
I.waitForDetached('#popup');
|
|
1513
|
+
```
|
|
1514
|
+
|
|
1515
|
+
#### Parameters
|
|
1516
|
+
|
|
1517
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1518
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1519
|
+
|
|
1520
|
+
### waitForElement
|
|
1521
|
+
|
|
1522
|
+
Waits for element to be present on page (by default waits for 1sec).
|
|
1523
|
+
Element can be located by CSS or XPath.
|
|
1524
|
+
|
|
1525
|
+
```js
|
|
1526
|
+
I.waitForElement('.btn.continue');
|
|
1527
|
+
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
#### Parameters
|
|
1531
|
+
|
|
1532
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1533
|
+
- `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
|
|
1534
|
+
|
|
1535
|
+
### waitForEnabled
|
|
1536
|
+
|
|
1537
|
+
Waits for element to become enabled (by default waits for 1sec).
|
|
1538
|
+
Element can be located by CSS or XPath.
|
|
1539
|
+
|
|
1540
|
+
#### Parameters
|
|
1541
|
+
|
|
1542
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1543
|
+
- `sec` **[number][8]** (optional) time in seconds to wait, 1 by default.
|
|
1544
|
+
|
|
1545
|
+
### waitForFunction
|
|
1546
|
+
|
|
1547
|
+
Waits for a function to return true (waits for 1 sec by default).
|
|
1548
|
+
Running in browser context.
|
|
1549
|
+
|
|
1550
|
+
```js
|
|
1551
|
+
I.waitForFunction(fn[, [args[, timeout]])
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
```js
|
|
1555
|
+
I.waitForFunction(() => window.requests == 0);
|
|
1556
|
+
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
|
|
1557
|
+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
#### Parameters
|
|
1561
|
+
|
|
1562
|
+
- `fn` **([string][7] | [function][17])** to be executed in browser context.
|
|
1563
|
+
- `argsOrSec` **([Array][10]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds.
|
|
1564
|
+
- `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
|
|
1565
|
+
|
|
1566
|
+
### waitForInvisible
|
|
1567
|
+
|
|
1568
|
+
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
1569
|
+
Element can be located by CSS or XPath.
|
|
1570
|
+
|
|
1571
|
+
```js
|
|
1572
|
+
I.waitForInvisible('#popup');
|
|
1573
|
+
```
|
|
1574
|
+
|
|
1575
|
+
#### Parameters
|
|
1576
|
+
|
|
1577
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1578
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1579
|
+
|
|
1580
|
+
### waitForNavigation
|
|
1581
|
+
|
|
1582
|
+
Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
1583
|
+
|
|
1584
|
+
See [Pupeteer's reference][18]
|
|
1585
|
+
|
|
1586
|
+
#### Parameters
|
|
1587
|
+
|
|
1588
|
+
- `opts` **any**
|
|
1589
|
+
|
|
1590
|
+
### waitForRequest
|
|
1591
|
+
|
|
1592
|
+
Waits for a network request.
|
|
1593
|
+
|
|
1594
|
+
```js
|
|
1595
|
+
I.waitForRequest('http://example.com/resource');
|
|
1596
|
+
I.waitForRequest(request => request.url() === 'http://example.com' && request.method() === 'GET');
|
|
1597
|
+
```
|
|
1598
|
+
|
|
1599
|
+
#### Parameters
|
|
1600
|
+
|
|
1601
|
+
- `urlOrPredicate` **([string][7] | [function][17])**
|
|
1602
|
+
- `sec` **[number][8]?** seconds to wait
|
|
1603
|
+
|
|
1604
|
+
### waitForResponse
|
|
1605
|
+
|
|
1606
|
+
Waits for a network request.
|
|
1607
|
+
|
|
1608
|
+
```js
|
|
1609
|
+
I.waitForResponse('http://example.com/resource');
|
|
1610
|
+
I.waitForResponse(request => request.url() === 'http://example.com' && request.method() === 'GET');
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
#### Parameters
|
|
1614
|
+
|
|
1615
|
+
- `urlOrPredicate` **([string][7] | [function][17])**
|
|
1616
|
+
- `sec` **[number][8]?** number of seconds to wait
|
|
1617
|
+
|
|
1618
|
+
### waitForText
|
|
1619
|
+
|
|
1620
|
+
Waits for a text to appear (by default waits for 1sec).
|
|
1621
|
+
Element can be located by CSS or XPath.
|
|
1622
|
+
Narrow down search results by providing context.
|
|
1623
|
+
|
|
1624
|
+
```js
|
|
1625
|
+
I.waitForText('Thank you, form has been submitted');
|
|
1626
|
+
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
1627
|
+
```
|
|
1628
|
+
|
|
1629
|
+
#### Parameters
|
|
1630
|
+
|
|
1631
|
+
- `text` **[string][7]** to wait for.
|
|
1632
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1633
|
+
- `context` **([string][7] | [object][5])?** (optional) element located by CSS|XPath|strict locator.
|
|
1634
|
+
|
|
1635
|
+
### waitForValue
|
|
1636
|
+
|
|
1637
|
+
Waits for the specified value to be in value attribute.
|
|
1638
|
+
|
|
1639
|
+
```js
|
|
1640
|
+
I.waitForValue('//input', "GoodValue");
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
#### Parameters
|
|
1644
|
+
|
|
1645
|
+
- `field` **([string][7] | [object][5])** input field.
|
|
1646
|
+
- `value` **[string][7]** expected value.
|
|
1647
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1648
|
+
|
|
1649
|
+
### waitForVisible
|
|
1650
|
+
|
|
1651
|
+
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
1652
|
+
Element can be located by CSS or XPath.
|
|
1653
|
+
|
|
1654
|
+
```js
|
|
1655
|
+
I.waitForVisible('#popup');
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
#### Parameters
|
|
1659
|
+
|
|
1660
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1661
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][19].
|
|
1662
|
+
|
|
1663
|
+
### waitInUrl
|
|
1664
|
+
|
|
1665
|
+
Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
|
|
1666
|
+
|
|
1667
|
+
```js
|
|
1668
|
+
I.waitInUrl('/info', 2);
|
|
1669
|
+
```
|
|
1670
|
+
|
|
1671
|
+
#### Parameters
|
|
1672
|
+
|
|
1673
|
+
- `urlPart` **[string][7]** value to check.
|
|
1674
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1675
|
+
|
|
1676
|
+
### waitNumberOfVisibleElements
|
|
1677
|
+
|
|
1678
|
+
Waits for a specified number of elements on the page.
|
|
1679
|
+
|
|
1680
|
+
```js
|
|
1681
|
+
I.waitNumberOfVisibleElements('a', 3);
|
|
1682
|
+
```
|
|
1683
|
+
|
|
1684
|
+
#### Parameters
|
|
1685
|
+
|
|
1686
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1687
|
+
- `num` **[number][8]** number of elements.
|
|
1688
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1689
|
+
|
|
1690
|
+
### waitToHide
|
|
1691
|
+
|
|
1692
|
+
Waits for an element to hide (by default waits for 1sec).
|
|
1693
|
+
Element can be located by CSS or XPath.
|
|
1694
|
+
|
|
1695
|
+
```js
|
|
1696
|
+
I.waitToHide('#popup');
|
|
1697
|
+
```
|
|
1698
|
+
|
|
1699
|
+
#### Parameters
|
|
1700
|
+
|
|
1701
|
+
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
1702
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1703
|
+
|
|
1704
|
+
### waitUntil
|
|
1705
|
+
|
|
1706
|
+
Waits for a function to return true (waits for 1sec by default).
|
|
1707
|
+
|
|
1708
|
+
```js
|
|
1709
|
+
I.waitUntil(() => window.requests == 0);
|
|
1710
|
+
I.waitUntil(() => window.requests == 0, 5);
|
|
1711
|
+
```
|
|
1712
|
+
|
|
1713
|
+
#### Parameters
|
|
1714
|
+
|
|
1715
|
+
- `fn` **([function][17] | [string][7])** function which is executed in browser context.
|
|
1716
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1717
|
+
- `timeoutMsg` **[string][7]** message to show in case of timeout fail.
|
|
1718
|
+
- `interval` **[number][8]?**
|
|
1719
|
+
|
|
1720
|
+
### waitUrlEquals
|
|
1721
|
+
|
|
1722
|
+
Waits for the entire URL to match the expected
|
|
1723
|
+
|
|
1724
|
+
```js
|
|
1725
|
+
I.waitUrlEquals('/info', 2);
|
|
1726
|
+
I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
#### Parameters
|
|
1730
|
+
|
|
1731
|
+
- `urlPart` **[string][7]** value to check.
|
|
1732
|
+
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1733
|
+
|
|
1734
|
+
[1]: https://github.com/microsoft/playwright
|
|
1735
|
+
|
|
1736
|
+
[2]: https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitfornavigationoptions
|
|
1737
|
+
|
|
1738
|
+
[3]: https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
|
|
1739
|
+
|
|
1740
|
+
[4]: https://github.com/microsoft/playwright/blob/v0.11.0/docs/api.md#working-with-chrome-extensions
|
|
1741
|
+
|
|
1742
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
1743
|
+
|
|
1744
|
+
[6]: http://jster.net/category/windows-modals-popups
|
|
1745
|
+
|
|
1746
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1747
|
+
|
|
1748
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
1749
|
+
|
|
1750
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1751
|
+
|
|
1752
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1753
|
+
|
|
1754
|
+
[11]: https://codecept.io/helpers/FileSystem
|
|
1755
|
+
|
|
1756
|
+
[12]: https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#browsernewpageoptions
|
|
1757
|
+
|
|
1758
|
+
[13]: #fillfield
|
|
1759
|
+
|
|
1760
|
+
[14]: https://github.com/GoogleChrome/Playwright/issues/1313
|
|
1761
|
+
|
|
1762
|
+
[15]: #click
|
|
1763
|
+
|
|
1764
|
+
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
1765
|
+
|
|
1766
|
+
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1767
|
+
|
|
1768
|
+
[18]: https://github.com/GoogleChrome/Playwright/blob/master/docs/api.md#pagewaitfornavigationoptions
|
|
1769
|
+
|
|
1770
|
+
[19]: https://codecept.io/react
|