codeceptjs 3.5.4-beta.1 → 3.5.5

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