codeceptjs 3.6.0-beta.1.ai-healers → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/codecept.js +2 -1
- package/docs/webapi/dontSeeTraffic.mustache +13 -0
- package/docs/webapi/flushNetworkTraffics.mustache +5 -0
- package/docs/webapi/grabRecordedNetworkTraffics.mustache +10 -0
- package/docs/webapi/seeTraffic.mustache +36 -0
- package/docs/webapi/startRecordingTraffic.mustache +8 -0
- package/docs/webapi/startRecordingWebSocketMessages.mustache +8 -0
- package/docs/webapi/stopRecordingTraffic.mustache +5 -0
- package/docs/webapi/stopRecordingWebSocketMessages.mustache +7 -0
- package/docs/webapi/waitForCookie.mustache +9 -0
- package/lib/actor.js +6 -3
- package/lib/command/dryRun.js +44 -13
- package/lib/helper/Appium.js +36 -12
- package/lib/helper/Expect.js +11 -8
- package/lib/helper/JSONResponse.js +8 -8
- package/lib/helper/MockServer.js +221 -0
- package/lib/helper/Playwright.js +107 -371
- package/lib/helper/Puppeteer.js +404 -71
- package/lib/helper/REST.js +4 -1
- package/lib/helper/WebDriver.js +189 -13
- package/lib/helper/errors/ElementAssertion.js +38 -0
- package/lib/helper/extras/PlaywrightReactVueLocator.js +6 -1
- package/lib/helper/network/actions.js +123 -0
- package/lib/helper/network/utils.js +187 -0
- package/lib/locator.js +36 -5
- package/lib/plugin/coverage.js +112 -99
- package/lib/step.js +3 -1
- package/package.json +48 -37
- package/typings/index.d.ts +19 -2
- package/typings/promiseBasedTypes.d.ts +505 -41
- package/typings/types.d.ts +609 -56
- package/docs/advanced.md +0 -351
- package/docs/ai.md +0 -365
- package/docs/api.md +0 -323
- package/docs/basics.md +0 -979
- package/docs/bdd.md +0 -539
- package/docs/best.md +0 -237
- package/docs/books.md +0 -37
- package/docs/bootstrap.md +0 -135
- package/docs/build/AI.js +0 -124
- package/docs/build/ApiDataFactory.js +0 -410
- package/docs/build/Appium.js +0 -2027
- package/docs/build/Expect.js +0 -422
- package/docs/build/FileSystem.js +0 -228
- package/docs/build/GraphQL.js +0 -229
- package/docs/build/GraphQLDataFactory.js +0 -309
- package/docs/build/JSONResponse.js +0 -338
- package/docs/build/Mochawesome.js +0 -71
- package/docs/build/Nightmare.js +0 -2152
- package/docs/build/OpenAI.js +0 -126
- package/docs/build/Playwright.js +0 -5110
- package/docs/build/Protractor.js +0 -2706
- package/docs/build/Puppeteer.js +0 -3905
- package/docs/build/REST.js +0 -344
- package/docs/build/TestCafe.js +0 -2125
- package/docs/build/WebDriver.js +0 -4240
- package/docs/changelog.md +0 -2572
- package/docs/commands.md +0 -266
- package/docs/community-helpers.md +0 -58
- package/docs/configuration.md +0 -157
- package/docs/continuous-integration.md +0 -22
- package/docs/custom-helpers.md +0 -306
- package/docs/data.md +0 -379
- package/docs/detox.md +0 -235
- package/docs/docker.md +0 -136
- package/docs/email.md +0 -183
- package/docs/examples.md +0 -149
- package/docs/heal.md +0 -186
- package/docs/helpers/ApiDataFactory.md +0 -266
- package/docs/helpers/Appium.md +0 -1374
- package/docs/helpers/Detox.md +0 -586
- package/docs/helpers/Expect.md +0 -275
- package/docs/helpers/FileSystem.md +0 -152
- package/docs/helpers/GraphQL.md +0 -151
- package/docs/helpers/GraphQLDataFactory.md +0 -226
- package/docs/helpers/JSONResponse.md +0 -254
- package/docs/helpers/Mochawesome.md +0 -8
- package/docs/helpers/MockRequest.md +0 -377
- package/docs/helpers/Nightmare.md +0 -1305
- package/docs/helpers/OpenAI.md +0 -70
- package/docs/helpers/Playwright.md +0 -2759
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Protractor.md +0 -1769
- package/docs/helpers/Puppeteer-firefox.md +0 -86
- package/docs/helpers/Puppeteer.md +0 -2317
- package/docs/helpers/REST.md +0 -218
- package/docs/helpers/TestCafe.md +0 -1321
- package/docs/helpers/WebDriver.md +0 -2547
- package/docs/hooks.md +0 -340
- package/docs/index.md +0 -111
- package/docs/installation.md +0 -75
- package/docs/internal-api.md +0 -266
- package/docs/locators.md +0 -339
- package/docs/mobile-react-native-locators.md +0 -67
- package/docs/mobile.md +0 -338
- package/docs/pageobjects.md +0 -291
- package/docs/parallel.md +0 -400
- package/docs/playwright.md +0 -632
- package/docs/plugins.md +0 -1247
- package/docs/puppeteer.md +0 -316
- package/docs/quickstart.md +0 -162
- package/docs/react.md +0 -70
- package/docs/reports.md +0 -392
- package/docs/secrets.md +0 -36
- package/docs/shadow.md +0 -68
- package/docs/shared/keys.mustache +0 -31
- package/docs/shared/react.mustache +0 -1
- package/docs/testcafe.md +0 -174
- package/docs/translation.md +0 -247
- package/docs/tutorial.md +0 -271
- package/docs/typescript.md +0 -180
- package/docs/ui.md +0 -59
- package/docs/videos.md +0 -28
- package/docs/visual.md +0 -202
- package/docs/vue.md +0 -143
- package/docs/webdriver.md +0 -701
- package/docs/wiki/Books-&-Posts.md +0 -27
- package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
- package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
- package/docs/wiki/Examples.md +0 -145
- package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
- package/docs/wiki/Home.md +0 -16
- package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
- package/docs/wiki/Release-Process.md +0 -24
- package/docs/wiki/Roadmap.md +0 -23
- package/docs/wiki/Tests.md +0 -1393
- package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
- package/docs/wiki/Videos.md +0 -19
|
@@ -1,2317 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /helpers/Puppeteer
|
|
3
|
-
editLink: false
|
|
4
|
-
sidebar: auto
|
|
5
|
-
title: Puppeteer
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
9
|
-
|
|
10
|
-
## Puppeteer
|
|
11
|
-
|
|
12
|
-
**Extends Helper**
|
|
13
|
-
|
|
14
|
-
Uses [Google Chrome's Puppeteer][1] library to run tests inside headless Chrome.
|
|
15
|
-
Browser control is executed via DevTools Protocol (instead of Selenium).
|
|
16
|
-
This helper works with a browser out of the box with no additional tools required to install.
|
|
17
|
-
|
|
18
|
-
Requires `puppeteer` or `puppeteer-core` package to be installed.
|
|
19
|
-
|
|
20
|
-
npm i puppeteer --save
|
|
21
|
-
|
|
22
|
-
or
|
|
23
|
-
|
|
24
|
-
npm i puppeteer-core --save
|
|
25
|
-
|
|
26
|
-
Using `puppeteer-core` package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
|
|
27
|
-
|
|
28
|
-
> Experimental Firefox support [can be activated][2].
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## Configuration
|
|
33
|
-
|
|
34
|
-
This helper should be configured in codecept.conf.js
|
|
35
|
-
|
|
36
|
-
Type: [object][4]
|
|
37
|
-
|
|
38
|
-
### Properties
|
|
39
|
-
|
|
40
|
-
- `url` **[string][6]** base url of website to be tested
|
|
41
|
-
- `basicAuth` **[object][4]?** (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
42
|
-
- `show` **[boolean][20]?** show Google Chrome window for debug.
|
|
43
|
-
- `restart` **[boolean][20]?** restart browser between tests.
|
|
44
|
-
- `disableScreenshots` **[boolean][20]?** don't save screenshot on failure.
|
|
45
|
-
- `fullPageScreenshots` **[boolean][20]?** make full page screenshots on failure.
|
|
46
|
-
- `uniqueScreenshotNames` **[boolean][20]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
|
|
47
|
-
- `trace` **[boolean][20]?** record [tracing information][24] with screenshots.
|
|
48
|
-
- `keepTraceForPassedTests` **[boolean][20]?** save trace for passed tests.
|
|
49
|
-
- `keepBrowserState` **[boolean][20]?** keep browser state between tests when `restart` is set to false.
|
|
50
|
-
- `keepCookies` **[boolean][20]?** keep cookies between tests when `restart` is set to false.
|
|
51
|
-
- `waitForAction` **[number][10]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
52
|
-
- `waitForNavigation` **[string][6]?** when to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Puppeteer API][23]. Array values are accepted as well.
|
|
53
|
-
- `pressKeyDelay` **[number][10]?** delay between key presses in ms. Used when calling Puppeteers page.type(...) in fillField/appendField
|
|
54
|
-
- `getPageTimeout` **[number][10]?** config option to set maximum navigation time in milliseconds. If the timeout is set to 0, then timeout will be disabled.
|
|
55
|
-
- `waitForTimeout` **[number][10]?** default wait* timeout in ms.
|
|
56
|
-
- `windowSize` **[string][6]?** default window size. Set a dimension in format WIDTHxHEIGHT like `640x480`.
|
|
57
|
-
- `userAgent` **[string][6]?** user-agent string.
|
|
58
|
-
- `manualStart` **[boolean][20]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
|
|
59
|
-
- `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
|
|
60
|
-
- `chrome` **[object][4]?** pass additional [Puppeteer run options][25].
|
|
61
|
-
- `highlightElement` **[boolean][20]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
#### Trace Recording Customization
|
|
66
|
-
|
|
67
|
-
Trace recording provides complete information on test execution and includes screenshots, and network requests logged during run.
|
|
68
|
-
Traces will be saved to `output/trace`
|
|
69
|
-
|
|
70
|
-
- `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
|
|
71
|
-
- `keepTraceForPassedTests`: - save trace for passed tests
|
|
72
|
-
|
|
73
|
-
#### Example #1: Wait for 0 network connections.
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
{
|
|
77
|
-
helpers: {
|
|
78
|
-
Puppeteer : {
|
|
79
|
-
url: "http://localhost",
|
|
80
|
-
restart: false,
|
|
81
|
-
waitForNavigation: "networkidle0",
|
|
82
|
-
waitForAction: 500
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### Example #2: Wait for DOMContentLoaded event and 0 network connections
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
{
|
|
92
|
-
helpers: {
|
|
93
|
-
Puppeteer : {
|
|
94
|
-
url: "http://localhost",
|
|
95
|
-
restart: false,
|
|
96
|
-
waitForNavigation: [ "domcontentloaded", "networkidle0" ],
|
|
97
|
-
waitForAction: 500
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
#### Example #3: Debug in window mode
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
{
|
|
107
|
-
helpers: {
|
|
108
|
-
Puppeteer : {
|
|
109
|
-
url: "http://localhost",
|
|
110
|
-
show: true
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### Example #4: Connect to remote browser by specifying [websocket endpoint][3]
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
{
|
|
120
|
-
helpers: {
|
|
121
|
-
Puppeteer: {
|
|
122
|
-
url: "http://localhost",
|
|
123
|
-
chrome: {
|
|
124
|
-
browserWSEndpoint: "ws://localhost:9222/devtools/browser/c5aa6160-b5bc-4d53-bb49-6ecb36cd2e0a"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
> Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
132
|
-
|
|
133
|
-
#### Example #5: Target URL with provided basic authentication
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
{
|
|
137
|
-
helpers: {
|
|
138
|
-
Puppeteer : {
|
|
139
|
-
url: 'http://localhost',
|
|
140
|
-
basicAuth: {username: 'username', password: 'password'},
|
|
141
|
-
show: true
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Troubleshooting
|
|
148
|
-
|
|
149
|
-
Error Message: `No usable sandbox!`
|
|
150
|
-
|
|
151
|
-
When running Puppeteer on CI try to disable sandbox if you see that message
|
|
152
|
-
|
|
153
|
-
helpers: {
|
|
154
|
-
Puppeteer: {
|
|
155
|
-
url: 'http://localhost',
|
|
156
|
-
show: false,
|
|
157
|
-
chrome: {
|
|
158
|
-
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
## Access From Helpers
|
|
164
|
-
|
|
165
|
-
Receive Puppeteer client from a custom helper by accessing `browser` for the Browser object or `page` for the current Page object:
|
|
166
|
-
|
|
167
|
-
```js
|
|
168
|
-
const { browser } = this.helpers.Puppeteer;
|
|
169
|
-
await browser.pages(); // List of pages in the browser
|
|
170
|
-
|
|
171
|
-
const { page } = this.helpers.Puppeteer;
|
|
172
|
-
await page.url(); // Get the url of the current page
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Methods
|
|
176
|
-
|
|
177
|
-
### Parameters
|
|
178
|
-
|
|
179
|
-
- `config`
|
|
180
|
-
|
|
181
|
-
### _addPopupListener
|
|
182
|
-
|
|
183
|
-
Add the 'dialog' event listener to a page
|
|
184
|
-
|
|
185
|
-
#### Parameters
|
|
186
|
-
|
|
187
|
-
- `page`
|
|
188
|
-
|
|
189
|
-
### _getPageUrl
|
|
190
|
-
|
|
191
|
-
Gets page URL including hash.
|
|
192
|
-
|
|
193
|
-
### _locate
|
|
194
|
-
|
|
195
|
-
Get elements by different locator types, including strict locator
|
|
196
|
-
Should be used in custom helpers:
|
|
197
|
-
|
|
198
|
-
```js
|
|
199
|
-
const elements = await this.helpers['Puppeteer']._locate({name: 'password'});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
#### Parameters
|
|
209
|
-
|
|
210
|
-
- `locator`
|
|
211
|
-
|
|
212
|
-
### _locateCheckable
|
|
213
|
-
|
|
214
|
-
Find a checkbox by providing human-readable text:
|
|
215
|
-
NOTE: Assumes the checkable element exists
|
|
216
|
-
|
|
217
|
-
```js
|
|
218
|
-
this.helpers['Puppeteer']._locateCheckable('I agree with terms and conditions').then // ...
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
#### Parameters
|
|
222
|
-
|
|
223
|
-
- `locator`
|
|
224
|
-
- `providedContext`
|
|
225
|
-
|
|
226
|
-
### _locateClickable
|
|
227
|
-
|
|
228
|
-
Find a clickable element by providing human-readable text:
|
|
229
|
-
|
|
230
|
-
```js
|
|
231
|
-
this.helpers['Puppeteer']._locateClickable('Next page').then // ...
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
#### Parameters
|
|
235
|
-
|
|
236
|
-
- `locator`
|
|
237
|
-
|
|
238
|
-
### _locateFields
|
|
239
|
-
|
|
240
|
-
Find field elements by providing human-readable text:
|
|
241
|
-
|
|
242
|
-
```js
|
|
243
|
-
this.helpers['Puppeteer']._locateFields('Your email').then // ...
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
#### Parameters
|
|
247
|
-
|
|
248
|
-
- `locator`
|
|
249
|
-
|
|
250
|
-
### _setPage
|
|
251
|
-
|
|
252
|
-
Set current page
|
|
253
|
-
|
|
254
|
-
#### Parameters
|
|
255
|
-
|
|
256
|
-
- `page` **[object][4]** page to set
|
|
257
|
-
|
|
258
|
-
### acceptPopup
|
|
259
|
-
|
|
260
|
-
Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
|
|
261
|
-
Don't confuse popups with modal windows, as created by [various
|
|
262
|
-
libraries][5].
|
|
263
|
-
|
|
264
|
-
### amAcceptingPopups
|
|
265
|
-
|
|
266
|
-
Set the automatic popup response to Accept.
|
|
267
|
-
This must be set before a popup is triggered.
|
|
268
|
-
|
|
269
|
-
```js
|
|
270
|
-
I.amAcceptingPopups();
|
|
271
|
-
I.click('#triggerPopup');
|
|
272
|
-
I.acceptPopup();
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### amCancellingPopups
|
|
276
|
-
|
|
277
|
-
Set the automatic popup response to Cancel/Dismiss.
|
|
278
|
-
This must be set before a popup is triggered.
|
|
279
|
-
|
|
280
|
-
```js
|
|
281
|
-
I.amCancellingPopups();
|
|
282
|
-
I.click('#triggerPopup');
|
|
283
|
-
I.cancelPopup();
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### amOnPage
|
|
287
|
-
|
|
288
|
-
Opens a web page in a browser. Requires relative or absolute url.
|
|
289
|
-
If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
290
|
-
|
|
291
|
-
```js
|
|
292
|
-
I.amOnPage('/'); // opens main page of website
|
|
293
|
-
I.amOnPage('https://github.com'); // opens github
|
|
294
|
-
I.amOnPage('/login'); // opens a login page
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
#### Parameters
|
|
298
|
-
|
|
299
|
-
- `url` **[string][6]** url path or global url.
|
|
300
|
-
|
|
301
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
302
|
-
|
|
303
|
-
### appendField
|
|
304
|
-
|
|
305
|
-
Appends text to a input field or textarea.
|
|
306
|
-
Field is located by name, label, CSS or XPath
|
|
307
|
-
|
|
308
|
-
```js
|
|
309
|
-
I.appendField('#myTextField', 'appended');
|
|
310
|
-
// typing secret
|
|
311
|
-
I.appendField('password', secret('123456'));
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
#### Parameters
|
|
315
|
-
|
|
316
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator
|
|
317
|
-
- `value` **[string][6]** text value to append.
|
|
318
|
-
|
|
319
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
### attachFile
|
|
326
|
-
|
|
327
|
-
> ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][7], downgrade to 2.0.0 if you face it.
|
|
328
|
-
|
|
329
|
-
Attaches a file to element located by label, name, CSS or XPath
|
|
330
|
-
Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
|
|
331
|
-
File will be uploaded to remote system (if tests are running remotely).
|
|
332
|
-
|
|
333
|
-
```js
|
|
334
|
-
I.attachFile('Avatar', 'data/avatar.jpg');
|
|
335
|
-
I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
#### Parameters
|
|
339
|
-
|
|
340
|
-
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
341
|
-
- `pathToFile` **[string][6]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
342
|
-
|
|
343
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
344
|
-
|
|
345
|
-
### blur
|
|
346
|
-
|
|
347
|
-
Remove focus from a text input, button, etc.
|
|
348
|
-
Calls [blur][8] on the element.
|
|
349
|
-
|
|
350
|
-
Examples:
|
|
351
|
-
|
|
352
|
-
```js
|
|
353
|
-
I.blur('.text-area')
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
```js
|
|
357
|
-
//element `#product-tile` is focused
|
|
358
|
-
I.see('#add-to-cart-btn');
|
|
359
|
-
I.blur('#product-tile')
|
|
360
|
-
I.dontSee('#add-to-cart-btn');
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
#### Parameters
|
|
364
|
-
|
|
365
|
-
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
366
|
-
- `options` **any?** Playwright only: [Additional options][9] for available options object as 2nd argument.
|
|
367
|
-
|
|
368
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
369
|
-
|
|
370
|
-
### cancelPopup
|
|
371
|
-
|
|
372
|
-
Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
|
|
373
|
-
|
|
374
|
-
### checkOption
|
|
375
|
-
|
|
376
|
-
Selects a checkbox or radio button.
|
|
377
|
-
Element is located by label or name or CSS or XPath.
|
|
378
|
-
|
|
379
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
380
|
-
|
|
381
|
-
```js
|
|
382
|
-
I.checkOption('#agree');
|
|
383
|
-
I.checkOption('I Agree to Terms and Conditions');
|
|
384
|
-
I.checkOption('agree', '//form');
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
#### Parameters
|
|
388
|
-
|
|
389
|
-
- `field` **([string][6] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
390
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
391
|
-
|
|
392
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
393
|
-
|
|
394
|
-
### clearCookie
|
|
395
|
-
|
|
396
|
-
Clears a cookie by name,
|
|
397
|
-
if none provided clears all cookies.
|
|
398
|
-
|
|
399
|
-
```js
|
|
400
|
-
I.clearCookie();
|
|
401
|
-
I.clearCookie('test'); // Playwright currently doesn't support clear a particular cookie name
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
#### Parameters
|
|
405
|
-
|
|
406
|
-
- `name`
|
|
407
|
-
- `cookie` **[string][6]?** (optional, `null` by default) cookie name
|
|
408
|
-
|
|
409
|
-
### clearField
|
|
410
|
-
|
|
411
|
-
Clears a `<textarea>` or text `<input>` element's value.
|
|
412
|
-
|
|
413
|
-
```js
|
|
414
|
-
I.clearField('Email');
|
|
415
|
-
I.clearField('user[email]');
|
|
416
|
-
I.clearField('#email');
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
#### Parameters
|
|
420
|
-
|
|
421
|
-
- `field`
|
|
422
|
-
- `editable` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
423
|
-
|
|
424
|
-
Returns **void** automatically synchronized promise through #recorder.
|
|
425
|
-
|
|
426
|
-
### click
|
|
427
|
-
|
|
428
|
-
Perform a click on a link or a button, given by a locator.
|
|
429
|
-
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
430
|
-
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
431
|
-
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
432
|
-
|
|
433
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
434
|
-
|
|
435
|
-
```js
|
|
436
|
-
// simple link
|
|
437
|
-
I.click('Logout');
|
|
438
|
-
// button of form
|
|
439
|
-
I.click('Submit');
|
|
440
|
-
// CSS button
|
|
441
|
-
I.click('#form input[type=submit]');
|
|
442
|
-
// XPath
|
|
443
|
-
I.click('//form/*[@type=submit]');
|
|
444
|
-
// link in context
|
|
445
|
-
I.click('Logout', '#nav');
|
|
446
|
-
// using strict locator
|
|
447
|
-
I.click({css: 'nav a.login'});
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
#### Parameters
|
|
451
|
-
|
|
452
|
-
- `locator` **([string][6] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
453
|
-
- `context` **([string][6]? | [object][4] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
454
|
-
|
|
455
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
### clickLink
|
|
462
|
-
|
|
463
|
-
Performs a click on a link and waits for navigation before moving on.
|
|
464
|
-
|
|
465
|
-
```js
|
|
466
|
-
I.clickLink('Logout', '#nav');
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
#### Parameters
|
|
470
|
-
|
|
471
|
-
- `locator` **([string][6] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator
|
|
472
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator
|
|
473
|
-
|
|
474
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
### closeCurrentTab
|
|
481
|
-
|
|
482
|
-
Close current tab and switches to previous.
|
|
483
|
-
|
|
484
|
-
```js
|
|
485
|
-
I.closeCurrentTab();
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
### closeOtherTabs
|
|
489
|
-
|
|
490
|
-
Close all tabs except for the current one.
|
|
491
|
-
|
|
492
|
-
```js
|
|
493
|
-
I.closeOtherTabs();
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
### dontSee
|
|
497
|
-
|
|
498
|
-
Opposite to `see`. Checks that a text is not present on a page.
|
|
499
|
-
Use context parameter to narrow down the search.
|
|
500
|
-
|
|
501
|
-
```js
|
|
502
|
-
I.dontSee('Login'); // assume we are already logged in.
|
|
503
|
-
I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
#### Parameters
|
|
507
|
-
|
|
508
|
-
- `text` **[string][6]** which is not present.
|
|
509
|
-
- `context` **([string][6] | [object][4])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
510
|
-
|
|
511
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
### dontSeeCheckboxIsChecked
|
|
518
|
-
|
|
519
|
-
Verifies that the specified checkbox is not checked.
|
|
520
|
-
|
|
521
|
-
```js
|
|
522
|
-
I.dontSeeCheckboxIsChecked('#agree'); // located by ID
|
|
523
|
-
I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
524
|
-
I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
#### Parameters
|
|
528
|
-
|
|
529
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
530
|
-
|
|
531
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
532
|
-
|
|
533
|
-
### dontSeeCookie
|
|
534
|
-
|
|
535
|
-
Checks that cookie with given name does not exist.
|
|
536
|
-
|
|
537
|
-
```js
|
|
538
|
-
I.dontSeeCookie('auth'); // no auth cookie
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
#### Parameters
|
|
542
|
-
|
|
543
|
-
- `name` **[string][6]** cookie name.
|
|
544
|
-
|
|
545
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
546
|
-
|
|
547
|
-
### dontSeeCurrentUrlEquals
|
|
548
|
-
|
|
549
|
-
Checks that current url is not equal to provided one.
|
|
550
|
-
If a relative url provided, a configured url will be prepended to it.
|
|
551
|
-
|
|
552
|
-
```js
|
|
553
|
-
I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
|
|
554
|
-
I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
#### Parameters
|
|
558
|
-
|
|
559
|
-
- `url` **[string][6]** value to check.
|
|
560
|
-
|
|
561
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
562
|
-
|
|
563
|
-
### dontSeeElement
|
|
564
|
-
|
|
565
|
-
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
566
|
-
|
|
567
|
-
```js
|
|
568
|
-
I.dontSeeElement('.modal'); // modal is not shown
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
#### Parameters
|
|
572
|
-
|
|
573
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|Strict locator.
|
|
574
|
-
|
|
575
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
### dontSeeElementInDOM
|
|
582
|
-
|
|
583
|
-
Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
584
|
-
|
|
585
|
-
```js
|
|
586
|
-
I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
#### Parameters
|
|
590
|
-
|
|
591
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|Strict locator.
|
|
592
|
-
|
|
593
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
594
|
-
|
|
595
|
-
### dontSeeInCurrentUrl
|
|
596
|
-
|
|
597
|
-
Checks that current url does not contain a provided fragment.
|
|
598
|
-
|
|
599
|
-
#### Parameters
|
|
600
|
-
|
|
601
|
-
- `url` **[string][6]** value to check.
|
|
602
|
-
|
|
603
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
604
|
-
|
|
605
|
-
### dontSeeInField
|
|
606
|
-
|
|
607
|
-
Checks that value of input field or textarea doesn't equal to given value
|
|
608
|
-
Opposite to `seeInField`.
|
|
609
|
-
|
|
610
|
-
```js
|
|
611
|
-
I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
612
|
-
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
#### Parameters
|
|
616
|
-
|
|
617
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
618
|
-
- `value` **([string][6] | [object][4])** value to check.
|
|
619
|
-
|
|
620
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
621
|
-
|
|
622
|
-
### dontSeeInSource
|
|
623
|
-
|
|
624
|
-
Checks that the current page does not contains the given string in its raw source code.
|
|
625
|
-
|
|
626
|
-
```js
|
|
627
|
-
I.dontSeeInSource('<!--'); // no comments in source
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
#### Parameters
|
|
631
|
-
|
|
632
|
-
- `text`
|
|
633
|
-
- `value` **[string][6]** to check.
|
|
634
|
-
|
|
635
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
636
|
-
|
|
637
|
-
### dontSeeInTitle
|
|
638
|
-
|
|
639
|
-
Checks that title does not contain text.
|
|
640
|
-
|
|
641
|
-
```js
|
|
642
|
-
I.dontSeeInTitle('Error');
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
#### Parameters
|
|
646
|
-
|
|
647
|
-
- `text` **[string][6]** value to check.
|
|
648
|
-
|
|
649
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
650
|
-
|
|
651
|
-
### doubleClick
|
|
652
|
-
|
|
653
|
-
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
654
|
-
Context can be specified as second parameter to narrow search.
|
|
655
|
-
|
|
656
|
-
```js
|
|
657
|
-
I.doubleClick('Edit');
|
|
658
|
-
I.doubleClick('Edit', '.actions');
|
|
659
|
-
I.doubleClick({css: 'button.accept'});
|
|
660
|
-
I.doubleClick('.btn.edit');
|
|
661
|
-
```
|
|
662
|
-
|
|
663
|
-
#### Parameters
|
|
664
|
-
|
|
665
|
-
- `locator` **([string][6] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
666
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
667
|
-
|
|
668
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
### downloadFile
|
|
675
|
-
|
|
676
|
-
This method is **deprecated**.
|
|
677
|
-
|
|
678
|
-
Please use `handleDownloads()` instead.
|
|
679
|
-
|
|
680
|
-
#### Parameters
|
|
681
|
-
|
|
682
|
-
- `locator`
|
|
683
|
-
- `customName`
|
|
684
|
-
|
|
685
|
-
### dragAndDrop
|
|
686
|
-
|
|
687
|
-
Drag an item to a destination element.
|
|
688
|
-
|
|
689
|
-
```js
|
|
690
|
-
I.dragAndDrop('#dragHandle', '#container');
|
|
691
|
-
```
|
|
692
|
-
|
|
693
|
-
#### Parameters
|
|
694
|
-
|
|
695
|
-
- `srcElement` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
696
|
-
- `destElement` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
697
|
-
|
|
698
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
699
|
-
|
|
700
|
-
### dragSlider
|
|
701
|
-
|
|
702
|
-
Drag the scrubber of a slider to a given position
|
|
703
|
-
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
704
|
-
|
|
705
|
-
```js
|
|
706
|
-
I.dragSlider('#slider', 30);
|
|
707
|
-
I.dragSlider('#slider', -70);
|
|
708
|
-
```
|
|
709
|
-
|
|
710
|
-
#### Parameters
|
|
711
|
-
|
|
712
|
-
- `locator` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
713
|
-
- `offsetX` **[number][10]** position to drag.
|
|
714
|
-
|
|
715
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
### executeAsyncScript
|
|
722
|
-
|
|
723
|
-
Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
|
|
724
|
-
Executes async script on page.
|
|
725
|
-
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
726
|
-
|
|
727
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][11].
|
|
728
|
-
|
|
729
|
-
```js
|
|
730
|
-
I.executeAsyncScript(function(done) {
|
|
731
|
-
Vue.nextTick(done); // waiting for next tick
|
|
732
|
-
});
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
By passing value to `done()` function you can return values.
|
|
736
|
-
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
|
|
737
|
-
|
|
738
|
-
```js
|
|
739
|
-
let val = await I.executeAsyncScript(function(url, done) {
|
|
740
|
-
// in browser context
|
|
741
|
-
$.ajax(url, { success: (data) => done(data); }
|
|
742
|
-
}, 'http://ajax.callback.url/');
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
#### Parameters
|
|
746
|
-
|
|
747
|
-
- `args` **...any** to be passed to function.
|
|
748
|
-
- `fn` **([string][6] | [function][12])** function to be executed in browser context.
|
|
749
|
-
|
|
750
|
-
Returns **[Promise][13]<any>** script return value
|
|
751
|
-
|
|
752
|
-
### executeScript
|
|
753
|
-
|
|
754
|
-
If a function returns a Promise, tt will wait for its resolution.
|
|
755
|
-
|
|
756
|
-
Executes sync script on a page.
|
|
757
|
-
Pass arguments to function as additional parameters.
|
|
758
|
-
Will return execution result to a test.
|
|
759
|
-
In this case you should use async function and await to receive results.
|
|
760
|
-
|
|
761
|
-
Example with jQuery DatePicker:
|
|
762
|
-
|
|
763
|
-
```js
|
|
764
|
-
// change date of jQuery DatePicker
|
|
765
|
-
I.executeScript(function() {
|
|
766
|
-
// now we are inside browser context
|
|
767
|
-
$('date').datetimepicker('setDate', new Date());
|
|
768
|
-
});
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
Can return values. Don't forget to use `await` to get them.
|
|
772
|
-
|
|
773
|
-
```js
|
|
774
|
-
let date = await I.executeScript(function(el) {
|
|
775
|
-
// only basic types can be returned
|
|
776
|
-
return $(el).datetimepicker('getDate').toString();
|
|
777
|
-
}, '#date'); // passing jquery selector
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
#### Parameters
|
|
781
|
-
|
|
782
|
-
- `args` **...any** to be passed to function.
|
|
783
|
-
- `fn` **([string][6] | [function][12])** function to be executed in browser context.
|
|
784
|
-
|
|
785
|
-
Returns **[Promise][13]<any>** script return value
|
|
786
|
-
|
|
787
|
-
### fillField
|
|
788
|
-
|
|
789
|
-
Fills a text field or textarea, after clearing its value, with the given string.
|
|
790
|
-
Field is located by name, label, CSS, or XPath.
|
|
791
|
-
|
|
792
|
-
```js
|
|
793
|
-
// by label
|
|
794
|
-
I.fillField('Email', 'hello@world.com');
|
|
795
|
-
// by name
|
|
796
|
-
I.fillField('password', secret('123456'));
|
|
797
|
-
// by CSS
|
|
798
|
-
I.fillField('form#login input[name=username]', 'John');
|
|
799
|
-
// or by strict locator
|
|
800
|
-
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
801
|
-
```
|
|
802
|
-
|
|
803
|
-
#### Parameters
|
|
804
|
-
|
|
805
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
806
|
-
- `value` **([string][6] | [object][4])** text value to fill.
|
|
807
|
-
|
|
808
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
### focus
|
|
815
|
-
|
|
816
|
-
Calls [focus][8] on the matching element.
|
|
817
|
-
|
|
818
|
-
Examples:
|
|
819
|
-
|
|
820
|
-
```js
|
|
821
|
-
I.dontSee('#add-to-cart-btn');
|
|
822
|
-
I.focus('#product-tile')
|
|
823
|
-
I.see('#add-to-cart-bnt');
|
|
824
|
-
```
|
|
825
|
-
|
|
826
|
-
#### Parameters
|
|
827
|
-
|
|
828
|
-
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
829
|
-
- `options` **any?** Playwright only: [Additional options][14] for available options object as 2nd argument.
|
|
830
|
-
|
|
831
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
832
|
-
|
|
833
|
-
### forceClick
|
|
834
|
-
|
|
835
|
-
Perform an emulated click on a link or a button, given by a locator.
|
|
836
|
-
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
837
|
-
This works on hidden, animated or inactive elements as well.
|
|
838
|
-
|
|
839
|
-
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
840
|
-
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
841
|
-
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
842
|
-
|
|
843
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
844
|
-
|
|
845
|
-
```js
|
|
846
|
-
// simple link
|
|
847
|
-
I.forceClick('Logout');
|
|
848
|
-
// button of form
|
|
849
|
-
I.forceClick('Submit');
|
|
850
|
-
// CSS button
|
|
851
|
-
I.forceClick('#form input[type=submit]');
|
|
852
|
-
// XPath
|
|
853
|
-
I.forceClick('//form/*[@type=submit]');
|
|
854
|
-
// link in context
|
|
855
|
-
I.forceClick('Logout', '#nav');
|
|
856
|
-
// using strict locator
|
|
857
|
-
I.forceClick({css: 'nav a.login'});
|
|
858
|
-
```
|
|
859
|
-
|
|
860
|
-
#### Parameters
|
|
861
|
-
|
|
862
|
-
- `locator` **([string][6] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
863
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
864
|
-
|
|
865
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
### grabAttributeFrom
|
|
872
|
-
|
|
873
|
-
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
874
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
875
|
-
If more than one element is found - attribute of first element is returned.
|
|
876
|
-
|
|
877
|
-
```js
|
|
878
|
-
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
879
|
-
```
|
|
880
|
-
|
|
881
|
-
#### Parameters
|
|
882
|
-
|
|
883
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
884
|
-
- `attr` **[string][6]** attribute name.
|
|
885
|
-
|
|
886
|
-
Returns **[Promise][13]<[string][6]>** attribute value
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
### grabAttributeFromAll
|
|
893
|
-
|
|
894
|
-
Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
|
|
895
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
896
|
-
|
|
897
|
-
```js
|
|
898
|
-
let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
899
|
-
```
|
|
900
|
-
|
|
901
|
-
#### Parameters
|
|
902
|
-
|
|
903
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
904
|
-
- `attr` **[string][6]** attribute name.
|
|
905
|
-
|
|
906
|
-
Returns **[Promise][13]<[Array][15]<[string][6]>>** attribute value
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
### grabBrowserLogs
|
|
913
|
-
|
|
914
|
-
Get JS log from browser.
|
|
915
|
-
|
|
916
|
-
```js
|
|
917
|
-
let logs = await I.grabBrowserLogs();
|
|
918
|
-
console.log(JSON.stringify(logs))
|
|
919
|
-
```
|
|
920
|
-
|
|
921
|
-
Returns **[Promise][13]<[Array][15]<any>>**
|
|
922
|
-
|
|
923
|
-
### grabCookie
|
|
924
|
-
|
|
925
|
-
Gets a cookie object by name.
|
|
926
|
-
If none provided gets all cookies.
|
|
927
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
928
|
-
|
|
929
|
-
```js
|
|
930
|
-
let cookie = await I.grabCookie('auth');
|
|
931
|
-
assert(cookie.value, '123456');
|
|
932
|
-
```
|
|
933
|
-
|
|
934
|
-
#### Parameters
|
|
935
|
-
|
|
936
|
-
- `name` **[string][6]?** cookie name.
|
|
937
|
-
|
|
938
|
-
Returns **any** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
939
|
-
|
|
940
|
-
### grabCssPropertyFrom
|
|
941
|
-
|
|
942
|
-
Grab CSS property for given locator
|
|
943
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
944
|
-
If more than one element is found - value of first element is returned.
|
|
945
|
-
|
|
946
|
-
```js
|
|
947
|
-
const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
#### Parameters
|
|
951
|
-
|
|
952
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
953
|
-
- `cssProperty` **[string][6]** CSS property name.
|
|
954
|
-
|
|
955
|
-
Returns **[Promise][13]<[string][6]>** CSS value
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
### grabCssPropertyFromAll
|
|
962
|
-
|
|
963
|
-
Grab array of CSS properties for given locator
|
|
964
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
965
|
-
|
|
966
|
-
```js
|
|
967
|
-
const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
968
|
-
```
|
|
969
|
-
|
|
970
|
-
#### Parameters
|
|
971
|
-
|
|
972
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
973
|
-
- `cssProperty` **[string][6]** CSS property name.
|
|
974
|
-
|
|
975
|
-
Returns **[Promise][13]<[Array][15]<[string][6]>>** CSS value
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
### grabCurrentUrl
|
|
982
|
-
|
|
983
|
-
Get current URL from browser.
|
|
984
|
-
Resumes test execution, so should be used inside an async function.
|
|
985
|
-
|
|
986
|
-
```js
|
|
987
|
-
let url = await I.grabCurrentUrl();
|
|
988
|
-
console.log(`Current URL is [${url}]`);
|
|
989
|
-
```
|
|
990
|
-
|
|
991
|
-
Returns **[Promise][13]<[string][6]>** current URL
|
|
992
|
-
|
|
993
|
-
### grabDataFromPerformanceTiming
|
|
994
|
-
|
|
995
|
-
Grab the data from performance timing using Navigation Timing API.
|
|
996
|
-
The returned data will contain following things in ms:
|
|
997
|
-
|
|
998
|
-
- responseEnd,
|
|
999
|
-
- domInteractive,
|
|
1000
|
-
- domContentLoadedEventEnd,
|
|
1001
|
-
- loadEventEnd
|
|
1002
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1003
|
-
|
|
1004
|
-
```js
|
|
1005
|
-
await I.amOnPage('https://example.com');
|
|
1006
|
-
let data = await I.grabDataFromPerformanceTiming();
|
|
1007
|
-
//Returned data
|
|
1008
|
-
{ // all results are in [ms]
|
|
1009
|
-
responseEnd: 23,
|
|
1010
|
-
domInteractive: 44,
|
|
1011
|
-
domContentLoadedEventEnd: 196,
|
|
1012
|
-
loadEventEnd: 241
|
|
1013
|
-
}
|
|
1014
|
-
```
|
|
1015
|
-
|
|
1016
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1017
|
-
|
|
1018
|
-
### grabElementBoundingRect
|
|
1019
|
-
|
|
1020
|
-
Grab the width, height, location of given locator.
|
|
1021
|
-
Provide `width` or `height`as second param to get your desired prop.
|
|
1022
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1023
|
-
|
|
1024
|
-
Returns an object with `x`, `y`, `width`, `height` keys.
|
|
1025
|
-
|
|
1026
|
-
```js
|
|
1027
|
-
const value = await I.grabElementBoundingRect('h3');
|
|
1028
|
-
// value is like { x: 226.5, y: 89, width: 527, height: 220 }
|
|
1029
|
-
```
|
|
1030
|
-
|
|
1031
|
-
To get only one metric use second parameter:
|
|
1032
|
-
|
|
1033
|
-
```js
|
|
1034
|
-
const width = await I.grabElementBoundingRect('h3', 'width');
|
|
1035
|
-
// width == 527
|
|
1036
|
-
```
|
|
1037
|
-
|
|
1038
|
-
#### Parameters
|
|
1039
|
-
|
|
1040
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1041
|
-
- `prop`
|
|
1042
|
-
- `elementSize` **[string][6]?** x, y, width or height of the given element.
|
|
1043
|
-
|
|
1044
|
-
Returns **([Promise][13]<DOMRect> | [Promise][13]<[number][10]>)** Element bounding rectangle
|
|
1045
|
-
|
|
1046
|
-
### grabHTMLFrom
|
|
1047
|
-
|
|
1048
|
-
Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
1049
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1050
|
-
If more than one element is found - HTML of first element is returned.
|
|
1051
|
-
|
|
1052
|
-
```js
|
|
1053
|
-
let postHTML = await I.grabHTMLFrom('#post');
|
|
1054
|
-
```
|
|
1055
|
-
|
|
1056
|
-
#### Parameters
|
|
1057
|
-
|
|
1058
|
-
- `locator`
|
|
1059
|
-
- `element` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1060
|
-
|
|
1061
|
-
Returns **[Promise][13]<[string][6]>** HTML code for an element
|
|
1062
|
-
|
|
1063
|
-
### grabHTMLFromAll
|
|
1064
|
-
|
|
1065
|
-
Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
|
|
1066
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1067
|
-
|
|
1068
|
-
```js
|
|
1069
|
-
let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
1070
|
-
```
|
|
1071
|
-
|
|
1072
|
-
#### Parameters
|
|
1073
|
-
|
|
1074
|
-
- `locator`
|
|
1075
|
-
- `element` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1076
|
-
|
|
1077
|
-
Returns **[Promise][13]<[Array][15]<[string][6]>>** HTML code for an element
|
|
1078
|
-
|
|
1079
|
-
### grabNumberOfOpenTabs
|
|
1080
|
-
|
|
1081
|
-
Grab number of open tabs.
|
|
1082
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1083
|
-
|
|
1084
|
-
```js
|
|
1085
|
-
let tabs = await I.grabNumberOfOpenTabs();
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
Returns **[Promise][13]<[number][10]>** number of open tabs
|
|
1089
|
-
|
|
1090
|
-
### grabNumberOfVisibleElements
|
|
1091
|
-
|
|
1092
|
-
Grab number of visible elements by locator.
|
|
1093
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1094
|
-
|
|
1095
|
-
```js
|
|
1096
|
-
let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1097
|
-
```
|
|
1098
|
-
|
|
1099
|
-
#### Parameters
|
|
1100
|
-
|
|
1101
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1102
|
-
|
|
1103
|
-
Returns **[Promise][13]<[number][10]>** number of visible elements
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
### grabPageScrollPosition
|
|
1111
|
-
|
|
1112
|
-
Retrieves a page scroll position and returns it to test.
|
|
1113
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1114
|
-
|
|
1115
|
-
```js
|
|
1116
|
-
let { x, y } = await I.grabPageScrollPosition();
|
|
1117
|
-
```
|
|
1118
|
-
|
|
1119
|
-
Returns **[Promise][13]<PageScrollPosition>** scroll position
|
|
1120
|
-
|
|
1121
|
-
### grabPopupText
|
|
1122
|
-
|
|
1123
|
-
Grab the text within the popup. If no popup is visible then it will return null
|
|
1124
|
-
|
|
1125
|
-
```js
|
|
1126
|
-
await I.grabPopupText();
|
|
1127
|
-
```
|
|
1128
|
-
|
|
1129
|
-
Returns **[Promise][13]<([string][6] | null)>**
|
|
1130
|
-
|
|
1131
|
-
### grabSource
|
|
1132
|
-
|
|
1133
|
-
Retrieves page source and returns it to test.
|
|
1134
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1135
|
-
|
|
1136
|
-
```js
|
|
1137
|
-
let pageSource = await I.grabSource();
|
|
1138
|
-
```
|
|
1139
|
-
|
|
1140
|
-
Returns **[Promise][13]<[string][6]>** source code
|
|
1141
|
-
|
|
1142
|
-
### grabTextFrom
|
|
1143
|
-
|
|
1144
|
-
Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
1145
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1146
|
-
|
|
1147
|
-
```js
|
|
1148
|
-
let pin = await I.grabTextFrom('#pin');
|
|
1149
|
-
```
|
|
1150
|
-
|
|
1151
|
-
If multiple elements found returns first element.
|
|
1152
|
-
|
|
1153
|
-
#### Parameters
|
|
1154
|
-
|
|
1155
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1156
|
-
|
|
1157
|
-
Returns **[Promise][13]<[string][6]>** attribute value
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
### grabTextFromAll
|
|
1164
|
-
|
|
1165
|
-
Retrieves all texts from an element located by CSS or XPath and returns it to test.
|
|
1166
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1167
|
-
|
|
1168
|
-
```js
|
|
1169
|
-
let pins = await I.grabTextFromAll('#pin li');
|
|
1170
|
-
```
|
|
1171
|
-
|
|
1172
|
-
#### Parameters
|
|
1173
|
-
|
|
1174
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1175
|
-
|
|
1176
|
-
Returns **[Promise][13]<[Array][15]<[string][6]>>** attribute value
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
### grabTitle
|
|
1183
|
-
|
|
1184
|
-
Retrieves a page title and returns it to test.
|
|
1185
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1186
|
-
|
|
1187
|
-
```js
|
|
1188
|
-
let title = await I.grabTitle();
|
|
1189
|
-
```
|
|
1190
|
-
|
|
1191
|
-
Returns **[Promise][13]<[string][6]>** title
|
|
1192
|
-
|
|
1193
|
-
### grabValueFrom
|
|
1194
|
-
|
|
1195
|
-
Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
1196
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1197
|
-
If more than one element is found - value of first element is returned.
|
|
1198
|
-
|
|
1199
|
-
```js
|
|
1200
|
-
let email = await I.grabValueFrom('input[name=email]');
|
|
1201
|
-
```
|
|
1202
|
-
|
|
1203
|
-
#### Parameters
|
|
1204
|
-
|
|
1205
|
-
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1206
|
-
|
|
1207
|
-
Returns **[Promise][13]<[string][6]>** attribute value
|
|
1208
|
-
|
|
1209
|
-
### grabValueFromAll
|
|
1210
|
-
|
|
1211
|
-
Retrieves an array of value from a form located by CSS or XPath and returns it to test.
|
|
1212
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1213
|
-
|
|
1214
|
-
```js
|
|
1215
|
-
let inputs = await I.grabValueFromAll('//form/input');
|
|
1216
|
-
```
|
|
1217
|
-
|
|
1218
|
-
#### Parameters
|
|
1219
|
-
|
|
1220
|
-
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1221
|
-
|
|
1222
|
-
Returns **[Promise][13]<[Array][15]<[string][6]>>** attribute value
|
|
1223
|
-
|
|
1224
|
-
### grabWebElements
|
|
1225
|
-
|
|
1226
|
-
Grab WebElements for given locator
|
|
1227
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1228
|
-
|
|
1229
|
-
```js
|
|
1230
|
-
const webElements = await I.grabWebElements('#button');
|
|
1231
|
-
```
|
|
1232
|
-
|
|
1233
|
-
#### Parameters
|
|
1234
|
-
|
|
1235
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1236
|
-
|
|
1237
|
-
Returns **[Promise][13]<any>** WebElement of being used Web helper
|
|
1238
|
-
|
|
1239
|
-
### handleDownloads
|
|
1240
|
-
|
|
1241
|
-
Sets a directory to where save files. Allows to test file downloads.
|
|
1242
|
-
Should be used with [FileSystem helper][16] to check that file were downloaded correctly.
|
|
1243
|
-
|
|
1244
|
-
By default, files are saved to `output/downloads`.
|
|
1245
|
-
This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
|
|
1246
|
-
|
|
1247
|
-
```js
|
|
1248
|
-
I.handleDownloads();
|
|
1249
|
-
I.click('Download Avatar');
|
|
1250
|
-
I.amInPath('output/downloads');
|
|
1251
|
-
I.seeFile('avatar.jpg');
|
|
1252
|
-
```
|
|
1253
|
-
|
|
1254
|
-
#### Parameters
|
|
1255
|
-
|
|
1256
|
-
- `downloadPath` **[string][6]** change this parameter to set another directory for saving
|
|
1257
|
-
|
|
1258
|
-
### moveCursorTo
|
|
1259
|
-
|
|
1260
|
-
Moves cursor to element matched by locator.
|
|
1261
|
-
Extra shift can be set with offsetX and offsetY options.
|
|
1262
|
-
|
|
1263
|
-
```js
|
|
1264
|
-
I.moveCursorTo('.tooltip');
|
|
1265
|
-
I.moveCursorTo('#submit', 5,5);
|
|
1266
|
-
```
|
|
1267
|
-
|
|
1268
|
-
#### Parameters
|
|
1269
|
-
|
|
1270
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1271
|
-
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1272
|
-
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1273
|
-
|
|
1274
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
### openNewTab
|
|
1281
|
-
|
|
1282
|
-
Open new tab and switch to it
|
|
1283
|
-
|
|
1284
|
-
```js
|
|
1285
|
-
I.openNewTab();
|
|
1286
|
-
```
|
|
1287
|
-
|
|
1288
|
-
### pressKey
|
|
1289
|
-
|
|
1290
|
-
_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][17]).
|
|
1291
|
-
|
|
1292
|
-
Presses a key in the browser (on a focused element).
|
|
1293
|
-
|
|
1294
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][18].
|
|
1295
|
-
|
|
1296
|
-
```js
|
|
1297
|
-
I.pressKey('Backspace');
|
|
1298
|
-
```
|
|
1299
|
-
|
|
1300
|
-
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.
|
|
1301
|
-
|
|
1302
|
-
```js
|
|
1303
|
-
I.pressKey(['Control', 'Z']);
|
|
1304
|
-
```
|
|
1305
|
-
|
|
1306
|
-
For specifying operation modifier key based on operating system it is suggested to use `'CommandOrControl'`.
|
|
1307
|
-
This will press `'Command'` (also known as `'Meta'`) on macOS machines and `'Control'` on non-macOS machines.
|
|
1308
|
-
|
|
1309
|
-
```js
|
|
1310
|
-
I.pressKey(['CommandOrControl', 'Z']);
|
|
1311
|
-
```
|
|
1312
|
-
|
|
1313
|
-
Some of the supported key names are:
|
|
1314
|
-
|
|
1315
|
-
- `'AltLeft'` or `'Alt'`
|
|
1316
|
-
- `'AltRight'`
|
|
1317
|
-
- `'ArrowDown'`
|
|
1318
|
-
- `'ArrowLeft'`
|
|
1319
|
-
- `'ArrowRight'`
|
|
1320
|
-
- `'ArrowUp'`
|
|
1321
|
-
- `'Backspace'`
|
|
1322
|
-
- `'Clear'`
|
|
1323
|
-
- `'ControlLeft'` or `'Control'`
|
|
1324
|
-
- `'ControlRight'`
|
|
1325
|
-
- `'Command'`
|
|
1326
|
-
- `'CommandOrControl'`
|
|
1327
|
-
- `'Delete'`
|
|
1328
|
-
- `'End'`
|
|
1329
|
-
- `'Enter'`
|
|
1330
|
-
- `'Escape'`
|
|
1331
|
-
- `'F1'` to `'F12'`
|
|
1332
|
-
- `'Home'`
|
|
1333
|
-
- `'Insert'`
|
|
1334
|
-
- `'MetaLeft'` or `'Meta'`
|
|
1335
|
-
- `'MetaRight'`
|
|
1336
|
-
- `'Numpad0'` to `'Numpad9'`
|
|
1337
|
-
- `'NumpadAdd'`
|
|
1338
|
-
- `'NumpadDecimal'`
|
|
1339
|
-
- `'NumpadDivide'`
|
|
1340
|
-
- `'NumpadMultiply'`
|
|
1341
|
-
- `'NumpadSubtract'`
|
|
1342
|
-
- `'PageDown'`
|
|
1343
|
-
- `'PageUp'`
|
|
1344
|
-
- `'Pause'`
|
|
1345
|
-
- `'Return'`
|
|
1346
|
-
- `'ShiftLeft'` or `'Shift'`
|
|
1347
|
-
- `'ShiftRight'`
|
|
1348
|
-
- `'Space'`
|
|
1349
|
-
- `'Tab'`
|
|
1350
|
-
|
|
1351
|
-
#### Parameters
|
|
1352
|
-
|
|
1353
|
-
- `key` **([string][6] | [Array][15]<[string][6]>)** key or array of keys to press.
|
|
1354
|
-
|
|
1355
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1356
|
-
|
|
1357
|
-
### pressKeyDown
|
|
1358
|
-
|
|
1359
|
-
Presses a key in the browser and leaves it in a down state.
|
|
1360
|
-
|
|
1361
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][19]).
|
|
1362
|
-
|
|
1363
|
-
```js
|
|
1364
|
-
I.pressKeyDown('Control');
|
|
1365
|
-
I.click('#element');
|
|
1366
|
-
I.pressKeyUp('Control');
|
|
1367
|
-
```
|
|
1368
|
-
|
|
1369
|
-
#### Parameters
|
|
1370
|
-
|
|
1371
|
-
- `key` **[string][6]** name of key to press down.
|
|
1372
|
-
|
|
1373
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1374
|
-
|
|
1375
|
-
### pressKeyUp
|
|
1376
|
-
|
|
1377
|
-
Releases a key in the browser which was previously set to a down state.
|
|
1378
|
-
|
|
1379
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][19]).
|
|
1380
|
-
|
|
1381
|
-
```js
|
|
1382
|
-
I.pressKeyDown('Control');
|
|
1383
|
-
I.click('#element');
|
|
1384
|
-
I.pressKeyUp('Control');
|
|
1385
|
-
```
|
|
1386
|
-
|
|
1387
|
-
#### Parameters
|
|
1388
|
-
|
|
1389
|
-
- `key` **[string][6]** name of key to release.
|
|
1390
|
-
|
|
1391
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1392
|
-
|
|
1393
|
-
### refreshPage
|
|
1394
|
-
|
|
1395
|
-
Reload the current page.
|
|
1396
|
-
|
|
1397
|
-
```js
|
|
1398
|
-
I.refreshPage();
|
|
1399
|
-
```
|
|
1400
|
-
|
|
1401
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1402
|
-
|
|
1403
|
-
### resizeWindow
|
|
1404
|
-
|
|
1405
|
-
Unlike other drivers Puppeteer changes the size of a viewport, not the window!
|
|
1406
|
-
Puppeteer does not control the window of a browser, so it can't adjust its real size.
|
|
1407
|
-
It also can't maximize a window.
|
|
1408
|
-
|
|
1409
|
-
Resize the current window to provided width and height.
|
|
1410
|
-
First parameter can be set to `maximize`.
|
|
1411
|
-
|
|
1412
|
-
#### Parameters
|
|
1413
|
-
|
|
1414
|
-
- `width` **[number][10]** width in pixels or `maximize`.
|
|
1415
|
-
- `height` **[number][10]** height in pixels.
|
|
1416
|
-
|
|
1417
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1418
|
-
|
|
1419
|
-
### rightClick
|
|
1420
|
-
|
|
1421
|
-
Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
1422
|
-
|
|
1423
|
-
```js
|
|
1424
|
-
// right click element with id el
|
|
1425
|
-
I.rightClick('#el');
|
|
1426
|
-
// right click link or button with text "Click me"
|
|
1427
|
-
I.rightClick('Click me');
|
|
1428
|
-
// right click button with text "Click me" inside .context
|
|
1429
|
-
I.rightClick('Click me', '.context');
|
|
1430
|
-
```
|
|
1431
|
-
|
|
1432
|
-
#### Parameters
|
|
1433
|
-
|
|
1434
|
-
- `locator` **([string][6] | [object][4])** clickable element located by CSS|XPath|strict locator.
|
|
1435
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1436
|
-
|
|
1437
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
### saveElementScreenshot
|
|
1444
|
-
|
|
1445
|
-
Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
1446
|
-
Filename is relative to output folder.
|
|
1447
|
-
|
|
1448
|
-
```js
|
|
1449
|
-
I.saveElementScreenshot(`#submit`,'debug.png');
|
|
1450
|
-
```
|
|
1451
|
-
|
|
1452
|
-
#### Parameters
|
|
1453
|
-
|
|
1454
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1455
|
-
- `fileName` **[string][6]** file name to save.
|
|
1456
|
-
|
|
1457
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1458
|
-
|
|
1459
|
-
### saveScreenshot
|
|
1460
|
-
|
|
1461
|
-
Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
1462
|
-
Filename is relative to output folder.
|
|
1463
|
-
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.
|
|
1464
|
-
|
|
1465
|
-
```js
|
|
1466
|
-
I.saveScreenshot('debug.png');
|
|
1467
|
-
I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
|
|
1468
|
-
```
|
|
1469
|
-
|
|
1470
|
-
#### Parameters
|
|
1471
|
-
|
|
1472
|
-
- `fileName` **[string][6]** file name to save.
|
|
1473
|
-
- `fullPage` **[boolean][20]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1474
|
-
|
|
1475
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1476
|
-
|
|
1477
|
-
### scrollPageToBottom
|
|
1478
|
-
|
|
1479
|
-
Scroll page to the bottom.
|
|
1480
|
-
|
|
1481
|
-
```js
|
|
1482
|
-
I.scrollPageToBottom();
|
|
1483
|
-
```
|
|
1484
|
-
|
|
1485
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1486
|
-
|
|
1487
|
-
### scrollPageToTop
|
|
1488
|
-
|
|
1489
|
-
Scroll page to the top.
|
|
1490
|
-
|
|
1491
|
-
```js
|
|
1492
|
-
I.scrollPageToTop();
|
|
1493
|
-
```
|
|
1494
|
-
|
|
1495
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1496
|
-
|
|
1497
|
-
### scrollTo
|
|
1498
|
-
|
|
1499
|
-
Scrolls to element matched by locator.
|
|
1500
|
-
Extra shift can be set with offsetX and offsetY options.
|
|
1501
|
-
|
|
1502
|
-
```js
|
|
1503
|
-
I.scrollTo('footer');
|
|
1504
|
-
I.scrollTo('#submit', 5, 5);
|
|
1505
|
-
```
|
|
1506
|
-
|
|
1507
|
-
#### Parameters
|
|
1508
|
-
|
|
1509
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1510
|
-
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1511
|
-
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1512
|
-
|
|
1513
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1514
|
-
|
|
1515
|
-
### see
|
|
1516
|
-
|
|
1517
|
-
Checks that a page contains a visible text.
|
|
1518
|
-
Use context parameter to narrow down the search.
|
|
1519
|
-
|
|
1520
|
-
```js
|
|
1521
|
-
I.see('Welcome'); // text welcome on a page
|
|
1522
|
-
I.see('Welcome', '.content'); // text inside .content div
|
|
1523
|
-
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1524
|
-
```
|
|
1525
|
-
|
|
1526
|
-
#### Parameters
|
|
1527
|
-
|
|
1528
|
-
- `text` **[string][6]** expected on page.
|
|
1529
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1530
|
-
|
|
1531
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
### seeAttributesOnElements
|
|
1538
|
-
|
|
1539
|
-
Checks that all elements with given locator have given attributes.
|
|
1540
|
-
|
|
1541
|
-
```js
|
|
1542
|
-
I.seeAttributesOnElements('//form', { method: "post"});
|
|
1543
|
-
```
|
|
1544
|
-
|
|
1545
|
-
#### Parameters
|
|
1546
|
-
|
|
1547
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1548
|
-
- `attributes` **[object][4]** attributes and their values to check.
|
|
1549
|
-
|
|
1550
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
### seeCheckboxIsChecked
|
|
1557
|
-
|
|
1558
|
-
Verifies that the specified checkbox is checked.
|
|
1559
|
-
|
|
1560
|
-
```js
|
|
1561
|
-
I.seeCheckboxIsChecked('Agree');
|
|
1562
|
-
I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1563
|
-
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1564
|
-
```
|
|
1565
|
-
|
|
1566
|
-
#### Parameters
|
|
1567
|
-
|
|
1568
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
1569
|
-
|
|
1570
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1571
|
-
|
|
1572
|
-
### seeCookie
|
|
1573
|
-
|
|
1574
|
-
Checks that cookie with given name exists.
|
|
1575
|
-
|
|
1576
|
-
```js
|
|
1577
|
-
I.seeCookie('Auth');
|
|
1578
|
-
```
|
|
1579
|
-
|
|
1580
|
-
#### Parameters
|
|
1581
|
-
|
|
1582
|
-
- `name` **[string][6]** cookie name.
|
|
1583
|
-
|
|
1584
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1585
|
-
|
|
1586
|
-
### seeCssPropertiesOnElements
|
|
1587
|
-
|
|
1588
|
-
Checks that all elements with given locator have given CSS properties.
|
|
1589
|
-
|
|
1590
|
-
```js
|
|
1591
|
-
I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
1592
|
-
```
|
|
1593
|
-
|
|
1594
|
-
#### Parameters
|
|
1595
|
-
|
|
1596
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1597
|
-
- `cssProperties` **[object][4]** object with CSS properties and their values to check.
|
|
1598
|
-
|
|
1599
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
### seeCurrentUrlEquals
|
|
1606
|
-
|
|
1607
|
-
Checks that current url is equal to provided one.
|
|
1608
|
-
If a relative url provided, a configured url will be prepended to it.
|
|
1609
|
-
So both examples will work:
|
|
1610
|
-
|
|
1611
|
-
```js
|
|
1612
|
-
I.seeCurrentUrlEquals('/register');
|
|
1613
|
-
I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
1614
|
-
```
|
|
1615
|
-
|
|
1616
|
-
#### Parameters
|
|
1617
|
-
|
|
1618
|
-
- `url` **[string][6]** value to check.
|
|
1619
|
-
|
|
1620
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1621
|
-
|
|
1622
|
-
### seeElement
|
|
1623
|
-
|
|
1624
|
-
Checks that a given Element is visible
|
|
1625
|
-
Element is located by CSS or XPath.
|
|
1626
|
-
|
|
1627
|
-
```js
|
|
1628
|
-
I.seeElement('#modal');
|
|
1629
|
-
```
|
|
1630
|
-
|
|
1631
|
-
#### Parameters
|
|
1632
|
-
|
|
1633
|
-
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1634
|
-
|
|
1635
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
### seeElementInDOM
|
|
1642
|
-
|
|
1643
|
-
Checks that a given Element is present in the DOM
|
|
1644
|
-
Element is located by CSS or XPath.
|
|
1645
|
-
|
|
1646
|
-
```js
|
|
1647
|
-
I.seeElementInDOM('#modal');
|
|
1648
|
-
```
|
|
1649
|
-
|
|
1650
|
-
#### Parameters
|
|
1651
|
-
|
|
1652
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1653
|
-
|
|
1654
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1655
|
-
|
|
1656
|
-
### seeInCurrentUrl
|
|
1657
|
-
|
|
1658
|
-
Checks that current url contains a provided fragment.
|
|
1659
|
-
|
|
1660
|
-
```js
|
|
1661
|
-
I.seeInCurrentUrl('/register'); // we are on registration page
|
|
1662
|
-
```
|
|
1663
|
-
|
|
1664
|
-
#### Parameters
|
|
1665
|
-
|
|
1666
|
-
- `url` **[string][6]** a fragment to check
|
|
1667
|
-
|
|
1668
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1669
|
-
|
|
1670
|
-
### seeInField
|
|
1671
|
-
|
|
1672
|
-
Checks that the given input field or textarea equals to given value.
|
|
1673
|
-
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1674
|
-
|
|
1675
|
-
```js
|
|
1676
|
-
I.seeInField('Username', 'davert');
|
|
1677
|
-
I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1678
|
-
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1679
|
-
I.seeInField('#searchform input','Search');
|
|
1680
|
-
```
|
|
1681
|
-
|
|
1682
|
-
#### Parameters
|
|
1683
|
-
|
|
1684
|
-
- `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
1685
|
-
- `value` **([string][6] | [object][4])** value to check.
|
|
1686
|
-
|
|
1687
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1688
|
-
|
|
1689
|
-
### seeInPopup
|
|
1690
|
-
|
|
1691
|
-
Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1692
|
-
given string.
|
|
1693
|
-
|
|
1694
|
-
```js
|
|
1695
|
-
I.seeInPopup('Popup text');
|
|
1696
|
-
```
|
|
1697
|
-
|
|
1698
|
-
#### Parameters
|
|
1699
|
-
|
|
1700
|
-
- `text` **[string][6]** value to check.
|
|
1701
|
-
|
|
1702
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1703
|
-
|
|
1704
|
-
### seeInSource
|
|
1705
|
-
|
|
1706
|
-
Checks that the current page contains the given string in its raw source code.
|
|
1707
|
-
|
|
1708
|
-
```js
|
|
1709
|
-
I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1710
|
-
```
|
|
1711
|
-
|
|
1712
|
-
#### Parameters
|
|
1713
|
-
|
|
1714
|
-
- `text` **[string][6]** value to check.
|
|
1715
|
-
|
|
1716
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1717
|
-
|
|
1718
|
-
### seeInTitle
|
|
1719
|
-
|
|
1720
|
-
Checks that title contains text.
|
|
1721
|
-
|
|
1722
|
-
```js
|
|
1723
|
-
I.seeInTitle('Home Page');
|
|
1724
|
-
```
|
|
1725
|
-
|
|
1726
|
-
#### Parameters
|
|
1727
|
-
|
|
1728
|
-
- `text` **[string][6]** text value to check.
|
|
1729
|
-
|
|
1730
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1731
|
-
|
|
1732
|
-
### seeNumberOfElements
|
|
1733
|
-
|
|
1734
|
-
Asserts that an element appears a given number of times in the DOM.
|
|
1735
|
-
Element is located by label or name or CSS or XPath.
|
|
1736
|
-
|
|
1737
|
-
```js
|
|
1738
|
-
I.seeNumberOfElements('#submitBtn', 1);
|
|
1739
|
-
```
|
|
1740
|
-
|
|
1741
|
-
#### Parameters
|
|
1742
|
-
|
|
1743
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1744
|
-
- `num` **[number][10]** number of elements.
|
|
1745
|
-
|
|
1746
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
### seeNumberOfVisibleElements
|
|
1753
|
-
|
|
1754
|
-
Asserts that an element is visible a given number of times.
|
|
1755
|
-
Element is located by CSS or XPath.
|
|
1756
|
-
|
|
1757
|
-
```js
|
|
1758
|
-
I.seeNumberOfVisibleElements('.buttons', 3);
|
|
1759
|
-
```
|
|
1760
|
-
|
|
1761
|
-
#### Parameters
|
|
1762
|
-
|
|
1763
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1764
|
-
- `num` **[number][10]** number of elements.
|
|
1765
|
-
|
|
1766
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
### seeTextEquals
|
|
1773
|
-
|
|
1774
|
-
Checks that text is equal to provided one.
|
|
1775
|
-
|
|
1776
|
-
```js
|
|
1777
|
-
I.seeTextEquals('text', 'h1');
|
|
1778
|
-
```
|
|
1779
|
-
|
|
1780
|
-
#### Parameters
|
|
1781
|
-
|
|
1782
|
-
- `text` **[string][6]** element value to check.
|
|
1783
|
-
- `context` **([string][6] | [object][4])?** element located by CSS|XPath|strict locator.
|
|
1784
|
-
|
|
1785
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1786
|
-
|
|
1787
|
-
### seeTitleEquals
|
|
1788
|
-
|
|
1789
|
-
Checks that title is equal to provided one.
|
|
1790
|
-
|
|
1791
|
-
```js
|
|
1792
|
-
I.seeTitleEquals('Test title.');
|
|
1793
|
-
```
|
|
1794
|
-
|
|
1795
|
-
#### Parameters
|
|
1796
|
-
|
|
1797
|
-
- `text` **[string][6]** value to check.
|
|
1798
|
-
|
|
1799
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1800
|
-
|
|
1801
|
-
### selectOption
|
|
1802
|
-
|
|
1803
|
-
Selects an option in a drop-down select.
|
|
1804
|
-
Field is searched by label | name | CSS | XPath.
|
|
1805
|
-
Option is selected by visible text or by value.
|
|
1806
|
-
|
|
1807
|
-
```js
|
|
1808
|
-
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
1809
|
-
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
1810
|
-
I.selectOption('subscription', '0'); // or by value
|
|
1811
|
-
I.selectOption('//form/select[@name=account]','Premium');
|
|
1812
|
-
I.selectOption('form select[name=account]', 'Premium');
|
|
1813
|
-
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
1814
|
-
```
|
|
1815
|
-
|
|
1816
|
-
Provide an array for the second argument to select multiple options.
|
|
1817
|
-
|
|
1818
|
-
```js
|
|
1819
|
-
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1820
|
-
```
|
|
1821
|
-
|
|
1822
|
-
#### Parameters
|
|
1823
|
-
|
|
1824
|
-
- `select` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1825
|
-
- `option` **([string][6] | [Array][15]<any>)** visible text or value of option.
|
|
1826
|
-
|
|
1827
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1828
|
-
|
|
1829
|
-
### setCookie
|
|
1830
|
-
|
|
1831
|
-
Sets cookie(s).
|
|
1832
|
-
|
|
1833
|
-
Can be a single cookie object or an array of cookies:
|
|
1834
|
-
|
|
1835
|
-
```js
|
|
1836
|
-
I.setCookie({name: 'auth', value: true});
|
|
1837
|
-
|
|
1838
|
-
// as array
|
|
1839
|
-
I.setCookie([
|
|
1840
|
-
{name: 'auth', value: true},
|
|
1841
|
-
{name: 'agree', value: true}
|
|
1842
|
-
]);
|
|
1843
|
-
```
|
|
1844
|
-
|
|
1845
|
-
#### Parameters
|
|
1846
|
-
|
|
1847
|
-
- `cookie` **(Cookie | [Array][15]<Cookie>)** a cookie object or array of cookie objects.
|
|
1848
|
-
|
|
1849
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1850
|
-
|
|
1851
|
-
### setPuppeteerRequestHeaders
|
|
1852
|
-
|
|
1853
|
-
Set headers for all next requests
|
|
1854
|
-
|
|
1855
|
-
```js
|
|
1856
|
-
I.setPuppeteerRequestHeaders({
|
|
1857
|
-
'X-Sent-By': 'CodeceptJS',
|
|
1858
|
-
});
|
|
1859
|
-
```
|
|
1860
|
-
|
|
1861
|
-
#### Parameters
|
|
1862
|
-
|
|
1863
|
-
- `customHeaders` **[object][4]** headers to set
|
|
1864
|
-
|
|
1865
|
-
### switchTo
|
|
1866
|
-
|
|
1867
|
-
Switches frame or in case of null locator reverts to parent.
|
|
1868
|
-
|
|
1869
|
-
```js
|
|
1870
|
-
I.switchTo('iframe'); // switch to first iframe
|
|
1871
|
-
I.switchTo(); // switch back to main page
|
|
1872
|
-
```
|
|
1873
|
-
|
|
1874
|
-
#### Parameters
|
|
1875
|
-
|
|
1876
|
-
- `locator` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1877
|
-
|
|
1878
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1879
|
-
|
|
1880
|
-
### switchToNextTab
|
|
1881
|
-
|
|
1882
|
-
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
|
|
1883
|
-
|
|
1884
|
-
```js
|
|
1885
|
-
I.switchToNextTab();
|
|
1886
|
-
I.switchToNextTab(2);
|
|
1887
|
-
```
|
|
1888
|
-
|
|
1889
|
-
#### Parameters
|
|
1890
|
-
|
|
1891
|
-
- `num` **[number][10]**
|
|
1892
|
-
|
|
1893
|
-
### switchToPreviousTab
|
|
1894
|
-
|
|
1895
|
-
Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
|
|
1896
|
-
|
|
1897
|
-
```js
|
|
1898
|
-
I.switchToPreviousTab();
|
|
1899
|
-
I.switchToPreviousTab(2);
|
|
1900
|
-
```
|
|
1901
|
-
|
|
1902
|
-
#### Parameters
|
|
1903
|
-
|
|
1904
|
-
- `num` **[number][10]**
|
|
1905
|
-
|
|
1906
|
-
### type
|
|
1907
|
-
|
|
1908
|
-
Types out the given text into an active field.
|
|
1909
|
-
To slow down typing use a second parameter, to set interval between key presses.
|
|
1910
|
-
_Note:_ Should be used when [`fillField`][18] is not an option.
|
|
1911
|
-
|
|
1912
|
-
```js
|
|
1913
|
-
// passing in a string
|
|
1914
|
-
I.type('Type this out.');
|
|
1915
|
-
|
|
1916
|
-
// typing values with a 100ms interval
|
|
1917
|
-
I.type('4141555311111111', 100);
|
|
1918
|
-
|
|
1919
|
-
// passing in an array
|
|
1920
|
-
I.type(['T', 'E', 'X', 'T']);
|
|
1921
|
-
|
|
1922
|
-
// passing a secret
|
|
1923
|
-
I.type(secret('123456'));
|
|
1924
|
-
```
|
|
1925
|
-
|
|
1926
|
-
#### Parameters
|
|
1927
|
-
|
|
1928
|
-
- `keys`
|
|
1929
|
-
- `delay` **[number][10]?** (optional) delay in ms between key presses
|
|
1930
|
-
- `key` **([string][6] | [Array][15]<[string][6]>)** or array of keys to type.
|
|
1931
|
-
|
|
1932
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1933
|
-
|
|
1934
|
-
### uncheckOption
|
|
1935
|
-
|
|
1936
|
-
Unselects a checkbox or radio button.
|
|
1937
|
-
Element is located by label or name or CSS or XPath.
|
|
1938
|
-
|
|
1939
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1940
|
-
|
|
1941
|
-
```js
|
|
1942
|
-
I.uncheckOption('#agree');
|
|
1943
|
-
I.uncheckOption('I Agree to Terms and Conditions');
|
|
1944
|
-
I.uncheckOption('agree', '//form');
|
|
1945
|
-
```
|
|
1946
|
-
|
|
1947
|
-
#### Parameters
|
|
1948
|
-
|
|
1949
|
-
- `field` **([string][6] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
1950
|
-
- `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1951
|
-
|
|
1952
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1953
|
-
|
|
1954
|
-
### usePuppeteerTo
|
|
1955
|
-
|
|
1956
|
-
Use Puppeteer API inside a test.
|
|
1957
|
-
|
|
1958
|
-
First argument is a description of an action.
|
|
1959
|
-
Second argument is async function that gets this helper as parameter.
|
|
1960
|
-
|
|
1961
|
-
{ [`page`][21], [`browser`][22] } from Puppeteer API are available.
|
|
1962
|
-
|
|
1963
|
-
```js
|
|
1964
|
-
I.usePuppeteerTo('emulate offline mode', async ({ page }) {
|
|
1965
|
-
await page.setOfflineMode(true);
|
|
1966
|
-
});
|
|
1967
|
-
```
|
|
1968
|
-
|
|
1969
|
-
#### Parameters
|
|
1970
|
-
|
|
1971
|
-
- `description` **[string][6]** used to show in logs.
|
|
1972
|
-
- `fn` **[function][12]** async function that is executed with Puppeteer as argument
|
|
1973
|
-
|
|
1974
|
-
### wait
|
|
1975
|
-
|
|
1976
|
-
Pauses execution for a number of seconds.
|
|
1977
|
-
|
|
1978
|
-
```js
|
|
1979
|
-
I.wait(2); // wait 2 secs
|
|
1980
|
-
```
|
|
1981
|
-
|
|
1982
|
-
#### Parameters
|
|
1983
|
-
|
|
1984
|
-
- `sec` **[number][10]** number of second to wait.
|
|
1985
|
-
|
|
1986
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1987
|
-
|
|
1988
|
-
### waitForClickable
|
|
1989
|
-
|
|
1990
|
-
Waits for element to be clickable (by default waits for 1sec).
|
|
1991
|
-
Element can be located by CSS or XPath.
|
|
1992
|
-
|
|
1993
|
-
```js
|
|
1994
|
-
I.waitForClickable('.btn.continue');
|
|
1995
|
-
I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
1996
|
-
```
|
|
1997
|
-
|
|
1998
|
-
#### Parameters
|
|
1999
|
-
|
|
2000
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2001
|
-
- `waitTimeout`
|
|
2002
|
-
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
2003
|
-
|
|
2004
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2005
|
-
|
|
2006
|
-
### waitForDetached
|
|
2007
|
-
|
|
2008
|
-
Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
2009
|
-
Element can be located by CSS or XPath.
|
|
2010
|
-
|
|
2011
|
-
```js
|
|
2012
|
-
I.waitForDetached('#popup');
|
|
2013
|
-
```
|
|
2014
|
-
|
|
2015
|
-
#### Parameters
|
|
2016
|
-
|
|
2017
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2018
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2019
|
-
|
|
2020
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2021
|
-
|
|
2022
|
-
### waitForElement
|
|
2023
|
-
|
|
2024
|
-
Waits for element to be present on page (by default waits for 1sec).
|
|
2025
|
-
Element can be located by CSS or XPath.
|
|
2026
|
-
|
|
2027
|
-
```js
|
|
2028
|
-
I.waitForElement('.btn.continue');
|
|
2029
|
-
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2030
|
-
```
|
|
2031
|
-
|
|
2032
|
-
#### Parameters
|
|
2033
|
-
|
|
2034
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2035
|
-
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
2036
|
-
|
|
2037
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
### waitForEnabled
|
|
2044
|
-
|
|
2045
|
-
Waits for element to become enabled (by default waits for 1sec).
|
|
2046
|
-
Element can be located by CSS or XPath.
|
|
2047
|
-
|
|
2048
|
-
#### Parameters
|
|
2049
|
-
|
|
2050
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2051
|
-
- `sec` **[number][10]** (optional) time in seconds to wait, 1 by default.
|
|
2052
|
-
|
|
2053
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2054
|
-
|
|
2055
|
-
### waitForFunction
|
|
2056
|
-
|
|
2057
|
-
Waits for a function to return true (waits for 1 sec by default).
|
|
2058
|
-
Running in browser context.
|
|
2059
|
-
|
|
2060
|
-
```js
|
|
2061
|
-
I.waitForFunction(fn[, [args[, timeout]])
|
|
2062
|
-
```
|
|
2063
|
-
|
|
2064
|
-
```js
|
|
2065
|
-
I.waitForFunction(() => window.requests == 0);
|
|
2066
|
-
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
|
|
2067
|
-
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
|
|
2068
|
-
```
|
|
2069
|
-
|
|
2070
|
-
#### Parameters
|
|
2071
|
-
|
|
2072
|
-
- `fn` **([string][6] | [function][12])** to be executed in browser context.
|
|
2073
|
-
- `argsOrSec` **([Array][15]<any> | [number][10])?** (optional, `1` by default) arguments for function or seconds.
|
|
2074
|
-
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
2075
|
-
|
|
2076
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2077
|
-
|
|
2078
|
-
### waitForInvisible
|
|
2079
|
-
|
|
2080
|
-
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
2081
|
-
Element can be located by CSS or XPath.
|
|
2082
|
-
|
|
2083
|
-
```js
|
|
2084
|
-
I.waitForInvisible('#popup');
|
|
2085
|
-
```
|
|
2086
|
-
|
|
2087
|
-
#### Parameters
|
|
2088
|
-
|
|
2089
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2090
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2091
|
-
|
|
2092
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2093
|
-
|
|
2094
|
-
### waitForNavigation
|
|
2095
|
-
|
|
2096
|
-
Waits for navigation to finish. By default, takes configured `waitForNavigation` option.
|
|
2097
|
-
|
|
2098
|
-
See [Puppeteer's reference][23]
|
|
2099
|
-
|
|
2100
|
-
#### Parameters
|
|
2101
|
-
|
|
2102
|
-
- `opts` **any**
|
|
2103
|
-
|
|
2104
|
-
### waitForNumberOfTabs
|
|
2105
|
-
|
|
2106
|
-
Waits for number of tabs.
|
|
2107
|
-
|
|
2108
|
-
```js
|
|
2109
|
-
I.waitForNumberOfTabs(2);
|
|
2110
|
-
```
|
|
2111
|
-
|
|
2112
|
-
#### Parameters
|
|
2113
|
-
|
|
2114
|
-
- `expectedTabs` **[number][10]** expecting the number of tabs.
|
|
2115
|
-
- `sec` **[number][10]** number of secs to wait.
|
|
2116
|
-
|
|
2117
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2118
|
-
|
|
2119
|
-
### waitForRequest
|
|
2120
|
-
|
|
2121
|
-
Waits for a network request.
|
|
2122
|
-
|
|
2123
|
-
```js
|
|
2124
|
-
I.waitForRequest('http://example.com/resource');
|
|
2125
|
-
I.waitForRequest(request => request.url() === 'http://example.com' && request.method() === 'GET');
|
|
2126
|
-
```
|
|
2127
|
-
|
|
2128
|
-
#### Parameters
|
|
2129
|
-
|
|
2130
|
-
- `urlOrPredicate` **([string][6] | [function][12])**
|
|
2131
|
-
- `sec` **[number][10]?** seconds to wait
|
|
2132
|
-
|
|
2133
|
-
### waitForResponse
|
|
2134
|
-
|
|
2135
|
-
Waits for a network response.
|
|
2136
|
-
|
|
2137
|
-
```js
|
|
2138
|
-
I.waitForResponse('http://example.com/resource');
|
|
2139
|
-
I.waitForResponse(response => response.url() === 'http://example.com' && response.request().method() === 'GET');
|
|
2140
|
-
```
|
|
2141
|
-
|
|
2142
|
-
#### Parameters
|
|
2143
|
-
|
|
2144
|
-
- `urlOrPredicate` **([string][6] | [function][12])**
|
|
2145
|
-
- `sec` **[number][10]?** number of seconds to wait
|
|
2146
|
-
|
|
2147
|
-
### waitForText
|
|
2148
|
-
|
|
2149
|
-
Waits for a text to appear (by default waits for 1sec).
|
|
2150
|
-
Element can be located by CSS or XPath.
|
|
2151
|
-
Narrow down search results by providing context.
|
|
2152
|
-
|
|
2153
|
-
```js
|
|
2154
|
-
I.waitForText('Thank you, form has been submitted');
|
|
2155
|
-
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
2156
|
-
```
|
|
2157
|
-
|
|
2158
|
-
#### Parameters
|
|
2159
|
-
|
|
2160
|
-
- `text` **[string][6]** to wait for.
|
|
2161
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2162
|
-
- `context` **([string][6] | [object][4])?** (optional) element located by CSS|XPath|strict locator.
|
|
2163
|
-
|
|
2164
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2165
|
-
|
|
2166
|
-
### waitForValue
|
|
2167
|
-
|
|
2168
|
-
Waits for the specified value to be in value attribute.
|
|
2169
|
-
|
|
2170
|
-
```js
|
|
2171
|
-
I.waitForValue('//input', "GoodValue");
|
|
2172
|
-
```
|
|
2173
|
-
|
|
2174
|
-
#### Parameters
|
|
2175
|
-
|
|
2176
|
-
- `field` **([string][6] | [object][4])** input field.
|
|
2177
|
-
- `value` **[string][6]** expected value.
|
|
2178
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2179
|
-
|
|
2180
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2181
|
-
|
|
2182
|
-
### waitForVisible
|
|
2183
|
-
|
|
2184
|
-
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
2185
|
-
Element can be located by CSS or XPath.
|
|
2186
|
-
|
|
2187
|
-
```js
|
|
2188
|
-
I.waitForVisible('#popup');
|
|
2189
|
-
```
|
|
2190
|
-
|
|
2191
|
-
#### Parameters
|
|
2192
|
-
|
|
2193
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2194
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2195
|
-
|
|
2196
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
### waitInUrl
|
|
2203
|
-
|
|
2204
|
-
Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
|
|
2205
|
-
|
|
2206
|
-
```js
|
|
2207
|
-
I.waitInUrl('/info', 2);
|
|
2208
|
-
```
|
|
2209
|
-
|
|
2210
|
-
#### Parameters
|
|
2211
|
-
|
|
2212
|
-
- `urlPart` **[string][6]** value to check.
|
|
2213
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2214
|
-
|
|
2215
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2216
|
-
|
|
2217
|
-
### waitNumberOfVisibleElements
|
|
2218
|
-
|
|
2219
|
-
Waits for a specified number of elements on the page.
|
|
2220
|
-
|
|
2221
|
-
```js
|
|
2222
|
-
I.waitNumberOfVisibleElements('a', 3);
|
|
2223
|
-
```
|
|
2224
|
-
|
|
2225
|
-
#### Parameters
|
|
2226
|
-
|
|
2227
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2228
|
-
- `num` **[number][10]** number of elements.
|
|
2229
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2230
|
-
|
|
2231
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
### waitToHide
|
|
2238
|
-
|
|
2239
|
-
Waits for an element to hide (by default waits for 1sec).
|
|
2240
|
-
Element can be located by CSS or XPath.
|
|
2241
|
-
|
|
2242
|
-
```js
|
|
2243
|
-
I.waitToHide('#popup');
|
|
2244
|
-
```
|
|
2245
|
-
|
|
2246
|
-
#### Parameters
|
|
2247
|
-
|
|
2248
|
-
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2249
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2250
|
-
|
|
2251
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2252
|
-
|
|
2253
|
-
### waitUrlEquals
|
|
2254
|
-
|
|
2255
|
-
Waits for the entire URL to match the expected
|
|
2256
|
-
|
|
2257
|
-
```js
|
|
2258
|
-
I.waitUrlEquals('/info', 2);
|
|
2259
|
-
I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
2260
|
-
```
|
|
2261
|
-
|
|
2262
|
-
#### Parameters
|
|
2263
|
-
|
|
2264
|
-
- `urlPart` **[string][6]** value to check.
|
|
2265
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2266
|
-
|
|
2267
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2268
|
-
|
|
2269
|
-
[1]: https://github.com/GoogleChrome/puppeteer
|
|
2270
|
-
|
|
2271
|
-
[2]: https://codecept.io/helpers/Puppeteer-firefox
|
|
2272
|
-
|
|
2273
|
-
[3]: https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
|
|
2274
|
-
|
|
2275
|
-
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
2276
|
-
|
|
2277
|
-
[5]: http://jster.net/category/windows-modals-popups
|
|
2278
|
-
|
|
2279
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
2280
|
-
|
|
2281
|
-
[7]: https://github.com/puppeteer/puppeteer/issues/5420
|
|
2282
|
-
|
|
2283
|
-
[8]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2284
|
-
|
|
2285
|
-
[9]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2286
|
-
|
|
2287
|
-
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2288
|
-
|
|
2289
|
-
[11]: https://vuejs.org/v2/api/#Vue-nextTick
|
|
2290
|
-
|
|
2291
|
-
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
2292
|
-
|
|
2293
|
-
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2294
|
-
|
|
2295
|
-
[14]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
2296
|
-
|
|
2297
|
-
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
2298
|
-
|
|
2299
|
-
[16]: https://codecept.io/helpers/FileSystem
|
|
2300
|
-
|
|
2301
|
-
[17]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
2302
|
-
|
|
2303
|
-
[18]: #fillfield
|
|
2304
|
-
|
|
2305
|
-
[19]: #click
|
|
2306
|
-
|
|
2307
|
-
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2308
|
-
|
|
2309
|
-
[21]: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-page
|
|
2310
|
-
|
|
2311
|
-
[22]: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browser
|
|
2312
|
-
|
|
2313
|
-
[23]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions
|
|
2314
|
-
|
|
2315
|
-
[24]: https://pptr.dev/api/puppeteer.tracing
|
|
2316
|
-
|
|
2317
|
-
[25]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
|