codeceptjs 3.1.3 → 3.2.3

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