codeceptjs 3.5.2 → 3.5.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.
@@ -0,0 +1,1709 @@
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]** 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
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
534
+
535
+ ### executeScript
536
+
537
+ Executes sync script on a page.
538
+ Pass arguments to function as additional parameters.
539
+ Will return execution result to a test.
540
+ In this case you should use async function and await to receive results.
541
+
542
+ Example with jQuery DatePicker:
543
+
544
+ ```js
545
+ // change date of jQuery DatePicker
546
+ I.executeScript(function() {
547
+ // now we are inside browser context
548
+ $('date').datetimepicker('setDate', new Date());
549
+ });
550
+ ```
551
+
552
+ Can return values. Don't forget to use `await` to get them.
553
+
554
+ ```js
555
+ let date = await I.executeScript(function(el) {
556
+ // only basic types can be returned
557
+ return $(el).datetimepicker('getDate').toString();
558
+ }, '#date'); // passing jquery selector
559
+ ```
560
+
561
+ #### Parameters
562
+
563
+ - `fn` **([string][9] | [function][12])** function to be executed in browser context.
564
+ - `args` **...any** to be passed to function.
565
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
566
+
567
+ ### fillField
568
+
569
+ Fills a text field or textarea, after clearing its value, with the given string.
570
+ Field is located by name, label, CSS, or XPath.
571
+
572
+ ```js
573
+ // by label
574
+ I.fillField('Email', 'hello@world.com');
575
+ // by name
576
+ I.fillField('password', secret('123456'));
577
+ // by CSS
578
+ I.fillField('form#login input[name=username]', 'John');
579
+ // or by strict locator
580
+ I.fillField({css: 'form#login input[name=username]'}, 'John');
581
+ ```
582
+
583
+ #### Parameters
584
+
585
+ - `field` **([string][9] | [object][10])** located by label|name|CSS|XPath|strict locator.
586
+ - `value` **([string][9] | [object][10])** text value to fill.
587
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
588
+
589
+ ### grabAttributeFrom
590
+
591
+ Retrieves an attribute from an element located by CSS or XPath and returns it to test.
592
+ Resumes test execution, so **should be used inside async with `await`** operator.
593
+ If more than one element is found - attribute of first element is returned.
594
+
595
+ ```js
596
+ let hint = await I.grabAttributeFrom('#tooltip', 'title');
597
+ ```
598
+
599
+ #### Parameters
600
+
601
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
602
+ - `attr` **[string][9]** attribute name.
603
+
604
+ Returns **[Promise][13]&lt;[string][9]>** attribute value
605
+
606
+ ### grabAttributeFromAll
607
+
608
+ Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
609
+ Resumes test execution, so **should be used inside async with `await`** operator.
610
+
611
+ ```js
612
+ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
613
+ ```
614
+
615
+ #### Parameters
616
+
617
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
618
+ - `attr` **[string][9]** attribute name.
619
+
620
+ Returns **[Promise][13]&lt;[Array][14]&lt;[string][9]>>** attribute value
621
+
622
+ ### grabBrowserLogs
623
+
624
+ Get JS log from browser. Log buffer is reset after each request.
625
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
626
+
627
+ ```js
628
+ let logs = await I.grabBrowserLogs();
629
+ console.log(JSON.stringify(logs))
630
+ ```
631
+
632
+ Returns **([Promise][13]&lt;[Array][14]&lt;[object][10]>> | [undefined][15])** all browser logs
633
+
634
+ ### grabCookie
635
+
636
+ Gets a cookie object by name.
637
+ If none provided gets all cookies.
638
+ Resumes test execution, so **should be used inside async function with `await`** operator.
639
+
640
+ ```js
641
+ let cookie = await I.grabCookie('auth');
642
+ assert(cookie.value, '123456');
643
+ ```
644
+
645
+ #### Parameters
646
+
647
+ - `name` **[string][9]?** cookie name.
648
+
649
+ Returns **([Promise][13]&lt;[string][9]> | [Promise][13]&lt;[Array][14]&lt;[string][9]>>)** attribute valueReturns cookie in JSON [format][16].
650
+
651
+ ### grabCssPropertyFrom
652
+
653
+ Grab CSS property for given locator
654
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
655
+ If more than one element is found - value of first element is returned.
656
+
657
+ ```js
658
+ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
659
+ ```
660
+
661
+ #### Parameters
662
+
663
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
664
+ - `cssProperty` **[string][9]** CSS property name.
665
+
666
+ Returns **[Promise][13]&lt;[string][9]>** CSS value
667
+
668
+ ### grabCssPropertyFromAll
669
+
670
+ Grab array of CSS properties for given locator
671
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
672
+
673
+ ```js
674
+ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
675
+ ```
676
+
677
+ #### Parameters
678
+
679
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
680
+ - `cssProperty` **[string][9]** CSS property name.
681
+
682
+ Returns **[Promise][13]&lt;[Array][14]&lt;[string][9]>>** CSS value
683
+
684
+ ### grabCurrentUrl
685
+
686
+ Get current URL from browser.
687
+ Resumes test execution, so should be used inside an async function.
688
+
689
+ ```js
690
+ let url = await I.grabCurrentUrl();
691
+ console.log(`Current URL is [${url}]`);
692
+ ```
693
+
694
+ Returns **[Promise][13]&lt;[string][9]>** current URL
695
+
696
+ ### grabHTMLFrom
697
+
698
+ Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
699
+ Resumes test execution, so **should be used inside async function with `await`** operator.
700
+ If more than one element is found - HTML of first element is returned.
701
+
702
+ ```js
703
+ let postHTML = await I.grabHTMLFrom('#post');
704
+ ```
705
+
706
+ #### Parameters
707
+
708
+ - `locator`
709
+ - `element` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
710
+
711
+ Returns **[Promise][13]&lt;[string][9]>** HTML code for an element
712
+
713
+ ### grabHTMLFromAll
714
+
715
+ Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
716
+ Resumes test execution, so **should be used inside async function with `await`** operator.
717
+
718
+ ```js
719
+ let postHTMLs = await I.grabHTMLFromAll('.post');
720
+ ```
721
+
722
+ #### Parameters
723
+
724
+ - `locator`
725
+ - `element` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
726
+
727
+ Returns **[Promise][13]&lt;[Array][14]&lt;[string][9]>>** HTML code for an element
728
+
729
+ ### grabNumberOfOpenTabs
730
+
731
+ Grab number of open tabs.
732
+ Resumes test execution, so **should be used inside async function with `await`** operator.
733
+
734
+ ```js
735
+ let tabs = await I.grabNumberOfOpenTabs();
736
+ ```
737
+
738
+ Returns **[Promise][13]&lt;[number][7]>** number of open tabs
739
+
740
+ ### grabNumberOfVisibleElements
741
+
742
+ Grab number of visible elements by locator.
743
+ Resumes test execution, so **should be used inside async function with `await`** operator.
744
+
745
+ ```js
746
+ let numOfElements = await I.grabNumberOfVisibleElements('p');
747
+ ```
748
+
749
+ #### Parameters
750
+
751
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
752
+
753
+ Returns **[Promise][13]&lt;[number][7]>** number of visible elements
754
+
755
+ ### grabPageScrollPosition
756
+
757
+ Retrieves a page scroll position and returns it to test.
758
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
759
+
760
+ ```js
761
+ let { x, y } = await I.grabPageScrollPosition();
762
+ ```
763
+
764
+ Returns **[Promise][13]&lt;PageScrollPosition>** scroll position
765
+
766
+ ### grabPopupText
767
+
768
+ Grab the text within the popup. If no popup is visible then it will return null
769
+
770
+ ```js
771
+ await I.grabPopupText();
772
+ ```
773
+
774
+ ### grabSource
775
+
776
+ Retrieves page source and returns it to test.
777
+ Resumes test execution, so **should be used inside async function with `await`** operator.
778
+
779
+ ```js
780
+ let pageSource = await I.grabSource();
781
+ ```
782
+
783
+ Returns **[Promise][13]&lt;[string][9]>** source code
784
+
785
+ ### grabTextFrom
786
+
787
+ Retrieves a text from an element located by CSS or XPath and returns it to test.
788
+ Resumes test execution, so **should be used inside async with `await`** operator.
789
+
790
+ ```js
791
+ let pin = await I.grabTextFrom('#pin');
792
+ ```
793
+
794
+ If multiple elements found returns first element.
795
+
796
+ #### Parameters
797
+
798
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
799
+
800
+ Returns **[Promise][13]&lt;[string][9]>** attribute value
801
+
802
+ ### grabTextFromAll
803
+
804
+ Retrieves all texts from an element located by CSS or XPath and returns it to test.
805
+ Resumes test execution, so **should be used inside async with `await`** operator.
806
+
807
+ ```js
808
+ let pins = await I.grabTextFromAll('#pin li');
809
+ ```
810
+
811
+ #### Parameters
812
+
813
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
814
+
815
+ Returns **[Promise][13]&lt;[Array][14]&lt;[string][9]>>** attribute value
816
+
817
+ ### grabTitle
818
+
819
+ Retrieves a page title and returns it to test.
820
+ Resumes test execution, so **should be used inside async with `await`** operator.
821
+
822
+ ```js
823
+ let title = await I.grabTitle();
824
+ ```
825
+
826
+ Returns **[Promise][13]&lt;[string][9]>** title
827
+
828
+ ### grabValueFrom
829
+
830
+ Retrieves a value from a form element located by CSS or XPath and returns it to test.
831
+ Resumes test execution, so **should be used inside async function with `await`** operator.
832
+ If more than one element is found - value of first element is returned.
833
+
834
+ ```js
835
+ let email = await I.grabValueFrom('input[name=email]');
836
+ ```
837
+
838
+ #### Parameters
839
+
840
+ - `locator` **([string][9] | [object][10])** field located by label|name|CSS|XPath|strict locator.
841
+
842
+ Returns **[Promise][13]&lt;[string][9]>** attribute value
843
+
844
+ ### grabValueFromAll
845
+
846
+ Retrieves an array of value from a form located by CSS or XPath and returns it to test.
847
+ Resumes test execution, so **should be used inside async function with `await`** operator.
848
+
849
+ ```js
850
+ let inputs = await I.grabValueFromAll('//form/input');
851
+ ```
852
+
853
+ #### Parameters
854
+
855
+ - `locator` **([string][9] | [object][10])** field located by label|name|CSS|XPath|strict locator.
856
+
857
+ Returns **[Promise][13]&lt;[Array][14]&lt;[string][9]>>** attribute value
858
+
859
+ ### haveModule
860
+
861
+ Injects Angular module.
862
+
863
+ ```js
864
+ I.haveModule('modName', function() {
865
+ angular.module('modName', []).value('foo', 'bar');
866
+ });
867
+ ```
868
+
869
+ #### Parameters
870
+
871
+ - `modName`
872
+ - `fn`
873
+
874
+ ### moveCursorTo
875
+
876
+ Moves cursor to element matched by locator.
877
+ Extra shift can be set with offsetX and offsetY options.
878
+
879
+ ```js
880
+ I.moveCursorTo('.tooltip');
881
+ I.moveCursorTo('#submit', 5,5);
882
+ ```
883
+
884
+ #### Parameters
885
+
886
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
887
+ - `offsetX` **[number][7]** (optional, `0` by default) X-axis offset.
888
+ - `offsetY` **[number][7]** (optional, `0` by default) Y-axis offset.
889
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
890
+
891
+ ### moveTo
892
+
893
+ Moves to url
894
+
895
+ #### Parameters
896
+
897
+ - `path`
898
+
899
+ ### openNewTab
900
+
901
+ Open new tab and switch to it
902
+
903
+ ```js
904
+ I.openNewTab();
905
+ ```
906
+
907
+ ### pressKey
908
+
909
+ Presses a key on a focused element.
910
+ Special keys like 'Enter', 'Control', [etc][17]
911
+ will be replaced with corresponding unicode.
912
+ If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
913
+
914
+ ```js
915
+ I.pressKey('Enter');
916
+ I.pressKey(['Control','a']);
917
+ ```
918
+
919
+ #### Parameters
920
+
921
+ - `key` **([string][9] | [Array][14]&lt;[string][9]>)** key or array of keys to press.
922
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
923
+
924
+
925
+ [Valid key names](https://w3c.github.io/webdriver/#keyboard-actions) are:
926
+
927
+ - `'Add'`,
928
+ - `'Alt'`,
929
+ - `'ArrowDown'` or `'Down arrow'`,
930
+ - `'ArrowLeft'` or `'Left arrow'`,
931
+ - `'ArrowRight'` or `'Right arrow'`,
932
+ - `'ArrowUp'` or `'Up arrow'`,
933
+ - `'Backspace'`,
934
+ - `'Command'`,
935
+ - `'Control'`,
936
+ - `'Del'`,
937
+ - `'Divide'`,
938
+ - `'End'`,
939
+ - `'Enter'`,
940
+ - `'Equals'`,
941
+ - `'Escape'`,
942
+ - `'F1 to F12'`,
943
+ - `'Home'`,
944
+ - `'Insert'`,
945
+ - `'Meta'`,
946
+ - `'Multiply'`,
947
+ - `'Numpad 0'` to `'Numpad 9'`,
948
+ - `'Pagedown'` or `'PageDown'`,
949
+ - `'Pageup'` or `'PageUp'`,
950
+ - `'Pause'`,
951
+ - `'Semicolon'`,
952
+ - `'Shift'`,
953
+ - `'Space'`,
954
+ - `'Subtract'`,
955
+ - `'Tab'`.
956
+
957
+ ### refresh
958
+
959
+ Reloads page
960
+
961
+ ### refreshPage
962
+
963
+ Reload the current page.
964
+
965
+ ```js
966
+ I.refreshPage();
967
+ ```
968
+
969
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
970
+
971
+ ### resetModule
972
+
973
+ Removes mocked Angular module. If modName not specified - clears all mock modules.
974
+
975
+ ```js
976
+ I.resetModule(); // clears all
977
+ I.resetModule('modName');
978
+ ```
979
+
980
+ #### Parameters
981
+
982
+ - `modName`
983
+
984
+ ### resizeWindow
985
+
986
+ Resize the current window to provided width and height.
987
+ First parameter can be set to `maximize`.
988
+
989
+ #### Parameters
990
+
991
+ - `width` **[number][7]** width in pixels or `maximize`.
992
+ - `height` **[number][7]** height in pixels.
993
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
994
+
995
+ ### rightClick
996
+
997
+ Performs right click on a clickable element matched by semantic locator, CSS or XPath.
998
+
999
+ ```js
1000
+ // right click element with id el
1001
+ I.rightClick('#el');
1002
+ // right click link or button with text "Click me"
1003
+ I.rightClick('Click me');
1004
+ // right click button with text "Click me" inside .context
1005
+ I.rightClick('Click me', '.context');
1006
+ ```
1007
+
1008
+ #### Parameters
1009
+
1010
+ - `locator` **([string][9] | [object][10])** clickable element located by CSS|XPath|strict locator.
1011
+ - `context` **([string][9]? | [object][10])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1012
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1013
+
1014
+ ### saveElementScreenshot
1015
+
1016
+ Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
1017
+ Filename is relative to output folder.
1018
+
1019
+ ```js
1020
+ I.saveElementScreenshot(`#submit`,'debug.png');
1021
+ ```
1022
+
1023
+ #### Parameters
1024
+
1025
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1026
+ - `fileName` **[string][9]** file name to save.
1027
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1028
+
1029
+ ### saveScreenshot
1030
+
1031
+ Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
1032
+ Filename is relative to output folder.
1033
+ 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.
1034
+
1035
+ ```js
1036
+ I.saveScreenshot('debug.png');
1037
+ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1038
+ ```
1039
+
1040
+ #### Parameters
1041
+
1042
+ - `fileName` **[string][9]** file name to save.
1043
+ - `fullPage` **[boolean][18]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
1044
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1045
+
1046
+ ### scrollPageToBottom
1047
+
1048
+ Scroll page to the bottom.
1049
+
1050
+ ```js
1051
+ I.scrollPageToBottom();
1052
+ ```
1053
+
1054
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1055
+
1056
+ ### scrollPageToTop
1057
+
1058
+ Scroll page to the top.
1059
+
1060
+ ```js
1061
+ I.scrollPageToTop();
1062
+ ```
1063
+
1064
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1065
+
1066
+ ### scrollTo
1067
+
1068
+ Scrolls to element matched by locator.
1069
+ Extra shift can be set with offsetX and offsetY options.
1070
+
1071
+ ```js
1072
+ I.scrollTo('footer');
1073
+ I.scrollTo('#submit', 5, 5);
1074
+ ```
1075
+
1076
+ #### Parameters
1077
+
1078
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
1079
+ - `offsetX` **[number][7]** (optional, `0` by default) X-axis offset.
1080
+ - `offsetY` **[number][7]** (optional, `0` by default) Y-axis offset.
1081
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1082
+
1083
+ ### see
1084
+
1085
+ Checks that a page contains a visible text.
1086
+ Use context parameter to narrow down the search.
1087
+
1088
+ ```js
1089
+ I.see('Welcome'); // text welcome on a page
1090
+ I.see('Welcome', '.content'); // text inside .content div
1091
+ I.see('Register', {css: 'form.register'}); // use strict locator
1092
+ ```
1093
+
1094
+ #### Parameters
1095
+
1096
+ - `text` **[string][9]** expected on page.
1097
+ - `context` **([string][9]? | [object][10])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
1098
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1099
+
1100
+ ### seeAttributesOnElements
1101
+
1102
+ Checks that all elements with given locator have given attributes.
1103
+
1104
+ ```js
1105
+ I.seeAttributesOnElements('//form', { method: "post"});
1106
+ ```
1107
+
1108
+ #### Parameters
1109
+
1110
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
1111
+ - `attributes` **[object][10]** attributes and their values to check.
1112
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1113
+
1114
+ ### seeCheckboxIsChecked
1115
+
1116
+ Verifies that the specified checkbox is checked.
1117
+
1118
+ ```js
1119
+ I.seeCheckboxIsChecked('Agree');
1120
+ I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1121
+ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1122
+ ```
1123
+
1124
+ #### Parameters
1125
+
1126
+ - `field` **([string][9] | [object][10])** located by label|name|CSS|XPath|strict locator.
1127
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1128
+
1129
+ ### seeCookie
1130
+
1131
+ Checks that cookie with given name exists.
1132
+
1133
+ ```js
1134
+ I.seeCookie('Auth');
1135
+ ```
1136
+
1137
+ #### Parameters
1138
+
1139
+ - `name` **[string][9]** cookie name.
1140
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1141
+
1142
+ ### seeCssPropertiesOnElements
1143
+
1144
+ Checks that all elements with given locator have given CSS properties.
1145
+
1146
+ ```js
1147
+ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1148
+ ```
1149
+
1150
+ #### Parameters
1151
+
1152
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
1153
+ - `cssProperties` **[object][10]** object with CSS properties and their values to check.
1154
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1155
+
1156
+ ### seeCurrentUrlEquals
1157
+
1158
+ Checks that current url is equal to provided one.
1159
+ If a relative url provided, a configured url will be prepended to it.
1160
+ So both examples will work:
1161
+
1162
+ ```js
1163
+ I.seeCurrentUrlEquals('/register');
1164
+ I.seeCurrentUrlEquals('http://my.site.com/register');
1165
+ ```
1166
+
1167
+ #### Parameters
1168
+
1169
+ - `url` **[string][9]** value to check.
1170
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1171
+
1172
+ ### seeElement
1173
+
1174
+ Checks that a given Element is visible
1175
+ Element is located by CSS or XPath.
1176
+
1177
+ ```js
1178
+ I.seeElement('#modal');
1179
+ ```
1180
+
1181
+ #### Parameters
1182
+
1183
+ - `locator` **([string][9] | [object][10])** located by CSS|XPath|strict locator.
1184
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1185
+
1186
+ ### seeElementInDOM
1187
+
1188
+ Checks that a given Element is present in the DOM
1189
+ Element is located by CSS or XPath.
1190
+
1191
+ ```js
1192
+ I.seeElementInDOM('#modal');
1193
+ ```
1194
+
1195
+ #### Parameters
1196
+
1197
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1198
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1199
+
1200
+ ### seeInCurrentUrl
1201
+
1202
+ Checks that current url contains a provided fragment.
1203
+
1204
+ ```js
1205
+ I.seeInCurrentUrl('/register'); // we are on registration page
1206
+ ```
1207
+
1208
+ #### Parameters
1209
+
1210
+ - `url` **[string][9]** a fragment to check
1211
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1212
+
1213
+ ### seeInField
1214
+
1215
+ Checks that the given input field or textarea equals to given value.
1216
+ For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1217
+
1218
+ ```js
1219
+ I.seeInField('Username', 'davert');
1220
+ I.seeInField({css: 'form textarea'},'Type your comment here');
1221
+ I.seeInField('form input[type=hidden]','hidden_value');
1222
+ I.seeInField('#searchform input','Search');
1223
+ ```
1224
+
1225
+ #### Parameters
1226
+
1227
+ - `field` **([string][9] | [object][10])** located by label|name|CSS|XPath|strict locator.
1228
+ - `value` **[string][9]** value to check.
1229
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1230
+
1231
+ ### seeInPopup
1232
+
1233
+ Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
1234
+ given string.
1235
+
1236
+ ```js
1237
+ I.seeInPopup('Popup text');
1238
+ ```
1239
+
1240
+ #### Parameters
1241
+
1242
+ - `text` **[string][9]** value to check.
1243
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1244
+
1245
+ ### seeInSource
1246
+
1247
+ Checks that the current page contains the given string in its raw source code.
1248
+
1249
+ ```js
1250
+ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1251
+ ```
1252
+
1253
+ #### Parameters
1254
+
1255
+ - `text` **[string][9]** value to check.
1256
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1257
+
1258
+ ### seeInTitle
1259
+
1260
+ Checks that title contains text.
1261
+
1262
+ ```js
1263
+ I.seeInTitle('Home Page');
1264
+ ```
1265
+
1266
+ #### Parameters
1267
+
1268
+ - `text` **[string][9]** text value to check.
1269
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1270
+
1271
+ ### seeNumberOfElements
1272
+
1273
+ Asserts that an element appears a given number of times in the DOM.
1274
+ Element is located by label or name or CSS or XPath.
1275
+
1276
+ ```js
1277
+ I.seeNumberOfElements('#submitBtn', 1);
1278
+ ```
1279
+
1280
+ #### Parameters
1281
+
1282
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1283
+ - `num` **[number][7]** number of elements.
1284
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1285
+
1286
+ ### seeNumberOfVisibleElements
1287
+
1288
+ Asserts that an element is visible a given number of times.
1289
+ Element is located by CSS or XPath.
1290
+
1291
+ ```js
1292
+ I.seeNumberOfVisibleElements('.buttons', 3);
1293
+ ```
1294
+
1295
+ #### Parameters
1296
+
1297
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1298
+ - `num` **[number][7]** number of elements.
1299
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1300
+
1301
+ ### seeTextEquals
1302
+
1303
+ Checks that text is equal to provided one.
1304
+
1305
+ ```js
1306
+ I.seeTextEquals('text', 'h1');
1307
+ ```
1308
+
1309
+ #### Parameters
1310
+
1311
+ - `text` **[string][9]** element value to check.
1312
+ - `context` **([string][9] | [object][10])?** element located by CSS|XPath|strict locator.
1313
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1314
+
1315
+ ### seeTitleEquals
1316
+
1317
+ Checks that title is equal to provided one.
1318
+
1319
+ ```js
1320
+ I.seeTitleEquals('Test title.');
1321
+ ```
1322
+
1323
+ #### Parameters
1324
+
1325
+ - `text` **[string][9]** value to check.
1326
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1327
+
1328
+ ### selectOption
1329
+
1330
+ Selects an option in a drop-down select.
1331
+ Field is searched by label | name | CSS | XPath.
1332
+ Option is selected by visible text or by value.
1333
+
1334
+ ```js
1335
+ I.selectOption('Choose Plan', 'Monthly'); // select by label
1336
+ I.selectOption('subscription', 'Monthly'); // match option by text
1337
+ I.selectOption('subscription', '0'); // or by value
1338
+ I.selectOption('//form/select[@name=account]','Premium');
1339
+ I.selectOption('form select[name=account]', 'Premium');
1340
+ I.selectOption({css: 'form select[name=account]'}, 'Premium');
1341
+ ```
1342
+
1343
+ Provide an array for the second argument to select multiple options.
1344
+
1345
+ ```js
1346
+ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
1347
+ ```
1348
+
1349
+ #### Parameters
1350
+
1351
+ - `select` **([string][9] | [object][10])** field located by label|name|CSS|XPath|strict locator.
1352
+ - `option` **([string][9] | [Array][14]&lt;any>)** visible text or value of option.
1353
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1354
+
1355
+ ### setCookie
1356
+
1357
+ Sets cookie(s).
1358
+
1359
+ Can be a single cookie object or an array of cookies:
1360
+
1361
+ ```js
1362
+ I.setCookie({name: 'auth', value: true});
1363
+
1364
+ // as array
1365
+ I.setCookie([
1366
+ {name: 'auth', value: true},
1367
+ {name: 'agree', value: true}
1368
+ ]);
1369
+ ```
1370
+
1371
+ #### Parameters
1372
+
1373
+ - `cookie` **(Cookie | [Array][14]&lt;Cookie>)** a cookie object or array of cookie objects.
1374
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1375
+
1376
+ ### switchTo
1377
+
1378
+ Switches frame or in case of null locator reverts to parent.
1379
+
1380
+ ```js
1381
+ I.switchTo('iframe'); // switch to first iframe
1382
+ I.switchTo(); // switch back to main page
1383
+ ```
1384
+
1385
+ #### Parameters
1386
+
1387
+ - `locator` **([string][9]? | [object][10])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1388
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1389
+
1390
+ ### switchToNextTab
1391
+
1392
+ Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
1393
+
1394
+ ```js
1395
+ I.switchToNextTab();
1396
+ I.switchToNextTab(2);
1397
+ ```
1398
+
1399
+ #### Parameters
1400
+
1401
+ - `num`
1402
+
1403
+ ### switchToPreviousTab
1404
+
1405
+ Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
1406
+
1407
+ ```js
1408
+ I.switchToPreviousTab();
1409
+ I.switchToPreviousTab(2);
1410
+ ```
1411
+
1412
+ #### Parameters
1413
+
1414
+ - `num`
1415
+
1416
+ ### uncheckOption
1417
+
1418
+ Unselects a checkbox or radio button.
1419
+ Element is located by label or name or CSS or XPath.
1420
+
1421
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
1422
+
1423
+ ```js
1424
+ I.uncheckOption('#agree');
1425
+ I.uncheckOption('I Agree to Terms and Conditions');
1426
+ I.uncheckOption('agree', '//form');
1427
+ ```
1428
+
1429
+ #### Parameters
1430
+
1431
+ - `field` **([string][9] | [object][10])** checkbox located by label | name | CSS | XPath | strict locator.
1432
+ - `context` **([string][9]? | [object][10])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1433
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1434
+
1435
+ ### useProtractorTo
1436
+
1437
+ Use [Protractor][19] API inside a test.
1438
+
1439
+ First argument is a description of an action.
1440
+ Second argument is async function that gets this helper as parameter.
1441
+
1442
+ { [`browser`][20]) } object from Protractor API is available.
1443
+
1444
+ ```js
1445
+ I.useProtractorTo('change url via in-page navigation', async ({ browser }) {
1446
+ await browser.setLocation('api');
1447
+ });
1448
+ ```
1449
+
1450
+ #### Parameters
1451
+
1452
+ - `description` **[string][9]** used to show in logs.
1453
+ - `fn` **[function][12]** async functuion that executed with Protractor helper as argument
1454
+
1455
+ ### wait
1456
+
1457
+ Pauses execution for a number of seconds.
1458
+
1459
+ ```js
1460
+ I.wait(2); // wait 2 secs
1461
+ ```
1462
+
1463
+ #### Parameters
1464
+
1465
+ - `sec` **[number][7]** number of second to wait.
1466
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1467
+
1468
+ ### waitForClickable
1469
+
1470
+ Waits for element to become clickable for number of seconds.
1471
+
1472
+ ```js
1473
+ I.waitForClickable('#link');
1474
+ ```
1475
+
1476
+ #### Parameters
1477
+
1478
+ - `locator`
1479
+ - `sec`
1480
+
1481
+ ### waitForDetached
1482
+
1483
+ Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
1484
+ Element can be located by CSS or XPath.
1485
+
1486
+ ```js
1487
+ I.waitForDetached('#popup');
1488
+ ```
1489
+
1490
+ #### Parameters
1491
+
1492
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1493
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1494
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1495
+
1496
+ ### waitForElement
1497
+
1498
+ Waits for element to be present on page (by default waits for 1sec).
1499
+ Element can be located by CSS or XPath.
1500
+
1501
+ ```js
1502
+ I.waitForElement('.btn.continue');
1503
+ I.waitForElement('.btn.continue', 5); // wait for 5 secs
1504
+ ```
1505
+
1506
+ #### Parameters
1507
+
1508
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1509
+ - `sec` **[number][7]?** (optional, `1` by default) time in seconds to wait
1510
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1511
+
1512
+ ### waitForEnabled
1513
+
1514
+ Waits for element to become enabled (by default waits for 1sec).
1515
+ Element can be located by CSS or XPath.
1516
+
1517
+ #### Parameters
1518
+
1519
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1520
+ - `sec` **[number][7]** (optional) time in seconds to wait, 1 by default.
1521
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1522
+
1523
+ ### waitForFunction
1524
+
1525
+ Waits for a function to return true (waits for 1 sec by default).
1526
+ Running in browser context.
1527
+
1528
+ ```js
1529
+ I.waitForFunction(fn[, [args[, timeout]])
1530
+ ```
1531
+
1532
+ ```js
1533
+ I.waitForFunction(() => window.requests == 0);
1534
+ I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1535
+ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
1536
+ ```
1537
+
1538
+ #### Parameters
1539
+
1540
+ - `fn` **([string][9] | [function][12])** to be executed in browser context.
1541
+ - `argsOrSec` **([Array][14]&lt;any> | [number][7])?** (optional, `1` by default) arguments for function or seconds.
1542
+ - `sec` **[number][7]?** (optional, `1` by default) time in seconds to wait
1543
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1544
+
1545
+ ### waitForInvisible
1546
+
1547
+ Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1548
+ Element can be located by CSS or XPath.
1549
+
1550
+ ```js
1551
+ I.waitForInvisible('#popup');
1552
+ ```
1553
+
1554
+ #### Parameters
1555
+
1556
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1557
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1558
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1559
+
1560
+ ### waitForText
1561
+
1562
+ Waits for a text to appear (by default waits for 1sec).
1563
+ Element can be located by CSS or XPath.
1564
+ Narrow down search results by providing context.
1565
+
1566
+ ```js
1567
+ I.waitForText('Thank you, form has been submitted');
1568
+ I.waitForText('Thank you, form has been submitted', 5, '#modal');
1569
+ ```
1570
+
1571
+ #### Parameters
1572
+
1573
+ - `text` **[string][9]** to wait for.
1574
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1575
+ - `context` **([string][9] | [object][10])?** (optional) element located by CSS|XPath|strict locator.
1576
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1577
+
1578
+ ### waitForValue
1579
+
1580
+ Waits for the specified value to be in value attribute.
1581
+
1582
+ ```js
1583
+ I.waitForValue('//input', "GoodValue");
1584
+ ```
1585
+
1586
+ #### Parameters
1587
+
1588
+ - `field` **([string][9] | [object][10])** input field.
1589
+ - `value` **[string][9]** expected value.
1590
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1591
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1592
+
1593
+ ### waitForVisible
1594
+
1595
+ Waits for an element to become visible on a page (by default waits for 1sec).
1596
+ Element can be located by CSS or XPath.
1597
+
1598
+ ```js
1599
+ I.waitForVisible('#popup');
1600
+ ```
1601
+
1602
+ #### Parameters
1603
+
1604
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1605
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1606
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1607
+
1608
+ ### waitInUrl
1609
+
1610
+ Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
1611
+
1612
+ ```js
1613
+ I.waitInUrl('/info', 2);
1614
+ ```
1615
+
1616
+ #### Parameters
1617
+
1618
+ - `urlPart` **[string][9]** value to check.
1619
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1620
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1621
+
1622
+ ### waitNumberOfVisibleElements
1623
+
1624
+ Waits for a specified number of elements on the page.
1625
+
1626
+ ```js
1627
+ I.waitNumberOfVisibleElements('a', 3);
1628
+ ```
1629
+
1630
+ #### Parameters
1631
+
1632
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1633
+ - `num` **[number][7]** number of elements.
1634
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1635
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1636
+
1637
+ ### waitToHide
1638
+
1639
+ Waits for an element to hide (by default waits for 1sec).
1640
+ Element can be located by CSS or XPath.
1641
+
1642
+ ```js
1643
+ I.waitToHide('#popup');
1644
+ ```
1645
+
1646
+ #### Parameters
1647
+
1648
+ - `locator` **([string][9] | [object][10])** element located by CSS|XPath|strict locator.
1649
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1650
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1651
+
1652
+ ### waitUrlEquals
1653
+
1654
+ Waits for the entire URL to match the expected
1655
+
1656
+ ```js
1657
+ I.waitUrlEquals('/info', 2);
1658
+ I.waitUrlEquals('http://127.0.0.1:8000/info');
1659
+ ```
1660
+
1661
+ #### Parameters
1662
+
1663
+ - `urlPart` **[string][9]** value to check.
1664
+ - `sec` **[number][7]** (optional, `1` by default) time in seconds to wait
1665
+ ⚠️ returns a _promise_ which is synchronized internally by recorder
1666
+
1667
+ ## locator
1668
+
1669
+ just press button if no selector is given
1670
+
1671
+ [1]: http://www.protractortest.org
1672
+
1673
+ [2]: http://codecept.io/quickstart/#prepare-selenium-server
1674
+
1675
+ [3]: http://codecept.io/acceptance/#smartwait
1676
+
1677
+ [4]: http://localhost:4444/wd/hub
1678
+
1679
+ [5]: https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
1680
+
1681
+ [6]: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
1682
+
1683
+ [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
1684
+
1685
+ [8]: http://jster.net/category/windows-modals-popups
1686
+
1687
+ [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1688
+
1689
+ [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
1690
+
1691
+ [11]: https://vuejs.org/v2/api/#Vue-nextTick
1692
+
1693
+ [12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1694
+
1695
+ [13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1696
+
1697
+ [14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
1698
+
1699
+ [15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
1700
+
1701
+ [16]: https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object
1702
+
1703
+ [17]: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
1704
+
1705
+ [18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
1706
+
1707
+ [19]: https://www.protractortest.org/#/api
1708
+
1709
+ [20]: https://www.protractortest.org/#/api?view=ProtractorBrowser