codeceptjs 3.5.15 → 3.6.0-beta.1.ai-healers
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 +66 -30
- package/docs/advanced.md +351 -0
- package/docs/ai.md +365 -0
- package/docs/api.md +323 -0
- package/docs/basics.md +979 -0
- package/docs/bdd.md +539 -0
- package/docs/best.md +237 -0
- package/docs/books.md +37 -0
- package/docs/bootstrap.md +135 -0
- package/docs/build/AI.js +124 -0
- package/docs/build/ApiDataFactory.js +410 -0
- package/docs/build/Appium.js +2027 -0
- package/docs/build/Expect.js +422 -0
- package/docs/build/FileSystem.js +228 -0
- package/docs/build/GraphQL.js +229 -0
- package/docs/build/GraphQLDataFactory.js +309 -0
- package/docs/build/JSONResponse.js +338 -0
- package/docs/build/Mochawesome.js +71 -0
- package/docs/build/Nightmare.js +2152 -0
- package/docs/build/Playwright.js +5110 -0
- package/docs/build/Protractor.js +2706 -0
- package/docs/build/Puppeteer.js +3905 -0
- package/docs/build/REST.js +344 -0
- package/docs/build/TestCafe.js +2125 -0
- package/docs/build/WebDriver.js +4240 -0
- package/docs/changelog.md +2572 -0
- package/docs/commands.md +266 -0
- package/docs/community-helpers.md +58 -0
- package/docs/configuration.md +157 -0
- package/docs/continuous-integration.md +22 -0
- package/docs/custom-helpers.md +306 -0
- package/docs/data.md +379 -0
- package/docs/detox.md +235 -0
- package/docs/docker.md +136 -0
- package/docs/email.md +183 -0
- package/docs/examples.md +149 -0
- package/docs/heal.md +186 -0
- package/docs/helpers/ApiDataFactory.md +266 -0
- package/docs/helpers/Appium.md +1374 -0
- package/docs/helpers/Detox.md +586 -0
- package/docs/helpers/Expect.md +275 -0
- package/docs/helpers/FileSystem.md +152 -0
- package/docs/helpers/GraphQL.md +151 -0
- package/docs/helpers/GraphQLDataFactory.md +226 -0
- package/docs/helpers/JSONResponse.md +254 -0
- package/docs/helpers/Mochawesome.md +8 -0
- package/docs/helpers/MockRequest.md +377 -0
- package/docs/helpers/Nightmare.md +1305 -0
- package/docs/helpers/OpenAI.md +70 -0
- package/docs/helpers/Playwright.md +2759 -0
- package/docs/helpers/Polly.md +44 -0
- package/docs/helpers/Protractor.md +1769 -0
- package/docs/helpers/Puppeteer-firefox.md +86 -0
- package/docs/helpers/Puppeteer.md +2317 -0
- package/docs/helpers/REST.md +218 -0
- package/docs/helpers/TestCafe.md +1321 -0
- package/docs/helpers/WebDriver.md +2547 -0
- package/docs/hooks.md +340 -0
- package/docs/index.md +111 -0
- package/docs/installation.md +75 -0
- package/docs/internal-api.md +266 -0
- package/docs/locators.md +339 -0
- package/docs/mobile-react-native-locators.md +67 -0
- package/docs/mobile.md +338 -0
- package/docs/pageobjects.md +291 -0
- package/docs/parallel.md +400 -0
- package/docs/playwright.md +632 -0
- package/docs/plugins.md +1247 -0
- package/docs/puppeteer.md +316 -0
- package/docs/quickstart.md +162 -0
- package/docs/react.md +70 -0
- package/docs/reports.md +392 -0
- package/docs/secrets.md +36 -0
- package/docs/shadow.md +68 -0
- package/docs/shared/keys.mustache +31 -0
- package/docs/shared/react.mustache +1 -0
- package/docs/testcafe.md +174 -0
- package/docs/translation.md +247 -0
- package/docs/tutorial.md +271 -0
- package/docs/typescript.md +180 -0
- package/docs/ui.md +59 -0
- package/docs/videos.md +28 -0
- package/docs/visual.md +202 -0
- package/docs/vue.md +143 -0
- package/docs/webdriver.md +701 -0
- package/docs/wiki/Books-&-Posts.md +27 -0
- package/docs/wiki/Community-Helpers-&-Plugins.md +53 -0
- package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +61 -0
- package/docs/wiki/Examples.md +145 -0
- package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +68 -0
- package/docs/wiki/Home.md +16 -0
- package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +83 -0
- package/docs/wiki/Release-Process.md +24 -0
- package/docs/wiki/Roadmap.md +23 -0
- package/docs/wiki/Tests.md +1393 -0
- package/docs/wiki/Upgrading-to-CodeceptJS-3.md +153 -0
- package/docs/wiki/Videos.md +19 -0
- package/lib/actor.js +3 -6
- package/lib/ai.js +152 -80
- package/lib/cli.js +1 -0
- package/lib/command/dryRun.js +13 -44
- package/lib/command/generate.js +34 -0
- package/lib/command/run-workers.js +3 -0
- package/lib/command/run.js +3 -0
- package/lib/container.js +2 -0
- package/lib/heal.js +172 -0
- package/lib/helper/AI.js +124 -0
- package/lib/helper/Appium.js +12 -36
- package/lib/helper/Expect.js +8 -11
- package/lib/helper/JSONResponse.js +8 -8
- package/lib/helper/Playwright.js +240 -100
- package/lib/helper/Puppeteer.js +68 -182
- package/lib/helper/REST.js +1 -4
- package/lib/helper/WebDriver.js +10 -324
- package/lib/index.js +3 -0
- package/lib/listener/steps.js +0 -2
- package/lib/locator.js +4 -13
- package/lib/plugin/coverage.js +99 -112
- package/lib/plugin/heal.js +26 -117
- package/lib/recorder.js +11 -5
- package/lib/step.js +1 -3
- package/lib/store.js +2 -0
- package/lib/template/heal.js +39 -0
- package/package.json +35 -47
- package/typings/index.d.ts +0 -17
- package/typings/promiseBasedTypes.d.ts +57 -340
- package/typings/types.d.ts +73 -433
- package/docs/webapi/dontSeeTraffic.mustache +0 -13
- package/docs/webapi/flushNetworkTraffics.mustache +0 -5
- package/docs/webapi/grabRecordedNetworkTraffics.mustache +0 -10
- package/docs/webapi/seeTraffic.mustache +0 -36
- package/docs/webapi/startRecordingTraffic.mustache +0 -8
- package/docs/webapi/stopRecordingTraffic.mustache +0 -5
- package/docs/webapi/waitForCookie.mustache +0 -9
- package/lib/helper/MockServer.js +0 -221
- package/lib/helper/errors/ElementAssertion.js +0 -38
- package/lib/helper/networkTraffics/utils.js +0 -137
- /package/{lib/helper → docs/build}/OpenAI.js +0 -0
|
@@ -0,0 +1,1374 @@
|
|
|
1
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
2
|
+
|
|
3
|
+
## Appium
|
|
4
|
+
|
|
5
|
+
**Extends Webdriver**
|
|
6
|
+
|
|
7
|
+
Appium helper extends [Webdriver][1] helper.
|
|
8
|
+
It supports all browser methods and also includes special methods for mobile apps testing.
|
|
9
|
+
You can use this helper to test Web on desktop and mobile devices and mobile apps.
|
|
10
|
+
|
|
11
|
+
## Appium Installation
|
|
12
|
+
|
|
13
|
+
Appium is an open source test automation framework for use with native, hybrid and mobile web apps that implements the WebDriver protocol.
|
|
14
|
+
It allows you to run Selenium tests on mobile devices and also test native, hybrid and mobile web apps.
|
|
15
|
+
|
|
16
|
+
Download and install [Appium][2]
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install -g appium
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Launch the daemon: `appium`
|
|
23
|
+
|
|
24
|
+
## Helper configuration
|
|
25
|
+
|
|
26
|
+
This helper should be configured in codecept.conf.ts or codecept.conf.js
|
|
27
|
+
|
|
28
|
+
- `appiumV2`: set this to true if you want to run tests with AppiumV2. See more how to setup [here][3]
|
|
29
|
+
- `app`: Application path. Local path or remote URL to an .ipa or .apk file, or a .zip containing one of these. Alias to desiredCapabilities.appPackage
|
|
30
|
+
- `host`: (default: 'localhost') Appium host
|
|
31
|
+
- `port`: (default: '4723') Appium port
|
|
32
|
+
- `platform`: (Android or IOS), which mobile OS to use; alias to desiredCapabilities.platformName
|
|
33
|
+
- `restart`: restart browser or app between tests (default: true), if set to false cookies will be cleaned but browser window will be kept and for apps nothing will be changed.
|
|
34
|
+
- `desiredCapabilities`: \[], Appium capabilities, see below
|
|
35
|
+
- `platformName` - Which mobile OS platform to use
|
|
36
|
+
- `appPackage` - Java package of the Android app you want to run
|
|
37
|
+
- `appActivity` - Activity name for the Android activity you want to launch from your package.
|
|
38
|
+
- `deviceName`: The kind of mobile device or emulator to use
|
|
39
|
+
- `platformVersion`: Mobile OS version
|
|
40
|
+
- `app` - The absolute local path or remote http URL to an .ipa or .apk file, or a .zip containing one of these. Appium will attempt to install this app binary on the appropriate device first.
|
|
41
|
+
- `browserName`: Name of mobile web browser to automate. Should be an empty string if automating an app instead.
|
|
42
|
+
|
|
43
|
+
Example Android App:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
{
|
|
47
|
+
helpers: {
|
|
48
|
+
Appium: {
|
|
49
|
+
platform: "Android",
|
|
50
|
+
desiredCapabilities: {
|
|
51
|
+
appPackage: "com.example.android.myApp",
|
|
52
|
+
appActivity: "MainActivity",
|
|
53
|
+
deviceName: "OnePlus3",
|
|
54
|
+
platformVersion: "6.0.1"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Example iOS Mobile Web with local Appium:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
{
|
|
65
|
+
helpers: {
|
|
66
|
+
Appium: {
|
|
67
|
+
platform: "iOS",
|
|
68
|
+
url: "https://the-internet.herokuapp.com/",
|
|
69
|
+
desiredCapabilities: {
|
|
70
|
+
deviceName: "iPhone X",
|
|
71
|
+
platformVersion: "12.0",
|
|
72
|
+
browserName: "safari"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Example iOS Mobile Web on BrowserStack:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
{
|
|
83
|
+
helpers: {
|
|
84
|
+
Appium: {
|
|
85
|
+
host: "hub-cloud.browserstack.com",
|
|
86
|
+
port: 4444,
|
|
87
|
+
user: process.env.BROWSERSTACK_USER,
|
|
88
|
+
key: process.env.BROWSERSTACK_KEY,
|
|
89
|
+
platform: "iOS",
|
|
90
|
+
url: "https://the-internet.herokuapp.com/",
|
|
91
|
+
desiredCapabilities: {
|
|
92
|
+
realMobile: "true",
|
|
93
|
+
device: "iPhone 8",
|
|
94
|
+
os_version: "12",
|
|
95
|
+
browserName: "safari"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Example Android App using AppiumV2 on BrowserStack:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
{
|
|
106
|
+
helpers: {
|
|
107
|
+
Appium: {
|
|
108
|
+
appiumV2: true,
|
|
109
|
+
host: "hub-cloud.browserstack.com",
|
|
110
|
+
port: 4444,
|
|
111
|
+
user: process.env.BROWSERSTACK_USER,
|
|
112
|
+
key: process.env.BROWSERSTACK_KEY,
|
|
113
|
+
app: `bs://c700ce60cf1gjhgjh3ae8ed9770ghjg5a55b8e022f13c5827cg`,
|
|
114
|
+
browser: '',
|
|
115
|
+
desiredCapabilities: {
|
|
116
|
+
'appPackage': data.packageName,
|
|
117
|
+
'deviceName': process.env.DEVICE || 'Google Pixel 3',
|
|
118
|
+
'platformName': process.env.PLATFORM || 'android',
|
|
119
|
+
'platformVersion': process.env.OS_VERSION || '10.0',
|
|
120
|
+
'automationName': process.env.ENGINE || 'UIAutomator2',
|
|
121
|
+
'newCommandTimeout': 300000,
|
|
122
|
+
'androidDeviceReadyTimeout': 300000,
|
|
123
|
+
'androidInstallTimeout': 90000,
|
|
124
|
+
'appWaitDuration': 300000,
|
|
125
|
+
'autoGrantPermissions': true,
|
|
126
|
+
'gpsEnabled': true,
|
|
127
|
+
'isHeadless': false,
|
|
128
|
+
'noReset': false,
|
|
129
|
+
'noSign': true,
|
|
130
|
+
'bstack:options' : {
|
|
131
|
+
"appiumVersion" : "2.0.1",
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Additional configuration params can be used from [https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/caps.md][4]
|
|
140
|
+
|
|
141
|
+
## Access From Helpers
|
|
142
|
+
|
|
143
|
+
Receive Appium client from a custom helper by accessing `browser` property:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
let browser = this.helpers['Appium'].browser
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Methods
|
|
150
|
+
|
|
151
|
+
### Parameters
|
|
152
|
+
|
|
153
|
+
- `config`
|
|
154
|
+
|
|
155
|
+
### runOnIOS
|
|
156
|
+
|
|
157
|
+
Execute code only on iOS
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
I.runOnIOS(() => {
|
|
161
|
+
I.click('//UIAApplication[1]/UIAWindow[1]/UIAButton[1]');
|
|
162
|
+
I.see('Hi, IOS', '~welcome');
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Additional filter can be applied by checking for capabilities.
|
|
167
|
+
For instance, this code will be executed only on iPhone 5s:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
I.runOnIOS({deviceName: 'iPhone 5s'},() => {
|
|
171
|
+
// ...
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Also capabilities can be checked by a function.
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
I.runOnAndroid((caps) => {
|
|
179
|
+
// caps is current config of desiredCapabiliites
|
|
180
|
+
return caps.platformVersion >= 6
|
|
181
|
+
},() => {
|
|
182
|
+
// ...
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Parameters
|
|
187
|
+
|
|
188
|
+
- `caps` **any**
|
|
189
|
+
- `fn` **any**
|
|
190
|
+
|
|
191
|
+
### runOnAndroid
|
|
192
|
+
|
|
193
|
+
Execute code only on Android
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
I.runOnAndroid(() => {
|
|
197
|
+
I.click('io.selendroid.testapp:id/buttonTest');
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Additional filter can be applied by checking for capabilities.
|
|
202
|
+
For instance, this code will be executed only on Android 6.0:
|
|
203
|
+
|
|
204
|
+
```js
|
|
205
|
+
I.runOnAndroid({platformVersion: '6.0'},() => {
|
|
206
|
+
// ...
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Also capabilities can be checked by a function.
|
|
211
|
+
In this case, code will be executed only on Android >= 6.
|
|
212
|
+
|
|
213
|
+
```js
|
|
214
|
+
I.runOnAndroid((caps) => {
|
|
215
|
+
// caps is current config of desiredCapabiliites
|
|
216
|
+
return caps.platformVersion >= 6
|
|
217
|
+
},() => {
|
|
218
|
+
// ...
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### Parameters
|
|
223
|
+
|
|
224
|
+
- `caps` **any**
|
|
225
|
+
- `fn` **any**
|
|
226
|
+
|
|
227
|
+
### runInWeb
|
|
228
|
+
|
|
229
|
+
Execute code only in Web mode.
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
I.runInWeb(() => {
|
|
233
|
+
I.waitForElement('#data');
|
|
234
|
+
I.seeInCurrentUrl('/data');
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### Parameters
|
|
239
|
+
|
|
240
|
+
- `fn` **any**
|
|
241
|
+
|
|
242
|
+
### checkIfAppIsInstalled
|
|
243
|
+
|
|
244
|
+
Returns app installation status.
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
I.checkIfAppIsInstalled("com.example.android.apis");
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### Parameters
|
|
251
|
+
|
|
252
|
+
- `bundleId` **[string][5]** String ID of bundled app
|
|
253
|
+
|
|
254
|
+
Returns **[Promise][6]<[boolean][7]>** Appium: support only Android
|
|
255
|
+
|
|
256
|
+
### seeAppIsInstalled
|
|
257
|
+
|
|
258
|
+
Check if an app is installed.
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
I.seeAppIsInstalled("com.example.android.apis");
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Parameters
|
|
265
|
+
|
|
266
|
+
- `bundleId` **[string][5]** String ID of bundled app
|
|
267
|
+
|
|
268
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
269
|
+
|
|
270
|
+
### seeAppIsNotInstalled
|
|
271
|
+
|
|
272
|
+
Check if an app is not installed.
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
I.seeAppIsNotInstalled("com.example.android.apis");
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Parameters
|
|
279
|
+
|
|
280
|
+
- `bundleId` **[string][5]** String ID of bundled app
|
|
281
|
+
|
|
282
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
283
|
+
|
|
284
|
+
### installApp
|
|
285
|
+
|
|
286
|
+
Install an app on device.
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
I.installApp('/path/to/file.apk');
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### Parameters
|
|
293
|
+
|
|
294
|
+
- `path` **[string][5]** path to apk file
|
|
295
|
+
|
|
296
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
297
|
+
|
|
298
|
+
### removeApp
|
|
299
|
+
|
|
300
|
+
Remove an app from the device.
|
|
301
|
+
|
|
302
|
+
```js
|
|
303
|
+
I.removeApp('appName', 'com.example.android.apis');
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Appium: support only Android
|
|
307
|
+
|
|
308
|
+
#### Parameters
|
|
309
|
+
|
|
310
|
+
- `appId` **[string][5]**
|
|
311
|
+
- `bundleId` **[string][5]?** ID of bundle
|
|
312
|
+
|
|
313
|
+
### resetApp
|
|
314
|
+
|
|
315
|
+
Reset the currently running app for current session.
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
I.resetApp();
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### seeCurrentActivityIs
|
|
322
|
+
|
|
323
|
+
Check current activity on an Android device.
|
|
324
|
+
|
|
325
|
+
```js
|
|
326
|
+
I.seeCurrentActivityIs(".HomeScreenActivity")
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
#### Parameters
|
|
330
|
+
|
|
331
|
+
- `currentActivity` **[string][5]**
|
|
332
|
+
|
|
333
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
334
|
+
|
|
335
|
+
### seeDeviceIsLocked
|
|
336
|
+
|
|
337
|
+
Check whether the device is locked.
|
|
338
|
+
|
|
339
|
+
```js
|
|
340
|
+
I.seeDeviceIsLocked();
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
344
|
+
|
|
345
|
+
### seeDeviceIsUnlocked
|
|
346
|
+
|
|
347
|
+
Check whether the device is not locked.
|
|
348
|
+
|
|
349
|
+
```js
|
|
350
|
+
I.seeDeviceIsUnlocked();
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
354
|
+
|
|
355
|
+
### seeOrientationIs
|
|
356
|
+
|
|
357
|
+
Check the device orientation
|
|
358
|
+
|
|
359
|
+
```js
|
|
360
|
+
I.seeOrientationIs('PORTRAIT');
|
|
361
|
+
I.seeOrientationIs('LANDSCAPE')
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Parameters
|
|
365
|
+
|
|
366
|
+
- `orientation` **(`"LANDSCAPE"` \| `"PORTRAIT"`)** LANDSCAPE or PORTRAITAppium: support Android and iOS
|
|
367
|
+
|
|
368
|
+
Returns **[Promise][6]<void>**
|
|
369
|
+
|
|
370
|
+
### setOrientation
|
|
371
|
+
|
|
372
|
+
Set a device orientation. Will fail, if app will not set orientation
|
|
373
|
+
|
|
374
|
+
```js
|
|
375
|
+
I.setOrientation('PORTRAIT');
|
|
376
|
+
I.setOrientation('LANDSCAPE')
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
#### Parameters
|
|
380
|
+
|
|
381
|
+
- `orientation` **(`"LANDSCAPE"` \| `"PORTRAIT"`)** LANDSCAPE or PORTRAITAppium: support Android and iOS
|
|
382
|
+
|
|
383
|
+
### grabAllContexts
|
|
384
|
+
|
|
385
|
+
Get list of all available contexts
|
|
386
|
+
|
|
387
|
+
let contexts = await I.grabAllContexts();
|
|
388
|
+
|
|
389
|
+
Returns **[Promise][6]<[Array][8]<[string][5]>>** Appium: support Android and iOS
|
|
390
|
+
|
|
391
|
+
### grabContext
|
|
392
|
+
|
|
393
|
+
Retrieve current context
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
let context = await I.grabContext();
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Returns **[Promise][6]<([string][5] | null)>** Appium: support Android and iOS
|
|
400
|
+
|
|
401
|
+
### grabCurrentActivity
|
|
402
|
+
|
|
403
|
+
Get current device activity.
|
|
404
|
+
|
|
405
|
+
```js
|
|
406
|
+
let activity = await I.grabCurrentActivity();
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Returns **[Promise][6]<[string][5]>** Appium: support only Android
|
|
410
|
+
|
|
411
|
+
### grabNetworkConnection
|
|
412
|
+
|
|
413
|
+
Get information about the current network connection (Data/WIFI/Airplane).
|
|
414
|
+
The actual server value will be a number. However WebdriverIO additional
|
|
415
|
+
properties to the response object to allow easier assertions.
|
|
416
|
+
|
|
417
|
+
```js
|
|
418
|
+
let con = await I.grabNetworkConnection();
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Returns **[Promise][6]<{}>** Appium: support only Android
|
|
422
|
+
|
|
423
|
+
### grabOrientation
|
|
424
|
+
|
|
425
|
+
Get current orientation.
|
|
426
|
+
|
|
427
|
+
```js
|
|
428
|
+
let orientation = await I.grabOrientation();
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Returns **[Promise][6]<[string][5]>** Appium: support Android and iOS
|
|
432
|
+
|
|
433
|
+
### grabSettings
|
|
434
|
+
|
|
435
|
+
Get all the currently specified settings.
|
|
436
|
+
|
|
437
|
+
```js
|
|
438
|
+
let settings = await I.grabSettings();
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
Returns **[Promise][6]<[string][5]>** Appium: support Android and iOS
|
|
442
|
+
|
|
443
|
+
### switchToContext
|
|
444
|
+
|
|
445
|
+
Switch to the specified context.
|
|
446
|
+
|
|
447
|
+
#### Parameters
|
|
448
|
+
|
|
449
|
+
- `context` **any** the context to switch to
|
|
450
|
+
|
|
451
|
+
### switchToWeb
|
|
452
|
+
|
|
453
|
+
Switches to web context.
|
|
454
|
+
If no context is provided switches to the first detected web context
|
|
455
|
+
|
|
456
|
+
```js
|
|
457
|
+
// switch to first web context
|
|
458
|
+
I.switchToWeb();
|
|
459
|
+
|
|
460
|
+
// or set the context explicitly
|
|
461
|
+
I.switchToWeb('WEBVIEW_io.selendroid.testapp');
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
#### Parameters
|
|
465
|
+
|
|
466
|
+
- `context` **[string][5]?**
|
|
467
|
+
|
|
468
|
+
Returns **[Promise][6]<void>**
|
|
469
|
+
|
|
470
|
+
### switchToNative
|
|
471
|
+
|
|
472
|
+
Switches to native context.
|
|
473
|
+
By default switches to NATIVE_APP context unless other specified.
|
|
474
|
+
|
|
475
|
+
```js
|
|
476
|
+
I.switchToNative();
|
|
477
|
+
|
|
478
|
+
// or set context explicitly
|
|
479
|
+
I.switchToNative('SOME_OTHER_CONTEXT');
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### Parameters
|
|
483
|
+
|
|
484
|
+
- `context` **any?** (optional, default `null`)
|
|
485
|
+
|
|
486
|
+
Returns **[Promise][6]<void>**
|
|
487
|
+
|
|
488
|
+
### startActivity
|
|
489
|
+
|
|
490
|
+
Start an arbitrary Android activity during a session.
|
|
491
|
+
|
|
492
|
+
```js
|
|
493
|
+
I.startActivity('io.selendroid.testapp', '.RegisterUserActivity');
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Appium: support only Android
|
|
497
|
+
|
|
498
|
+
#### Parameters
|
|
499
|
+
|
|
500
|
+
- `appPackage` **[string][5]**
|
|
501
|
+
- `appActivity` **[string][5]**
|
|
502
|
+
|
|
503
|
+
Returns **[Promise][6]<void>**
|
|
504
|
+
|
|
505
|
+
### setNetworkConnection
|
|
506
|
+
|
|
507
|
+
Set network connection mode.
|
|
508
|
+
|
|
509
|
+
- airplane mode
|
|
510
|
+
- wifi mode
|
|
511
|
+
- data data
|
|
512
|
+
|
|
513
|
+
```js
|
|
514
|
+
I.setNetworkConnection(0) // airplane mode off, wifi off, data off
|
|
515
|
+
I.setNetworkConnection(1) // airplane mode on, wifi off, data off
|
|
516
|
+
I.setNetworkConnection(2) // airplane mode off, wifi on, data off
|
|
517
|
+
I.setNetworkConnection(4) // airplane mode off, wifi off, data on
|
|
518
|
+
I.setNetworkConnection(6) // airplane mode off, wifi on, data on
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
See corresponding [webdriverio reference][9].
|
|
522
|
+
|
|
523
|
+
Appium: support only Android
|
|
524
|
+
|
|
525
|
+
#### Parameters
|
|
526
|
+
|
|
527
|
+
- `value` **[number][10]** The network connection mode bitmask
|
|
528
|
+
|
|
529
|
+
Returns **[Promise][6]<[number][10]>**
|
|
530
|
+
|
|
531
|
+
### setSettings
|
|
532
|
+
|
|
533
|
+
Update the current setting on the device
|
|
534
|
+
|
|
535
|
+
```js
|
|
536
|
+
I.setSettings({cyberdelia: 'open'});
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
#### Parameters
|
|
540
|
+
|
|
541
|
+
- `settings` **[object][11]** objectAppium: support Android and iOS
|
|
542
|
+
|
|
543
|
+
### hideDeviceKeyboard
|
|
544
|
+
|
|
545
|
+
Hide the keyboard.
|
|
546
|
+
|
|
547
|
+
```js
|
|
548
|
+
// taps outside to hide keyboard per default
|
|
549
|
+
I.hideDeviceKeyboard();
|
|
550
|
+
I.hideDeviceKeyboard('tapOutside');
|
|
551
|
+
|
|
552
|
+
// or by pressing key
|
|
553
|
+
I.hideDeviceKeyboard('pressKey', 'Done');
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
Appium: support Android and iOS
|
|
557
|
+
|
|
558
|
+
#### Parameters
|
|
559
|
+
|
|
560
|
+
- `strategy` **(`"tapOutside"` \| `"pressKey"`)?** Desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
|
|
561
|
+
- `key` **[string][5]?** Optional key
|
|
562
|
+
|
|
563
|
+
### sendDeviceKeyEvent
|
|
564
|
+
|
|
565
|
+
Send a key event to the device.
|
|
566
|
+
List of keys: [https://developer.android.com/reference/android/view/KeyEvent.html][12]
|
|
567
|
+
|
|
568
|
+
```js
|
|
569
|
+
I.sendDeviceKeyEvent(3);
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
#### Parameters
|
|
573
|
+
|
|
574
|
+
- `keyValue` **[number][10]** Device specific key value
|
|
575
|
+
|
|
576
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
577
|
+
|
|
578
|
+
### openNotifications
|
|
579
|
+
|
|
580
|
+
Open the notifications panel on the device.
|
|
581
|
+
|
|
582
|
+
```js
|
|
583
|
+
I.openNotifications();
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
Returns **[Promise][6]<void>** Appium: support only Android
|
|
587
|
+
|
|
588
|
+
### makeTouchAction
|
|
589
|
+
|
|
590
|
+
The Touch Action API provides the basis of all gestures that can be
|
|
591
|
+
automated in Appium. At its core is the ability to chain together ad hoc
|
|
592
|
+
individual actions, which will then be applied to an element in the
|
|
593
|
+
application on the device.
|
|
594
|
+
[See complete documentation][13]
|
|
595
|
+
|
|
596
|
+
```js
|
|
597
|
+
I.makeTouchAction("~buttonStartWebviewCD", 'tap');
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
#### Parameters
|
|
601
|
+
|
|
602
|
+
- `locator`
|
|
603
|
+
- `action`
|
|
604
|
+
|
|
605
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
606
|
+
|
|
607
|
+
### tap
|
|
608
|
+
|
|
609
|
+
Taps on element.
|
|
610
|
+
|
|
611
|
+
```js
|
|
612
|
+
I.tap("~buttonStartWebviewCD");
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Shortcut for `makeTouchAction`
|
|
616
|
+
|
|
617
|
+
#### Parameters
|
|
618
|
+
|
|
619
|
+
- `locator` **any**
|
|
620
|
+
|
|
621
|
+
Returns **[Promise][6]<void>**
|
|
622
|
+
|
|
623
|
+
### swipe
|
|
624
|
+
|
|
625
|
+
Perform a swipe on the screen or an element.
|
|
626
|
+
|
|
627
|
+
```js
|
|
628
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
629
|
+
I.swipe(locator, 800, 1200, 1000);
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
[See complete reference][14]
|
|
633
|
+
|
|
634
|
+
#### Parameters
|
|
635
|
+
|
|
636
|
+
- `locator` **([string][5] \| [object][11])**
|
|
637
|
+
- `xoffset` **[number][10]**
|
|
638
|
+
- `yoffset` **[number][10]**
|
|
639
|
+
- `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
640
|
+
|
|
641
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
642
|
+
|
|
643
|
+
### performSwipe
|
|
644
|
+
|
|
645
|
+
Perform a swipe on the screen.
|
|
646
|
+
|
|
647
|
+
```js
|
|
648
|
+
I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 });
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
#### Parameters
|
|
652
|
+
|
|
653
|
+
- `from` **[object][11]**
|
|
654
|
+
- `to` **[object][11]** Appium: support Android and iOS
|
|
655
|
+
|
|
656
|
+
### swipeDown
|
|
657
|
+
|
|
658
|
+
Perform a swipe down on an element.
|
|
659
|
+
|
|
660
|
+
```js
|
|
661
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
662
|
+
I.swipeDown(locator); // simple swipe
|
|
663
|
+
I.swipeDown(locator, 500); // set speed
|
|
664
|
+
I.swipeDown(locator, 1200, 1000); // set offset and speed
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
#### Parameters
|
|
668
|
+
|
|
669
|
+
- `locator` **([string][5] \| [object][11])**
|
|
670
|
+
- `yoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
671
|
+
- `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
672
|
+
|
|
673
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
674
|
+
|
|
675
|
+
### swipeLeft
|
|
676
|
+
|
|
677
|
+
Perform a swipe left on an element.
|
|
678
|
+
|
|
679
|
+
```js
|
|
680
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
681
|
+
I.swipeLeft(locator); // simple swipe
|
|
682
|
+
I.swipeLeft(locator, 500); // set speed
|
|
683
|
+
I.swipeLeft(locator, 1200, 1000); // set offset and speed
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
#### Parameters
|
|
687
|
+
|
|
688
|
+
- `locator` **([string][5] \| [object][11])**
|
|
689
|
+
- `xoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
690
|
+
- `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
691
|
+
|
|
692
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
693
|
+
|
|
694
|
+
### swipeRight
|
|
695
|
+
|
|
696
|
+
Perform a swipe right on an element.
|
|
697
|
+
|
|
698
|
+
```js
|
|
699
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
700
|
+
I.swipeRight(locator); // simple swipe
|
|
701
|
+
I.swipeRight(locator, 500); // set speed
|
|
702
|
+
I.swipeRight(locator, 1200, 1000); // set offset and speed
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
#### Parameters
|
|
706
|
+
|
|
707
|
+
- `locator` **([string][5] \| [object][11])**
|
|
708
|
+
- `xoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
709
|
+
- `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
710
|
+
|
|
711
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
712
|
+
|
|
713
|
+
### swipeUp
|
|
714
|
+
|
|
715
|
+
Perform a swipe up on an element.
|
|
716
|
+
|
|
717
|
+
```js
|
|
718
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
719
|
+
I.swipeUp(locator); // simple swipe
|
|
720
|
+
I.swipeUp(locator, 500); // set speed
|
|
721
|
+
I.swipeUp(locator, 1200, 1000); // set offset and speed
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
#### Parameters
|
|
725
|
+
|
|
726
|
+
- `locator` **([string][5] \| [object][11])**
|
|
727
|
+
- `yoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
728
|
+
- `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
729
|
+
|
|
730
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
731
|
+
|
|
732
|
+
### swipeTo
|
|
733
|
+
|
|
734
|
+
Perform a swipe in selected direction on an element to searchable element.
|
|
735
|
+
|
|
736
|
+
```js
|
|
737
|
+
I.swipeTo(
|
|
738
|
+
"android.widget.CheckBox", // searchable element
|
|
739
|
+
"//android.widget.ScrollView/android.widget.LinearLayout", // scroll element
|
|
740
|
+
"up", // direction
|
|
741
|
+
30,
|
|
742
|
+
100,
|
|
743
|
+
500);
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
#### Parameters
|
|
747
|
+
|
|
748
|
+
- `searchableLocator` **[string][5]**
|
|
749
|
+
- `scrollLocator` **[string][5]**
|
|
750
|
+
- `direction` **[string][5]**
|
|
751
|
+
- `timeout` **[number][10]**
|
|
752
|
+
- `offset` **[number][10]**
|
|
753
|
+
- `speed` **[number][10]**
|
|
754
|
+
|
|
755
|
+
Returns **[Promise][6]<void>** Appium: support Android and iOS
|
|
756
|
+
|
|
757
|
+
### touchPerform
|
|
758
|
+
|
|
759
|
+
Performs a specific touch action.
|
|
760
|
+
The action object need to contain the action name, x/y coordinates
|
|
761
|
+
|
|
762
|
+
```js
|
|
763
|
+
I.touchPerform([{
|
|
764
|
+
action: 'press',
|
|
765
|
+
options: {
|
|
766
|
+
x: 100,
|
|
767
|
+
y: 200
|
|
768
|
+
}
|
|
769
|
+
}, {action: 'release'}])
|
|
770
|
+
|
|
771
|
+
I.touchPerform([{
|
|
772
|
+
action: 'tap',
|
|
773
|
+
options: {
|
|
774
|
+
element: '1', // json web element was queried before
|
|
775
|
+
x: 10, // x offset
|
|
776
|
+
y: 20, // y offset
|
|
777
|
+
count: 1 // number of touches
|
|
778
|
+
}
|
|
779
|
+
}]);
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
Appium: support Android and iOS
|
|
783
|
+
|
|
784
|
+
#### Parameters
|
|
785
|
+
|
|
786
|
+
- `actions` **[Array][8]** Array of touch actions
|
|
787
|
+
|
|
788
|
+
### pullFile
|
|
789
|
+
|
|
790
|
+
Pulls a file from the device.
|
|
791
|
+
|
|
792
|
+
```js
|
|
793
|
+
I.pullFile('/storage/emulated/0/DCIM/logo.png', 'my/path');
|
|
794
|
+
// save file to output dir
|
|
795
|
+
I.pullFile('/storage/emulated/0/DCIM/logo.png', output_dir);
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
#### Parameters
|
|
799
|
+
|
|
800
|
+
- `path` **[string][5]**
|
|
801
|
+
- `dest` **[string][5]**
|
|
802
|
+
|
|
803
|
+
Returns **[Promise][6]<[string][5]>** Appium: support Android and iOS
|
|
804
|
+
|
|
805
|
+
### shakeDevice
|
|
806
|
+
|
|
807
|
+
Perform a shake action on the device.
|
|
808
|
+
|
|
809
|
+
```js
|
|
810
|
+
I.shakeDevice();
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
Returns **[Promise][6]<void>** Appium: support only iOS
|
|
814
|
+
|
|
815
|
+
### rotate
|
|
816
|
+
|
|
817
|
+
Perform a rotation gesture centered on the specified element.
|
|
818
|
+
|
|
819
|
+
```js
|
|
820
|
+
I.rotate(120, 120)
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
See corresponding [webdriverio reference][15].
|
|
824
|
+
|
|
825
|
+
#### Parameters
|
|
826
|
+
|
|
827
|
+
- `x`
|
|
828
|
+
- `y`
|
|
829
|
+
- `duration`
|
|
830
|
+
- `radius`
|
|
831
|
+
- `rotation`
|
|
832
|
+
- `touchCount`
|
|
833
|
+
|
|
834
|
+
Returns **[Promise][6]<void>** Appium: support only iOS
|
|
835
|
+
|
|
836
|
+
### setImmediateValue
|
|
837
|
+
|
|
838
|
+
Set immediate value in app.
|
|
839
|
+
|
|
840
|
+
See corresponding [webdriverio reference][16].
|
|
841
|
+
|
|
842
|
+
#### Parameters
|
|
843
|
+
|
|
844
|
+
- `id`
|
|
845
|
+
- `value`
|
|
846
|
+
|
|
847
|
+
Returns **[Promise][6]<void>** Appium: support only iOS
|
|
848
|
+
|
|
849
|
+
### simulateTouchId
|
|
850
|
+
|
|
851
|
+
Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
|
|
852
|
+
|
|
853
|
+
```js
|
|
854
|
+
I.touchId(); // simulates valid fingerprint
|
|
855
|
+
I.touchId(true); // simulates valid fingerprint
|
|
856
|
+
I.touchId(false); // simulates invalid fingerprint
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
#### Parameters
|
|
860
|
+
|
|
861
|
+
- `match`
|
|
862
|
+
|
|
863
|
+
Returns **[Promise][6]<void>** Appium: support only iOS
|
|
864
|
+
TODO: not tested
|
|
865
|
+
|
|
866
|
+
### closeApp
|
|
867
|
+
|
|
868
|
+
Close the given application.
|
|
869
|
+
|
|
870
|
+
```js
|
|
871
|
+
I.closeApp();
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Returns **[Promise][6]<void>** Appium: support both Android and iOS
|
|
875
|
+
|
|
876
|
+
### appendField
|
|
877
|
+
|
|
878
|
+
Appends text to a input field or textarea.
|
|
879
|
+
Field is located by name, label, CSS or XPath
|
|
880
|
+
|
|
881
|
+
```js
|
|
882
|
+
I.appendField('#myTextField', 'appended');
|
|
883
|
+
// typing secret
|
|
884
|
+
I.appendField('password', secret('123456'));
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
#### Parameters
|
|
888
|
+
|
|
889
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator
|
|
890
|
+
- `value` **[string][5]** text value to append.
|
|
891
|
+
|
|
892
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
893
|
+
|
|
894
|
+
### checkOption
|
|
895
|
+
|
|
896
|
+
Selects a checkbox or radio button.
|
|
897
|
+
Element is located by label or name or CSS or XPath.
|
|
898
|
+
|
|
899
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
900
|
+
|
|
901
|
+
```js
|
|
902
|
+
I.checkOption('#agree');
|
|
903
|
+
I.checkOption('I Agree to Terms and Conditions');
|
|
904
|
+
I.checkOption('agree', '//form');
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### Parameters
|
|
908
|
+
|
|
909
|
+
- `field` **([string][5] \| [object][11])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
910
|
+
- `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
|
|
911
|
+
|
|
912
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
913
|
+
|
|
914
|
+
### click
|
|
915
|
+
|
|
916
|
+
Perform a click on a link or a button, given by a locator.
|
|
917
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
918
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
919
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
920
|
+
|
|
921
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
922
|
+
|
|
923
|
+
```js
|
|
924
|
+
// simple link
|
|
925
|
+
I.click('Logout');
|
|
926
|
+
// button of form
|
|
927
|
+
I.click('Submit');
|
|
928
|
+
// CSS button
|
|
929
|
+
I.click('#form input[type=submit]');
|
|
930
|
+
// XPath
|
|
931
|
+
I.click('//form/*[@type=submit]');
|
|
932
|
+
// link in context
|
|
933
|
+
I.click('Logout', '#nav');
|
|
934
|
+
// using strict locator
|
|
935
|
+
I.click({css: 'nav a.login'});
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
#### Parameters
|
|
939
|
+
|
|
940
|
+
- `locator` **([string][5] \| [object][11])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
941
|
+
- `context` **([string][5]? | [object][11] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator. (optional, default `null`)
|
|
942
|
+
|
|
943
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
944
|
+
|
|
945
|
+
### dontSeeCheckboxIsChecked
|
|
946
|
+
|
|
947
|
+
Verifies that the specified checkbox is not checked.
|
|
948
|
+
|
|
949
|
+
```js
|
|
950
|
+
I.dontSeeCheckboxIsChecked('#agree'); // located by ID
|
|
951
|
+
I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
952
|
+
I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
#### Parameters
|
|
956
|
+
|
|
957
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator.
|
|
958
|
+
|
|
959
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
960
|
+
|
|
961
|
+
### dontSeeElement
|
|
962
|
+
|
|
963
|
+
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
964
|
+
|
|
965
|
+
```js
|
|
966
|
+
I.dontSeeElement('.modal'); // modal is not shown
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
#### Parameters
|
|
970
|
+
|
|
971
|
+
- `locator` **([string][5] \| [object][11])** located by CSS|XPath|Strict locator.
|
|
972
|
+
|
|
973
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
974
|
+
|
|
975
|
+
### dontSeeInField
|
|
976
|
+
|
|
977
|
+
Checks that value of input field or textarea doesn't equal to given value
|
|
978
|
+
Opposite to `seeInField`.
|
|
979
|
+
|
|
980
|
+
```js
|
|
981
|
+
I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
982
|
+
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
#### Parameters
|
|
986
|
+
|
|
987
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator.
|
|
988
|
+
- `value` **([string][5] \| [object][11])** value to check.
|
|
989
|
+
|
|
990
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
991
|
+
|
|
992
|
+
### dontSee
|
|
993
|
+
|
|
994
|
+
Opposite to `see`. Checks that a text is not present on a page.
|
|
995
|
+
Use context parameter to narrow down the search.
|
|
996
|
+
|
|
997
|
+
```js
|
|
998
|
+
I.dontSee('Login'); // assume we are already logged in.
|
|
999
|
+
I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
#### Parameters
|
|
1003
|
+
|
|
1004
|
+
- `text` **[string][5]** which is not present.
|
|
1005
|
+
- `context` **([string][5] \| [object][11])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search. (optional, default `null`)
|
|
1006
|
+
|
|
1007
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1008
|
+
|
|
1009
|
+
### fillField
|
|
1010
|
+
|
|
1011
|
+
Fills a text field or textarea, after clearing its value, with the given string.
|
|
1012
|
+
Field is located by name, label, CSS, or XPath.
|
|
1013
|
+
|
|
1014
|
+
```js
|
|
1015
|
+
// by label
|
|
1016
|
+
I.fillField('Email', 'hello@world.com');
|
|
1017
|
+
// by name
|
|
1018
|
+
I.fillField('password', secret('123456'));
|
|
1019
|
+
// by CSS
|
|
1020
|
+
I.fillField('form#login input[name=username]', 'John');
|
|
1021
|
+
// or by strict locator
|
|
1022
|
+
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
#### Parameters
|
|
1026
|
+
|
|
1027
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator.
|
|
1028
|
+
- `value` **([string][5] \| [object][11])** text value to fill.
|
|
1029
|
+
|
|
1030
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1031
|
+
|
|
1032
|
+
### grabTextFromAll
|
|
1033
|
+
|
|
1034
|
+
Retrieves all texts from an element located by CSS or XPath and returns it to test.
|
|
1035
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1036
|
+
|
|
1037
|
+
```js
|
|
1038
|
+
let pins = await I.grabTextFromAll('#pin li');
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
#### Parameters
|
|
1042
|
+
|
|
1043
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1044
|
+
|
|
1045
|
+
Returns **[Promise][6]<[Array][8]<[string][5]>>** attribute value
|
|
1046
|
+
|
|
1047
|
+
### grabTextFrom
|
|
1048
|
+
|
|
1049
|
+
Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
1050
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1051
|
+
|
|
1052
|
+
```js
|
|
1053
|
+
let pin = await I.grabTextFrom('#pin');
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
If multiple elements found returns first element.
|
|
1057
|
+
|
|
1058
|
+
#### Parameters
|
|
1059
|
+
|
|
1060
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1061
|
+
|
|
1062
|
+
Returns **[Promise][6]<[string][5]>** attribute value
|
|
1063
|
+
|
|
1064
|
+
### grabNumberOfVisibleElements
|
|
1065
|
+
|
|
1066
|
+
Grab number of visible elements by locator.
|
|
1067
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1068
|
+
|
|
1069
|
+
```js
|
|
1070
|
+
let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
#### Parameters
|
|
1074
|
+
|
|
1075
|
+
- `locator` **([string][5] \| [object][11])** located by CSS|XPath|strict locator.
|
|
1076
|
+
|
|
1077
|
+
Returns **[Promise][6]<[number][10]>** number of visible elements
|
|
1078
|
+
|
|
1079
|
+
### grabAttributeFrom
|
|
1080
|
+
|
|
1081
|
+
Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
1082
|
+
|
|
1083
|
+
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
1084
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1085
|
+
If more than one element is found - attribute of first element is returned.
|
|
1086
|
+
|
|
1087
|
+
```js
|
|
1088
|
+
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
#### Parameters
|
|
1092
|
+
|
|
1093
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1094
|
+
- `attr` **[string][5]** attribute name.
|
|
1095
|
+
|
|
1096
|
+
Returns **[Promise][6]<[string][5]>** attribute value
|
|
1097
|
+
|
|
1098
|
+
### grabAttributeFromAll
|
|
1099
|
+
|
|
1100
|
+
Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
1101
|
+
Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
|
|
1102
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1103
|
+
|
|
1104
|
+
```js
|
|
1105
|
+
let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
#### Parameters
|
|
1109
|
+
|
|
1110
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1111
|
+
- `attr` **[string][5]** attribute name.
|
|
1112
|
+
|
|
1113
|
+
Returns **[Promise][6]<[Array][8]<[string][5]>>** attribute value
|
|
1114
|
+
|
|
1115
|
+
### grabValueFromAll
|
|
1116
|
+
|
|
1117
|
+
Retrieves an array of value from a form located by CSS or XPath and returns it to test.
|
|
1118
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1119
|
+
|
|
1120
|
+
```js
|
|
1121
|
+
let inputs = await I.grabValueFromAll('//form/input');
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
#### Parameters
|
|
1125
|
+
|
|
1126
|
+
- `locator` **([string][5] \| [object][11])** field located by label|name|CSS|XPath|strict locator.
|
|
1127
|
+
|
|
1128
|
+
Returns **[Promise][6]<[Array][8]<[string][5]>>** attribute value
|
|
1129
|
+
|
|
1130
|
+
### grabValueFrom
|
|
1131
|
+
|
|
1132
|
+
Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
1133
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1134
|
+
If more than one element is found - value of first element is returned.
|
|
1135
|
+
|
|
1136
|
+
```js
|
|
1137
|
+
let email = await I.grabValueFrom('input[name=email]');
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
#### Parameters
|
|
1141
|
+
|
|
1142
|
+
- `locator` **([string][5] \| [object][11])** field located by label|name|CSS|XPath|strict locator.
|
|
1143
|
+
|
|
1144
|
+
Returns **[Promise][6]<[string][5]>** attribute value
|
|
1145
|
+
|
|
1146
|
+
### saveScreenshot
|
|
1147
|
+
|
|
1148
|
+
Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
1149
|
+
Filename is relative to output folder.
|
|
1150
|
+
|
|
1151
|
+
```js
|
|
1152
|
+
I.saveScreenshot('debug.png');
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
#### Parameters
|
|
1156
|
+
|
|
1157
|
+
- `fileName` **[string][5]** file name to save.
|
|
1158
|
+
|
|
1159
|
+
Returns **[Promise][6]<void>**
|
|
1160
|
+
|
|
1161
|
+
### scrollIntoView
|
|
1162
|
+
|
|
1163
|
+
Scroll element into viewport.
|
|
1164
|
+
|
|
1165
|
+
```js
|
|
1166
|
+
I.scrollIntoView('#submit');
|
|
1167
|
+
I.scrollIntoView('#submit', true);
|
|
1168
|
+
I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
#### Parameters
|
|
1172
|
+
|
|
1173
|
+
- `locator` **([string][5] \| [object][11])** located by CSS|XPath|strict locator.
|
|
1174
|
+
- `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][7])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][17].
|
|
1175
|
+
|
|
1176
|
+
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
|
|
1177
|
+
|
|
1178
|
+
### seeCheckboxIsChecked
|
|
1179
|
+
|
|
1180
|
+
Verifies that the specified checkbox is checked.
|
|
1181
|
+
|
|
1182
|
+
```js
|
|
1183
|
+
I.seeCheckboxIsChecked('Agree');
|
|
1184
|
+
I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1185
|
+
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1186
|
+
```
|
|
1187
|
+
|
|
1188
|
+
#### Parameters
|
|
1189
|
+
|
|
1190
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator.
|
|
1191
|
+
|
|
1192
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1193
|
+
|
|
1194
|
+
### seeElement
|
|
1195
|
+
|
|
1196
|
+
Checks that a given Element is visible
|
|
1197
|
+
Element is located by CSS or XPath.
|
|
1198
|
+
|
|
1199
|
+
```js
|
|
1200
|
+
I.seeElement('#modal');
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
#### Parameters
|
|
1204
|
+
|
|
1205
|
+
- `locator` **([string][5] \| [object][11])** located by CSS|XPath|strict locator.
|
|
1206
|
+
|
|
1207
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1208
|
+
|
|
1209
|
+
### seeInField
|
|
1210
|
+
|
|
1211
|
+
Checks that the given input field or textarea equals to given value.
|
|
1212
|
+
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1213
|
+
|
|
1214
|
+
```js
|
|
1215
|
+
I.seeInField('Username', 'davert');
|
|
1216
|
+
I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1217
|
+
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1218
|
+
I.seeInField('#searchform input','Search');
|
|
1219
|
+
```
|
|
1220
|
+
|
|
1221
|
+
#### Parameters
|
|
1222
|
+
|
|
1223
|
+
- `field` **([string][5] \| [object][11])** located by label|name|CSS|XPath|strict locator.
|
|
1224
|
+
- `value` **([string][5] \| [object][11])** value to check.
|
|
1225
|
+
|
|
1226
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1227
|
+
|
|
1228
|
+
### see
|
|
1229
|
+
|
|
1230
|
+
Checks that a page contains a visible text.
|
|
1231
|
+
Use context parameter to narrow down the search.
|
|
1232
|
+
|
|
1233
|
+
```js
|
|
1234
|
+
I.see('Welcome'); // text welcome on a page
|
|
1235
|
+
I.see('Welcome', '.content'); // text inside .content div
|
|
1236
|
+
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
#### Parameters
|
|
1240
|
+
|
|
1241
|
+
- `text` **[string][5]** expected on page.
|
|
1242
|
+
- `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text. (optional, default `null`)
|
|
1243
|
+
|
|
1244
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1245
|
+
|
|
1246
|
+
### selectOption
|
|
1247
|
+
|
|
1248
|
+
Selects an option in a drop-down select.
|
|
1249
|
+
Field is searched by label | name | CSS | XPath.
|
|
1250
|
+
Option is selected by visible text or by value.
|
|
1251
|
+
|
|
1252
|
+
```js
|
|
1253
|
+
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
1254
|
+
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
1255
|
+
I.selectOption('subscription', '0'); // or by value
|
|
1256
|
+
I.selectOption('//form/select[@name=account]','Premium');
|
|
1257
|
+
I.selectOption('form select[name=account]', 'Premium');
|
|
1258
|
+
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
Provide an array for the second argument to select multiple options.
|
|
1262
|
+
|
|
1263
|
+
```js
|
|
1264
|
+
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
#### Parameters
|
|
1268
|
+
|
|
1269
|
+
- `select` **([string][5] \| [object][11])** field located by label|name|CSS|XPath|strict locator.
|
|
1270
|
+
- `option` **([string][5] \| [Array][8]<any>)** visible text or value of option.
|
|
1271
|
+
|
|
1272
|
+
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
|
|
1273
|
+
|
|
1274
|
+
### waitForElement
|
|
1275
|
+
|
|
1276
|
+
Waits for element to be present on page (by default waits for 1sec).
|
|
1277
|
+
Element can be located by CSS or XPath.
|
|
1278
|
+
|
|
1279
|
+
```js
|
|
1280
|
+
I.waitForElement('.btn.continue');
|
|
1281
|
+
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
#### Parameters
|
|
1285
|
+
|
|
1286
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1287
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait (optional, default `null`)
|
|
1288
|
+
|
|
1289
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1290
|
+
|
|
1291
|
+
### waitForVisible
|
|
1292
|
+
|
|
1293
|
+
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
1294
|
+
Element can be located by CSS or XPath.
|
|
1295
|
+
|
|
1296
|
+
```js
|
|
1297
|
+
I.waitForVisible('#popup');
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
#### Parameters
|
|
1301
|
+
|
|
1302
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1303
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
1304
|
+
|
|
1305
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1306
|
+
|
|
1307
|
+
### waitForInvisible
|
|
1308
|
+
|
|
1309
|
+
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
1310
|
+
Element can be located by CSS or XPath.
|
|
1311
|
+
|
|
1312
|
+
```js
|
|
1313
|
+
I.waitForInvisible('#popup');
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
#### Parameters
|
|
1317
|
+
|
|
1318
|
+
- `locator` **([string][5] \| [object][11])** element located by CSS|XPath|strict locator.
|
|
1319
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
1320
|
+
|
|
1321
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1322
|
+
|
|
1323
|
+
### waitForText
|
|
1324
|
+
|
|
1325
|
+
Waits for a text to appear (by default waits for 1sec).
|
|
1326
|
+
Element can be located by CSS or XPath.
|
|
1327
|
+
Narrow down search results by providing context.
|
|
1328
|
+
|
|
1329
|
+
```js
|
|
1330
|
+
I.waitForText('Thank you, form has been submitted');
|
|
1331
|
+
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
1332
|
+
```
|
|
1333
|
+
|
|
1334
|
+
#### Parameters
|
|
1335
|
+
|
|
1336
|
+
- `text` **[string][5]** to wait for.
|
|
1337
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
1338
|
+
- `context` **([string][5] \| [object][11])?** (optional) element located by CSS|XPath|strict locator. (optional, default `null`)
|
|
1339
|
+
|
|
1340
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1341
|
+
|
|
1342
|
+
[1]: http://codecept.io/helpers/WebDriver/
|
|
1343
|
+
|
|
1344
|
+
[2]: https://appium.io/docs/en/2.1/
|
|
1345
|
+
|
|
1346
|
+
[3]: https://codecept.io/mobile/#setting-up
|
|
1347
|
+
|
|
1348
|
+
[4]: https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/caps.md
|
|
1349
|
+
|
|
1350
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1351
|
+
|
|
1352
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1353
|
+
|
|
1354
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
1355
|
+
|
|
1356
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1357
|
+
|
|
1358
|
+
[9]: https://webdriver.io/docs/api/chromium/#setnetworkconnection
|
|
1359
|
+
|
|
1360
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
1361
|
+
|
|
1362
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
1363
|
+
|
|
1364
|
+
[12]: https://developer.android.com/reference/android/view/KeyEvent.html
|
|
1365
|
+
|
|
1366
|
+
[13]: http://webdriver.io/api/mobile/touchAction.html
|
|
1367
|
+
|
|
1368
|
+
[14]: http://webdriver.io/api/mobile/swipe.html
|
|
1369
|
+
|
|
1370
|
+
[15]: http://webdriver.io/api/mobile/rotate.html
|
|
1371
|
+
|
|
1372
|
+
[16]: http://webdriver.io/api/mobile/setImmediateValue.html
|
|
1373
|
+
|
|
1374
|
+
[17]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|