codeceptjs 3.5.14 → 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/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 +7 -10
- package/lib/helper/JSONResponse.js +8 -8
- package/lib/helper/Playwright.js +240 -100
- package/lib/helper/Puppeteer.js +9 -61
- 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/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 +23 -27
- package/typings/index.d.ts +0 -16
- package/typings/promiseBasedTypes.d.ts +55 -338
- package/typings/types.d.ts +58 -353
- 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,586 @@
|
|
|
1
|
+
---
|
|
2
|
+
permalink: /helpers/Detox
|
|
3
|
+
sidebar: auto
|
|
4
|
+
title: Detox
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Detox
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
11
|
+
|
|
12
|
+
## Detox
|
|
13
|
+
|
|
14
|
+
**Extends Helper**
|
|
15
|
+
|
|
16
|
+
This is a wrapper on top of [Detox][1] library, aimied to unify testing experience for CodeceptJS framework.
|
|
17
|
+
Detox provides a grey box testing for mobile applications, playing especially good for React Native apps.
|
|
18
|
+
|
|
19
|
+
Detox plays quite differently from Appium. To establish detox testing you need to build a mobile application in a special way to inject Detox code.
|
|
20
|
+
This why **Detox is grey box testing** solution, so you need an access to application source code, and a way to build and execute it on emulator.
|
|
21
|
+
|
|
22
|
+
Comparing to Appium, Detox runs faster and more stable but requires an additional setup for build.
|
|
23
|
+
|
|
24
|
+
### Setup
|
|
25
|
+
|
|
26
|
+
1. [Install and configure Detox for iOS][2] and [Android][3]
|
|
27
|
+
2. [Build an application][4] using `detox build` command.
|
|
28
|
+
3. Install [CodeceptJS][5] and detox-helper:
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
npm i @codeceptjs/detox-helper --save
|
|
32
|
+
|
|
33
|
+
Detox configuration is required in `package.json` under `detox` section.
|
|
34
|
+
|
|
35
|
+
If you completed step 1 and step 2 you should have a configuration similar this:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
"detox": {
|
|
39
|
+
"configurations": {
|
|
40
|
+
"ios.sim.debug": {
|
|
41
|
+
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
|
|
42
|
+
"build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
|
|
43
|
+
"type": "ios.simulator",
|
|
44
|
+
"name": "iPhone 7"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Configuration
|
|
51
|
+
|
|
52
|
+
Besides Detox configuration, CodeceptJS should also be configured to use Detox.
|
|
53
|
+
|
|
54
|
+
In `codecept.conf.js` enable Detox helper:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
helpers: {
|
|
58
|
+
Detox: {
|
|
59
|
+
require: '@codeceptjs/detox-helper',
|
|
60
|
+
configuration: '<detox-configuration-name>',
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
It's important to specify a package name under `require` section and current detox configuration taken from `package.json`.
|
|
66
|
+
|
|
67
|
+
Options:
|
|
68
|
+
|
|
69
|
+
- `configuration` - a detox configuration name. Required.
|
|
70
|
+
- `reloadReactNative` - should be enabled for React Native applications.
|
|
71
|
+
- `reuse` - reuse application for tests. By default, Detox reinstalls and relaunches app.
|
|
72
|
+
- `registerGlobals` - (default: true) Register Detox helper functions `by`, `element`, `expect`, `waitFor` globally.
|
|
73
|
+
|
|
74
|
+
### Parameters
|
|
75
|
+
|
|
76
|
+
- `config`
|
|
77
|
+
|
|
78
|
+
### appendField
|
|
79
|
+
|
|
80
|
+
Appends text into the field.
|
|
81
|
+
A field can be located by text, accessibility id, id.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
I.appendField('name', 'davert');
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
- `field` **([string][6] \| [object][7])**
|
|
90
|
+
- `value` **[string][6]**
|
|
91
|
+
|
|
92
|
+
### clearField
|
|
93
|
+
|
|
94
|
+
Clears a text field.
|
|
95
|
+
A field can be located by text, accessibility id, id.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
I.clearField('~name');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Parameters
|
|
102
|
+
|
|
103
|
+
- `field` **([string][6] \| [object][7])** an input element to clear
|
|
104
|
+
|
|
105
|
+
### click
|
|
106
|
+
|
|
107
|
+
Clicks on an element.
|
|
108
|
+
Element can be located by its text or id or accessibility id
|
|
109
|
+
|
|
110
|
+
The second parameter is a context (id | type | accessibility id) to narrow the search.
|
|
111
|
+
|
|
112
|
+
Same as [tap][8]
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
I.click('Login'); // locate by text
|
|
116
|
+
I.click('~nav-1'); // locate by accessibility label
|
|
117
|
+
I.click('#user'); // locate by id
|
|
118
|
+
I.click('Login', '#nav'); // locate by text inside #nav
|
|
119
|
+
I.click({ ios: 'Save', android: 'SAVE' }, '#main'); // different texts on iOS and Android
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Parameters
|
|
123
|
+
|
|
124
|
+
- `locator` **([string][6] \| [object][7])**
|
|
125
|
+
- `context` **([string][6] \| [object][7] | null)** (optional, default `null`)
|
|
126
|
+
|
|
127
|
+
### clickAtPoint
|
|
128
|
+
|
|
129
|
+
Performs click on element with horizontal and vertical offset.
|
|
130
|
+
An element is located by text, id, accessibility id.
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
I.clickAtPoint('Save', 10, 10);
|
|
134
|
+
I.clickAtPoint('~save', 10, 10); // locate by accessibility id
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Parameters
|
|
138
|
+
|
|
139
|
+
- `locator` **([string][6] \| [object][7])**
|
|
140
|
+
- `x` **[number][9]** horizontal offset (optional, default `0`)
|
|
141
|
+
- `y` **[number][9]** vertical offset (optional, default `0`)
|
|
142
|
+
|
|
143
|
+
### dontSee
|
|
144
|
+
|
|
145
|
+
Checks text not to be visible.
|
|
146
|
+
Use second parameter to narrow down the search.
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
I.dontSee('Record created');
|
|
150
|
+
I.dontSee('Record updated', '#message');
|
|
151
|
+
I.dontSee('Record deleted', '~message');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Parameters
|
|
155
|
+
|
|
156
|
+
- `text` **[string][6]** to check invisibility
|
|
157
|
+
- `context` **([string][6] \| [object][7] | null)** element in which to search for text (optional, default `null`)
|
|
158
|
+
|
|
159
|
+
### dontSeeElement
|
|
160
|
+
|
|
161
|
+
Checks that element is not visible.
|
|
162
|
+
Use second parameter to narrow down the search.
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
I.dontSeeElement('~edit'); // located by accessibility id
|
|
166
|
+
I.dontSeeElement('~edit', '#menu'); // element inside #menu
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Parameters
|
|
170
|
+
|
|
171
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
172
|
+
- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`)
|
|
173
|
+
|
|
174
|
+
### dontSeeElementExists
|
|
175
|
+
|
|
176
|
+
Checks that element not exists.
|
|
177
|
+
Use second parameter to narrow down the search.
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
I.dontSeeElementExist('~edit'); // located by accessibility id
|
|
181
|
+
I.dontSeeElementExist('~edit', '#menu'); // element inside #menu
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Parameters
|
|
185
|
+
|
|
186
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
187
|
+
- `context` **([string][6] \| [object][7])** context element (optional, default `null`)
|
|
188
|
+
|
|
189
|
+
### fillField
|
|
190
|
+
|
|
191
|
+
Fills in text field in an app.
|
|
192
|
+
A field can be located by text, accessibility id, id.
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
I.fillField('Username', 'davert');
|
|
196
|
+
I.fillField('~name', 'davert');
|
|
197
|
+
I.fillField({ android: 'NAME', ios: 'name' }, 'davert');
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Parameters
|
|
201
|
+
|
|
202
|
+
- `field` **([string][6] \| [object][7])** an input element to fill in
|
|
203
|
+
- `value` **[string][6]** value to fill
|
|
204
|
+
|
|
205
|
+
### goBack
|
|
206
|
+
|
|
207
|
+
Goes back on Android
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
I.goBack(); // on Android only
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### installApp
|
|
214
|
+
|
|
215
|
+
Installs a configured application.
|
|
216
|
+
Application is installed by default.
|
|
217
|
+
|
|
218
|
+
```js
|
|
219
|
+
I.installApp();
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### launchApp
|
|
223
|
+
|
|
224
|
+
Launches an application. If application instance already exists, use [relaunchApp][10].
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
I.launchApp();
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### longPress
|
|
231
|
+
|
|
232
|
+
Taps an element and holds for a requested time.
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
I.longPress('Login', 2); // locate by text, hold for 2 seconds
|
|
236
|
+
I.longPress('~nav', 1); // locate by accessibility label, hold for second
|
|
237
|
+
I.longPress('Update', 2, '#menu'); // locate by text inside #menu, hold for 2 seconds
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Parameters
|
|
241
|
+
|
|
242
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
243
|
+
- `sec` **[number][9]** number of seconds to hold tap
|
|
244
|
+
- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`)
|
|
245
|
+
|
|
246
|
+
### multiTap
|
|
247
|
+
|
|
248
|
+
Multi taps on an element.
|
|
249
|
+
Element can be located by its text or id or accessibility id.
|
|
250
|
+
|
|
251
|
+
Set the number of taps in second argument.
|
|
252
|
+
Optionally define the context element by third argument.
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
I.multiTap('Login', 2); // locate by text
|
|
256
|
+
I.multiTap('~nav', 2); // locate by accessibility label
|
|
257
|
+
I.multiTap('#user', 2); // locate by id
|
|
258
|
+
I.multiTap('Update', 2, '#menu'); // locate by id
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Parameters
|
|
262
|
+
|
|
263
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
264
|
+
- `num` **[number][9]** number of taps
|
|
265
|
+
- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`)
|
|
266
|
+
|
|
267
|
+
### relaunchApp
|
|
268
|
+
|
|
269
|
+
Relaunches an application.
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
I.relaunchApp();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### runOnAndroid
|
|
276
|
+
|
|
277
|
+
Execute code only on Android
|
|
278
|
+
|
|
279
|
+
```js
|
|
280
|
+
I.runOnAndroid(() => {
|
|
281
|
+
I.click('Button');
|
|
282
|
+
I.see('Hi, Android');
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### Parameters
|
|
287
|
+
|
|
288
|
+
- `fn` **[Function][11]** a function which will be executed on android
|
|
289
|
+
|
|
290
|
+
### runOnIOS
|
|
291
|
+
|
|
292
|
+
Execute code only on iOS
|
|
293
|
+
|
|
294
|
+
```js
|
|
295
|
+
I.runOnIOS(() => {
|
|
296
|
+
I.click('Button');
|
|
297
|
+
I.see('Hi, IOS');
|
|
298
|
+
});
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### Parameters
|
|
302
|
+
|
|
303
|
+
- `fn` **[Function][11]** a function which will be executed on iOS
|
|
304
|
+
|
|
305
|
+
### saveScreenshot
|
|
306
|
+
|
|
307
|
+
Saves a screenshot to the output dir
|
|
308
|
+
|
|
309
|
+
```js
|
|
310
|
+
I.saveScreenshot('main-window.png');
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### Parameters
|
|
314
|
+
|
|
315
|
+
- `name` **[string][6]**
|
|
316
|
+
|
|
317
|
+
### scrollDown
|
|
318
|
+
|
|
319
|
+
Scrolls to the bottom of an element.
|
|
320
|
+
|
|
321
|
+
```js
|
|
322
|
+
I.scrollDown('#container');
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
#### Parameters
|
|
326
|
+
|
|
327
|
+
- `locator` **([string][6] \| [object][7])**
|
|
328
|
+
|
|
329
|
+
### scrollLeft
|
|
330
|
+
|
|
331
|
+
Scrolls to the left of an element.
|
|
332
|
+
|
|
333
|
+
```js
|
|
334
|
+
I.scrollLeft('#container');
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
#### Parameters
|
|
338
|
+
|
|
339
|
+
- `locator` **([string][6] \| [object][7])**
|
|
340
|
+
|
|
341
|
+
### scrollRight
|
|
342
|
+
|
|
343
|
+
Scrolls to the right of an element.
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
I.scrollRight('#container');
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### Parameters
|
|
350
|
+
|
|
351
|
+
- `locator` **([string][6] \| [object][7])**
|
|
352
|
+
|
|
353
|
+
### scrollUp
|
|
354
|
+
|
|
355
|
+
Scrolls to the top of an element.
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
I.scrollUp('#container');
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Parameters
|
|
362
|
+
|
|
363
|
+
- `locator` **([string][6] \| [object][7])**
|
|
364
|
+
|
|
365
|
+
### see
|
|
366
|
+
|
|
367
|
+
Checks text to be visible.
|
|
368
|
+
Use second parameter to narrow down the search.
|
|
369
|
+
|
|
370
|
+
```js
|
|
371
|
+
I.see('Record created');
|
|
372
|
+
I.see('Record updated', '#message');
|
|
373
|
+
I.see('Record deleted', '~message');
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
#### Parameters
|
|
377
|
+
|
|
378
|
+
- `text` **[string][6]** to check visibility
|
|
379
|
+
- `context` **([string][6] \| [object][7] | null)** element inside which to search for text (optional, default `null`)
|
|
380
|
+
|
|
381
|
+
### seeElement
|
|
382
|
+
|
|
383
|
+
Checks for visibility of an element.
|
|
384
|
+
Use second parameter to narrow down the search.
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
I.seeElement('~edit'); // located by accessibility id
|
|
388
|
+
I.seeElement('~edit', '#menu'); // element inside #menu
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
#### Parameters
|
|
392
|
+
|
|
393
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
394
|
+
- `context` **([string][6] \| [object][7] | null)** context element (optional, default `null`)
|
|
395
|
+
|
|
396
|
+
### seeElementExists
|
|
397
|
+
|
|
398
|
+
Checks for existence of an element. An element can be visible or not.
|
|
399
|
+
Use second parameter to narrow down the search.
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
I.seeElementExists('~edit'); // located by accessibility id
|
|
403
|
+
I.seeElementExists('~edit', '#menu'); // element inside #menu
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### Parameters
|
|
407
|
+
|
|
408
|
+
- `locator` **([string][6] \| [object][7])** element to locate
|
|
409
|
+
- `context` **([string][6] \| [object][7])** context element (optional, default `null`)
|
|
410
|
+
|
|
411
|
+
### setLandscapeOrientation
|
|
412
|
+
|
|
413
|
+
Switches device to landscape orientation
|
|
414
|
+
|
|
415
|
+
```js
|
|
416
|
+
I.setLandscapeOrientation();
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### setPortraitOrientation
|
|
420
|
+
|
|
421
|
+
Switches device to portrait orientation
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
I.setPortraitOrientation();
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### shakeDevice
|
|
428
|
+
|
|
429
|
+
Shakes the device.
|
|
430
|
+
|
|
431
|
+
```js
|
|
432
|
+
I.shakeDevice();
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### swipeDown
|
|
436
|
+
|
|
437
|
+
Performs a swipe up inside an element.
|
|
438
|
+
Can be `slow` or `fast` swipe.
|
|
439
|
+
|
|
440
|
+
```js
|
|
441
|
+
I.swipeUp('#container');
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### Parameters
|
|
445
|
+
|
|
446
|
+
- `locator` **([string][6] \| [object][7])** an element on which to perform swipe
|
|
447
|
+
- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`)
|
|
448
|
+
|
|
449
|
+
### swipeLeft
|
|
450
|
+
|
|
451
|
+
Performs a swipe up inside an element.
|
|
452
|
+
Can be `slow` or `fast` swipe.
|
|
453
|
+
|
|
454
|
+
```js
|
|
455
|
+
I.swipeUp('#container');
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
#### Parameters
|
|
459
|
+
|
|
460
|
+
- `locator` **([string][6] \| [object][7])** an element on which to perform swipe
|
|
461
|
+
- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`)
|
|
462
|
+
|
|
463
|
+
### swipeRight
|
|
464
|
+
|
|
465
|
+
Performs a swipe up inside an element.
|
|
466
|
+
Can be `slow` or `fast` swipe.
|
|
467
|
+
|
|
468
|
+
```js
|
|
469
|
+
I.swipeUp('#container');
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
#### Parameters
|
|
473
|
+
|
|
474
|
+
- `locator` **([string][6] \| [object][7])** an element on which to perform swipe
|
|
475
|
+
- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`)
|
|
476
|
+
|
|
477
|
+
### swipeUp
|
|
478
|
+
|
|
479
|
+
Performs a swipe up inside an element.
|
|
480
|
+
Can be `slow` or `fast` swipe.
|
|
481
|
+
|
|
482
|
+
```js
|
|
483
|
+
I.swipeUp('#container');
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
#### Parameters
|
|
487
|
+
|
|
488
|
+
- `locator` **([string][6] \| [object][7])** an element on which to perform swipe
|
|
489
|
+
- `speed` **[string][6]** a speed to perform: `slow` or `fast`. (optional, default `'slow'`)
|
|
490
|
+
|
|
491
|
+
### tap
|
|
492
|
+
|
|
493
|
+
Taps on an element.
|
|
494
|
+
Element can be located by its text or id or accessibility id.
|
|
495
|
+
|
|
496
|
+
The second parameter is a context element to narrow the search.
|
|
497
|
+
|
|
498
|
+
Same as [click][12]
|
|
499
|
+
|
|
500
|
+
```js
|
|
501
|
+
I.tap('Login'); // locate by text
|
|
502
|
+
I.tap('~nav-1'); // locate by accessibility label
|
|
503
|
+
I.tap('#user'); // locate by id
|
|
504
|
+
I.tap('Login', '#nav'); // locate by text inside #nav
|
|
505
|
+
I.tap({ ios: 'Save', android: 'SAVE' }, '#main'); // different texts on iOS and Android
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### Parameters
|
|
509
|
+
|
|
510
|
+
- `locator` **([string][6] \| [object][7])**
|
|
511
|
+
- `context` **([string][6] \| [object][7] | null)** (optional, default `null`)
|
|
512
|
+
|
|
513
|
+
### wait
|
|
514
|
+
|
|
515
|
+
Waits for number of seconds
|
|
516
|
+
|
|
517
|
+
```js
|
|
518
|
+
I.wait(2); // waits for 2 seconds
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
#### Parameters
|
|
522
|
+
|
|
523
|
+
- `sec` **[number][9]** number of seconds to wait
|
|
524
|
+
|
|
525
|
+
### waitForElement
|
|
526
|
+
|
|
527
|
+
Waits for an element to exist on page.
|
|
528
|
+
|
|
529
|
+
```js
|
|
530
|
+
I.waitForElement('#message', 1); // wait for 1 second
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
#### Parameters
|
|
534
|
+
|
|
535
|
+
- `locator` **([string][6] \| [object][7])** an element to wait for
|
|
536
|
+
- `sec` **[number][9]** number of seconds to wait, 5 by default (optional, default `5`)
|
|
537
|
+
|
|
538
|
+
### waitForElementVisible
|
|
539
|
+
|
|
540
|
+
Waits for an element to be visible on page.
|
|
541
|
+
|
|
542
|
+
```js
|
|
543
|
+
I.waitForElementVisible('#message', 1); // wait for 1 second
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### Parameters
|
|
547
|
+
|
|
548
|
+
- `locator` **([string][6] \| [object][7])** an element to wait for
|
|
549
|
+
- `sec` **[number][9]** number of seconds to wait (optional, default `5`)
|
|
550
|
+
|
|
551
|
+
### waitToHide
|
|
552
|
+
|
|
553
|
+
Waits an elment to become not visible.
|
|
554
|
+
|
|
555
|
+
```js
|
|
556
|
+
I.waitToHide('#message', 2); // wait for 2 seconds
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
#### Parameters
|
|
560
|
+
|
|
561
|
+
- `locator` **([string][6] \| [object][7])** an element to wait for
|
|
562
|
+
- `sec` **[number][9]** number of seconds to wait (optional, default `5`)
|
|
563
|
+
|
|
564
|
+
[1]: https://github.com/wix/Detox
|
|
565
|
+
|
|
566
|
+
[2]: https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md
|
|
567
|
+
|
|
568
|
+
[3]: https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md
|
|
569
|
+
|
|
570
|
+
[4]: https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md#step-4-build-your-app-and-run-detox-tests
|
|
571
|
+
|
|
572
|
+
[5]: https://codecept.io
|
|
573
|
+
|
|
574
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
575
|
+
|
|
576
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
577
|
+
|
|
578
|
+
[8]: #tap
|
|
579
|
+
|
|
580
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
581
|
+
|
|
582
|
+
[10]: #relaunchApp
|
|
583
|
+
|
|
584
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
585
|
+
|
|
586
|
+
[12]: #click
|