codeceptjs 4.2.1 → 4.2.2

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.
@@ -78,20 +78,30 @@ These are set automatically and only need overriding for unusual setups:
78
78
 
79
79
  This helper should be configured in codecept.conf.js
80
80
 
81
- Type: [object][3]
81
+ Type: [object][4]
82
82
 
83
83
  ### Properties
84
84
 
85
- * `endpoint` **[string][4]?** explicit CDP endpoint. Setting this switches the helper to ATTACH
85
+ * `endpoint` **[string][3]?** explicit CDP endpoint. Setting this switches the helper to ATTACH
86
86
  mode: it only connects, and never spawns or kills a process, no matter what else is configured.
87
87
  Leave it unset for SELF-MANAGED mode (see below).
88
- * `binaryPath` **[string][4]?** path to the `lightpanda` executable, used in SELF-MANAGED mode
88
+ * `binaryPath` **[string][3]?** path to the `lightpanda` executable, used in SELF-MANAGED mode
89
89
  (`endpoint` unset). Checked before `LIGHTPANDA_PATH` and `PATH`.
90
- * `port` **[number][5]?** port `lightpanda serve` listens on, in SELF-MANAGED mode. When unset, a
90
+ * `port` **[number][8]?** port `lightpanda serve` listens on, in SELF-MANAGED mode. When unset, a
91
91
  free port is picked automatically, which is what makes `run-workers` collision-free — every
92
92
  worker gets its own instance on its own port with zero config.
93
- * `serverStartTimeout` **[number][5]?** milliseconds to wait for a spawned `lightpanda serve`
93
+ * `serverStartTimeout` **[number][8]?** milliseconds to wait for a spawned `lightpanda serve`
94
94
  to answer `/json/version` before `_connect` gives up.
95
+ * `url` **[string][3]?** base url of website to be tested.
96
+ * `headers` **[object][4]?** headers sent when connecting to the endpoint, e.g. for authenticated remote browsers.
97
+ * `input` **[string][3]?** how actions are dispatched: `cdp` (real mouse and keyboard events) or `synthetic` (DOM events). `auto` picks `cdp` when the browser renders layout.
98
+ * `xpathPolyfill` **([string][3] | [boolean][18])?** inject an XPath polyfill for browsers with incomplete XPath support. `auto` detects when it is needed.
99
+ * `capabilities` **[object][4]?** browser capabilities (`layout`, `xpath`, `screenshot`, `video`, `innerText`, `aria`) to use instead of detecting them at runtime.
100
+ * `waitForTimeout` **[number][8]?** default timeout for wait* actions, in seconds.
101
+ * `waitForAction` **[number][8]?** fixed delay after each action, in milliseconds. When unset, actions wait only for the navigation they trigger.
102
+ * `pollInterval` **[number][8]?** interval between checks while waiting, in milliseconds.
103
+ * `getPageTimeout` **[number][8]?** maximum time to wait for a page to load, in seconds.
104
+ * `waitForNavigation` **[string][3]?** when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
95
105
 
96
106
 
97
107
 
@@ -128,12 +138,1830 @@ Type: [object][3]
128
138
 
129
139
  * `config` **LightpandaConfig** 
130
140
 
141
+ ### amOnPage
142
+
143
+ Opens a web page in a browser. Requires relative or absolute url.
144
+ If url starts with `/`, opens a web page of a site defined in `url` config parameter.
145
+
146
+ ```js
147
+ I.amOnPage('/'); // opens main page of website
148
+ I.amOnPage('https://github.com'); // opens github
149
+ I.amOnPage('/login'); // opens a login page
150
+ ```
151
+
152
+ #### Parameters
153
+
154
+ * `url` **[string][3]** url path or global url.
155
+
156
+ Returns **void** automatically synchronized promise through #recorder
157
+
158
+ ### appendField
159
+
160
+ Appends text to a input field or textarea.
161
+ Field is located by name, label, CSS or XPath
162
+
163
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
164
+
165
+ ```js
166
+ I.appendField('#myTextField', 'appended');
167
+ // typing secret
168
+ I.appendField('password', secret('123456'));
169
+ // within a context
170
+ I.appendField('name', 'John', '.form-container');
171
+ ```
172
+
173
+ #### Parameters
174
+
175
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator
176
+ * `value` **[string][3]** text value to append.
177
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
178
+
179
+ Returns **void** automatically synchronized promise through #recorder
180
+
181
+ ### attachFile
182
+
183
+ Attaches a file to element located by label, name, CSS or XPath
184
+ Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
185
+ File will be uploaded to remote system (if tests are running remotely).
186
+
187
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
188
+
189
+ ```js
190
+ I.attachFile('Avatar', 'data/avatar.jpg');
191
+ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
192
+ // within a context
193
+ I.attachFile('Avatar', 'data/avatar.jpg', '.form-container');
194
+ ```
195
+
196
+ If the locator points to a non-file-input element (e.g., a dropzone area),
197
+ the file will be dropped onto that element using drag-and-drop events.
198
+
199
+ ```js
200
+ I.attachFile('#dropzone', 'data/avatar.jpg');
201
+ ```
202
+
203
+ #### Parameters
204
+
205
+ * `field`  
206
+ * `pathToFile` **[string][3]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
207
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
208
+ * `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
209
+
210
+ Returns **void** automatically synchronized promise through #recorder
211
+
212
+ ### blur
213
+
214
+ Remove focus from a text input, button, etc.
215
+ Calls [blur][5] on the element.
216
+
217
+ Examples:
218
+
219
+ ```js
220
+ I.blur('.text-area')
221
+ ```
222
+
223
+ ```js
224
+ //element `#product-tile` is focused
225
+ I.see('#add-to-cart-btn');
226
+ I.blur('#product-tile')
227
+ I.dontSee('#add-to-cart-btn');
228
+ ```
229
+
230
+ #### Parameters
231
+
232
+ * `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
233
+ * `options` **any?** Playwright only: [Additional options][6] for available options object as 2nd argument.
234
+
235
+ Returns **void** automatically synchronized promise through #recorder
236
+
237
+ ### capabilities
238
+
239
+ Type: CodeceptJS.HelperCapabilities
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 an optional 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][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
257
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
258
+
259
+ Returns **void** automatically synchronized promise through #recorder
260
+
261
+ ### clearClipboard
262
+
263
+ Clears the system clipboard.
264
+
265
+ ```js
266
+ I.clearClipboard();
267
+ I.seeClipboardEquals('');
268
+ ```
269
+
270
+ Returns **void** automatically synchronized promise through #recorder
271
+
272
+ ### clearCookie
273
+
274
+ Clears a cookie by name,
275
+ if none provided clears all cookies.
276
+
277
+ ```js
278
+ I.clearCookie();
279
+ I.clearCookie('test');
280
+ ```
281
+
282
+ #### Parameters
283
+
284
+ * `name`  
285
+ * `cookie` **[string][3]?** (optional, `null` by default) cookie name
286
+
287
+ ### clearField
288
+
289
+ Clears a `<textarea>` or text `<input>` element's value.
290
+
291
+ The second parameter is an optional context (CSS or XPath locator) to narrow the search.
292
+
293
+ ```js
294
+ I.clearField('Email');
295
+ I.clearField('user[email]');
296
+ I.clearField('#email');
297
+ // within a context
298
+ I.clearField('Email', '.form-container');
299
+ ```
300
+
301
+ #### Parameters
302
+
303
+ * `field` &#x20;
304
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
305
+ * `editable` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
306
+
307
+ Returns **void** automatically synchronized promise through #recorder.
308
+
309
+ ### click
310
+
311
+ Perform a click on a link or a button, given by a locator.
312
+ If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
313
+ For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
314
+ For images, the "alt" attribute and inner text of any parent links are searched.
315
+
316
+ If no locator is provided, defaults to clicking the body element (`'//body'`).
317
+
318
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
319
+
320
+ ```js
321
+ // click body element (default)
322
+ I.click();
323
+ // simple link
324
+ I.click('Logout');
325
+ // button of form
326
+ I.click('Submit');
327
+ // CSS button
328
+ I.click('#form input[type=submit]');
329
+ // XPath
330
+ I.click('//form/*[@type=submit]');
331
+ // link in context
332
+ I.click('Logout', '#nav');
333
+ // using strict locator
334
+ I.click({css: 'nav a.login'});
335
+ // using ARIA role locator
336
+ I.click({role: 'button', name: 'Submit'});
337
+ ```
338
+
339
+ > ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][7].
340
+
341
+ #### Parameters
342
+
343
+ * `locator` **([string][3] | [object][4])** (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
344
+ * `context` **([string][3]? | [object][4] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
345
+
346
+ Returns **void** automatically synchronized promise through #recorder
347
+
348
+ ### clickXY
349
+
350
+ Clicks at page coordinates, or at coordinates relative to an element.
351
+ Requires a browser that renders layout.
352
+
353
+ ```js
354
+ I.clickXY(100, 200); // page coordinates
355
+ I.clickXY('#area', 50, 30); // relative to #area
356
+ ```
357
+
358
+ #### Parameters
359
+
360
+ * `locator` **([string][3] | [object][4] | [number][8])** element to click relative to, or the X page coordinate.
361
+ * `x` **[number][8]?** X coordinate relative to the element, or the Y page coordinate if `locator` is a number.
362
+ * `y` **[number][8]?** Y coordinate relative to the element.
363
+
364
+ Returns **void** automatically synchronized promise through #recorder
365
+
366
+ ### dontSee
367
+
368
+ Opposite to `see`. Checks that a text is not present on a page.
369
+ Use context parameter to narrow down the search.
370
+
371
+ ```js
372
+ I.dontSee('Login'); // assume we are already logged in.
373
+ I.dontSee('Login', '.nav'); // no login inside .nav element
374
+ ```
375
+
376
+ #### Parameters
377
+
378
+ * `text` **[string][3]** which is not present.
379
+ * `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
380
+
381
+ Returns **void** automatically synchronized promise through #recorder
382
+
383
+ ### dontSeeCheckboxIsChecked
384
+
385
+ Verifies that the specified checkbox is not checked.
386
+
387
+ ```js
388
+ I.dontSeeCheckboxIsChecked('#agree'); // located by ID
389
+ I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
390
+ I.dontSeeCheckboxIsChecked('agree'); // located by name
391
+ ```
392
+
393
+ #### Parameters
394
+
395
+ * `locator` &#x20;
396
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
397
+
398
+ Returns **void** automatically synchronized promise through #recorder
399
+
400
+ ### dontSeeCookie
401
+
402
+ Checks that cookie with given name does not exist.
403
+
404
+ ```js
405
+ I.dontSeeCookie('auth'); // no auth cookie
406
+ ```
407
+
408
+ #### Parameters
409
+
410
+ * `name` **[string][3]** cookie name.
411
+
412
+ Returns **void** automatically synchronized promise through #recorder
413
+
414
+ ### dontSeeCurrentPathEquals
415
+
416
+ Checks that current URL path does NOT match the expected path.
417
+ Query strings and URL fragments are ignored.
418
+
419
+ ```js
420
+ I.dontSeeCurrentPathEquals('/form'); // fails for '/form', '/form?user=1', '/form#section'
421
+ I.dontSeeCurrentPathEquals('/'); // fails for '/', '/?user=ok', '/#top'
422
+ ```
423
+
424
+ #### Parameters
425
+
426
+ * `path` **[string][3]** value to check.
427
+
428
+ Returns **void** automatically synchronized promise through #recorder
429
+
430
+ ### dontSeeCurrentUrlEquals
431
+
432
+ Checks that current url is not equal to provided one.
433
+ If a relative url provided, a configured url will be prepended to it.
434
+
435
+ ```js
436
+ I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
437
+ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
438
+ ```
439
+
440
+ #### Parameters
441
+
442
+ * `url` **[string][3]** value to check.
443
+
444
+ Returns **void** automatically synchronized promise through #recorder
445
+
446
+ ### dontSeeElement
447
+
448
+ Opposite to `seeElement`. Checks that element is not visible (or in DOM)
449
+
450
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
451
+
452
+ ```js
453
+ I.dontSeeElement('.modal'); // modal is not shown
454
+ I.dontSeeElement('.modal', '#container');
455
+ ```
456
+
457
+ #### Parameters
458
+
459
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
460
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
461
+
462
+ Returns **void** automatically synchronized promise through #recorder
463
+
464
+ ### dontSeeElementInDOM
465
+
466
+ Opposite to `seeElementInDOM`. Checks that element is not on page.
467
+
468
+ ```js
469
+ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
470
+ ```
471
+
472
+ #### Parameters
473
+
474
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
475
+
476
+ Returns **void** automatically synchronized promise through #recorder
477
+
478
+ ### dontSeeInCurrentUrl
479
+
480
+ Checks that current url does not contain a provided fragment.
481
+
482
+ #### Parameters
483
+
484
+ * `url` **[string][3]** value to check.
485
+
486
+ Returns **void** automatically synchronized promise through #recorder
487
+
488
+ ### dontSeeInField
489
+
490
+ Checks that value of input field or textarea doesn't equal to given value
491
+ Opposite to `seeInField`.
492
+
493
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
494
+
495
+ ```js
496
+ I.dontSeeInField('email', 'user@user.com'); // field by name
497
+ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
498
+ // within a context
499
+ I.dontSeeInField('Name', 'old_value', '.form-container');
500
+ ```
501
+
502
+ #### Parameters
503
+
504
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
505
+ * `value` **([string][3] | [object][4])** value to check.
506
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
507
+
508
+ Returns **void** automatically synchronized promise through #recorder
509
+
510
+ ### dontSeeInSource
511
+
512
+ Checks that the current page does not contains the given string in its raw source code.
513
+
514
+ ```js
515
+ I.dontSeeInSource('<!--'); // no comments in source
516
+ ```
517
+
518
+ #### Parameters
519
+
520
+ * `text` &#x20;
521
+ * `value` **[string][3]** to check.
522
+
523
+ Returns **void** automatically synchronized promise through #recorder
524
+
525
+ ### dontSeeInTitle
526
+
527
+ Checks that title does not contain text.
528
+
529
+ ```js
530
+ I.dontSeeInTitle('Error');
531
+ ```
532
+
533
+ #### Parameters
534
+
535
+ * `text` **[string][3]** value to check.
536
+
537
+ Returns **void** automatically synchronized promise through #recorder
538
+
539
+ ### dontSeeTraffic
540
+
541
+ Verifies that a certain request is not part of network traffic.
542
+
543
+ Examples:
544
+
545
+ ```js
546
+ I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
547
+ I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
548
+ ```
549
+
550
+ #### Parameters
551
+
552
+ * `opts` **[Object][4]** options when checking the traffic network.
553
+
554
+ * `opts.name` **[string][3]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
555
+ * `opts.url` **([string][3] | [RegExp][9])** Expected URL of request in network traffic. Can be a string or a regular expression.
556
+
557
+ Returns **void** automatically synchronized promise through #recorder
558
+
559
+ ### doubleClick
560
+
561
+ Performs a double-click on an element matched by link|button|label|CSS or XPath.
562
+ Context can be specified as second parameter to narrow search.
563
+
564
+ ```js
565
+ I.doubleClick('Edit');
566
+ I.doubleClick('Edit', '.actions');
567
+ I.doubleClick({css: 'button.accept'});
568
+ I.doubleClick('.btn.edit');
569
+ ```
570
+
571
+ #### Parameters
572
+
573
+ * `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
574
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
575
+
576
+ Returns **void** automatically synchronized promise through #recorder
577
+
578
+ ### executeAsyncScript
579
+
580
+ Executes async script on page.
581
+ Provided function should execute a passed callback (as first argument) to signal it is finished.
582
+
583
+ Example: In Vue.js to make components completely rendered we are waiting for [nextTick][10].
584
+
585
+ ```js
586
+ I.executeAsyncScript(function(done) {
587
+ Vue.nextTick(done); // waiting for next tick
588
+ });
589
+ ```
590
+
591
+ By passing value to `done()` function you can return values.
592
+ Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
593
+
594
+ ```js
595
+ let val = await I.executeAsyncScript(function(url, done) {
596
+ // in browser context
597
+ $.ajax(url, { success: (data) => done(data); }
598
+ }, 'http://ajax.callback.url/');
599
+ ```
600
+
601
+ #### Parameters
602
+
603
+ * `fn` **([string][3] | [function][11])** function to be executed in browser context.
604
+ * `args` **...any** to be passed to function.
605
+
606
+ Returns **[Promise][12]<any>** script return value
607
+
608
+ ### executeScript
609
+
610
+ Executes sync script on a page.
611
+ Pass arguments to function as additional parameters.
612
+ Will return execution result to a test.
613
+ In this case you should use async function and await to receive results.
614
+
615
+ Example with jQuery DatePicker:
616
+
617
+ ```js
618
+ // change date of jQuery DatePicker
619
+ I.executeScript(function() {
620
+ // now we are inside browser context
621
+ $('date').datetimepicker('setDate', new Date());
622
+ });
623
+ ```
624
+
625
+ Can return values. Don't forget to use `await` to get them.
626
+
627
+ ```js
628
+ let date = await I.executeScript(function(el) {
629
+ // only basic types can be returned
630
+ return $(el).datetimepicker('getDate').toString();
631
+ }, '#date'); // passing jquery selector
632
+ ```
633
+
634
+ #### Parameters
635
+
636
+ * `fn` **([string][3] | [function][11])** function to be executed in browser context.
637
+ * `args` **...any** to be passed to function.
638
+
639
+ Returns **[Promise][12]<any>** script return value
640
+
641
+ ### fillField
642
+
643
+ Fills a text field or textarea, after clearing its value, with the given string.
644
+ Field is located by name, label, CSS, or XPath.
645
+
646
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
647
+
648
+ ```js
649
+ // by label
650
+ I.fillField('Email', 'hello@world.com');
651
+ // by name
652
+ I.fillField('password', secret('123456'));
653
+ // by CSS
654
+ I.fillField('form#login input[name=username]', 'John');
655
+ // or by strict locator
656
+ I.fillField({css: 'form#login input[name=username]'}, 'John');
657
+ // by ARIA role locator
658
+ I.fillField({role: 'textbox', name: 'Email'}, 'hello@world.com');
659
+ // within a context
660
+ I.fillField('Name', 'John', '#section2');
661
+ ```
662
+
663
+ > ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators][7].
664
+
665
+ #### Parameters
666
+
667
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
668
+ * `value` **([string][3] | [object][4])** text value to fill.
669
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
670
+
671
+ Returns **void** automatically synchronized promise through #recorder
672
+
673
+ ### flushNetworkTraffics
674
+
675
+ Resets all recorded network requests.
676
+
677
+ ```js
678
+ I.flushNetworkTraffics();
679
+ ```
680
+
681
+ ### focus
682
+
683
+ Calls [focus][5] on the matching element.
684
+
685
+ Examples:
686
+
687
+ ```js
688
+ I.dontSee('#add-to-cart-btn');
689
+ I.focus('#product-tile')
690
+ I.see('#add-to-cart-bnt');
691
+ ```
692
+
693
+ #### Parameters
694
+
695
+ * `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
696
+ * `options` **any?** Playwright only: [Additional options][13] for available options object as 2nd argument.
697
+
698
+ Returns **void** automatically synchronized promise through #recorder
699
+
700
+ ### forceClick
701
+
702
+ Perform an emulated click on a link or a button, given by a locator.
703
+ Unlike normal click instead of sending native event, emulates a click with JavaScript.
704
+ This works on hidden, animated or inactive elements as well.
705
+
706
+ If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
707
+ For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
708
+ For images, the "alt" attribute and inner text of any parent links are searched.
709
+
710
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
711
+
712
+ ```js
713
+ // simple link
714
+ I.forceClick('Logout');
715
+ // button of form
716
+ I.forceClick('Submit');
717
+ // CSS button
718
+ I.forceClick('#form input[type=submit]');
719
+ // XPath
720
+ I.forceClick('//form/*[@type=submit]');
721
+ // link in context
722
+ I.forceClick('Logout', '#nav');
723
+ // using strict locator
724
+ I.forceClick({css: 'nav a.login'});
725
+ ```
726
+
727
+ #### Parameters
728
+
729
+ * `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
730
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
731
+
732
+ Returns **void** automatically synchronized promise through #recorder
733
+
734
+ ### grabAriaSnapshot
735
+
736
+ Retrieves the ARIA snapshot of the page, or of an element, built from the browser accessibility tree.
737
+ The format matches Playwright's [ARIA snapshots][14].
738
+
739
+ ```js
740
+ const snapshot = await I.grabAriaSnapshot();
741
+ const formSnapshot = await I.grabAriaSnapshot('#login-form');
742
+ ```
743
+
744
+ #### Parameters
745
+
746
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator. Defaults to body element.
747
+
748
+ Returns **[Promise][12]<[string][3]>** YAML representation of the accessibility tree
749
+
750
+ ### grabAttributeFrom
751
+
752
+ Retrieves an attribute from an element located by CSS or XPath and returns it to test.
753
+ Resumes test execution, so **should be used inside async with `await`** operator.
754
+ If more than one element is found - attribute of first element is returned.
755
+
756
+ ```js
757
+ let hint = await I.grabAttributeFrom('#tooltip', 'title');
758
+ ```
759
+
760
+ #### Parameters
761
+
762
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
763
+ * `attr` **[string][3]** attribute name.
764
+
765
+ Returns **[Promise][12]<[string][3]>** attribute value
766
+
767
+ ### grabAttributeFromAll
768
+
769
+ Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
770
+ Resumes test execution, so **should be used inside async with `await`** operator.
771
+
772
+ ```js
773
+ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
774
+ ```
775
+
776
+ #### Parameters
777
+
778
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
779
+ * `attr` **[string][3]** attribute name.
780
+
781
+ Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
782
+
783
+ ### grabCookie
784
+
785
+ Gets a cookie object by name.
786
+ If none provided gets all cookies.
787
+ Resumes test execution, so **should be used inside async function with `await`** operator.
788
+
789
+ ```js
790
+ let cookie = await I.grabCookie('auth');
791
+ assert(cookie.value, '123456');
792
+ ```
793
+
794
+ #### Parameters
795
+
796
+ * `name` **[string][3]?** cookie name.
797
+
798
+ Returns **any** attribute value
799
+
800
+ ### grabCookies
801
+
802
+ Retrieves all cookies visible to the current page.
803
+ Resumes test execution, so **should be used inside async function with `await`** operator.
804
+
805
+ ```js
806
+ let cookies = await I.grabCookies();
807
+ ```
808
+
809
+ Returns **[Promise][12]<[Array][15]<CodeceptJS.Cookie>>** array of cookie objects.
810
+
811
+ ### grabCssPropertyFrom
812
+
813
+ Grab CSS property for given locator
814
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
815
+ If more than one element is found - value of first element is returned.
816
+
817
+ ```js
818
+ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
819
+ ```
820
+
821
+ #### Parameters
822
+
823
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
824
+ * `cssProperty` **[string][3]** CSS property name.
825
+
826
+ Returns **[Promise][12]<[string][3]>** CSS value
827
+
828
+ ### grabCssPropertyFromAll
829
+
830
+ Grab array of CSS properties for given locator
831
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
832
+
833
+ ```js
834
+ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
835
+ ```
836
+
837
+ #### Parameters
838
+
839
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
840
+ * `cssProperty` **[string][3]** CSS property name.
841
+
842
+ Returns **[Promise][12]<[Array][15]<[string][3]>>** CSS value
843
+
844
+ ### grabCurrentUrl
845
+
846
+ Get current URL from browser.
847
+ Resumes test execution, so should be used inside an async function.
848
+
849
+ ```js
850
+ let url = await I.grabCurrentUrl();
851
+ console.log(`Current URL is [${url}]`);
852
+ ```
853
+
854
+ Returns **[Promise][12]<[string][3]>** current URL
855
+
856
+ ### grabFromClipboard
857
+
858
+ Grabs the text content of the system clipboard and returns it to test.
859
+ Resumes test execution, so **should be used inside async function with `await`** operator.
860
+
861
+ ```js
862
+ I.click('Copy to clipboard');
863
+ let url = await I.grabFromClipboard();
864
+ ```
865
+
866
+ Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
867
+ in Chromium-based browsers, where read access is granted automatically.
868
+
869
+ Returns **[Promise][12]<[string][3]>** the system clipboard contents.
870
+
871
+ ### grabHTMLFrom
872
+
873
+ Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
874
+ Resumes test execution, so **should be used inside async function with `await`** operator.
875
+ If more than one element is found - HTML of first element is returned.
876
+
877
+ ```js
878
+ let postHTML = await I.grabHTMLFrom('#post');
879
+ ```
880
+
881
+ #### Parameters
882
+
883
+ * `locator` &#x20;
884
+ * `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
885
+
886
+ Returns **[Promise][12]<[string][3]>** HTML code for an element
887
+
888
+ ### grabHTMLFromAll
889
+
890
+ Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
891
+ Resumes test execution, so **should be used inside async function with `await`** operator.
892
+
893
+ ```js
894
+ let postHTMLs = await I.grabHTMLFromAll('.post');
895
+ ```
896
+
897
+ #### Parameters
898
+
899
+ * `locator` &#x20;
900
+ * `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
901
+
902
+ Returns **[Promise][12]<[Array][15]<[string][3]>>** HTML code for an element
903
+
904
+ ### grabNumberOfElements
905
+
906
+ Grab number of elements by locator.
907
+ Resumes test execution, so **should be used inside async function with `await`** operator.
908
+
909
+ ```js
910
+ let numOfElements = await I.grabNumberOfElements('p');
911
+ ```
912
+
913
+ #### Parameters
914
+
915
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
916
+
917
+ Returns **[Promise][12]<[number][8]>** number of matched elements.
918
+
919
+ ### grabNumberOfVisibleElements
920
+
921
+ Grab number of visible elements by locator.
922
+ Resumes test execution, so **should be used inside async function with `await`** operator.
923
+
924
+ ```js
925
+ let numOfElements = await I.grabNumberOfVisibleElements('p');
926
+ ```
927
+
928
+ #### Parameters
929
+
930
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
931
+
932
+ Returns **[Promise][12]<[number][8]>** number of visible elements
933
+
934
+ ### grabPageScrollPosition
935
+
936
+ Retrieves a page scroll position and returns it to test.
937
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
938
+
939
+ ```js
940
+ let { x, y } = await I.grabPageScrollPosition();
941
+ ```
942
+
943
+ Returns **[Promise][12]<PageScrollPosition>** scroll position
944
+
945
+ ### grabRecordedNetworkTraffics
946
+
947
+ Grab the recording network traffics
948
+
949
+ ```js
950
+ const traffics = await I.grabRecordedNetworkTraffics();
951
+ expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
952
+ expect(traffics[0].response.status).to.equal(200);
953
+ expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
954
+ ```
955
+
956
+ Returns **[Array][15]** recorded network traffics
957
+
958
+ ### grabSource
959
+
960
+ Retrieves page source and returns it to test.
961
+ Resumes test execution, so **should be used inside async function with `await`** operator.
962
+
963
+ ```js
964
+ let pageSource = await I.grabSource();
965
+ ```
966
+
967
+ Returns **[Promise][12]<[string][3]>** source code
968
+
969
+ ### grabTextFrom
970
+
971
+ Retrieves a text from an element located by CSS or XPath and returns it to test.
972
+ Resumes test execution, so **should be used inside async with `await`** operator.
973
+
974
+ ```js
975
+ let pin = await I.grabTextFrom('#pin');
976
+ ```
977
+
978
+ If multiple elements found returns first element.
979
+
980
+ #### Parameters
981
+
982
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
983
+
984
+ Returns **[Promise][12]<[string][3]>** attribute value
985
+
986
+ ### grabTextFromAll
987
+
988
+ Retrieves all texts from an element located by CSS or XPath and returns it to test.
989
+ Resumes test execution, so **should be used inside async with `await`** operator.
990
+
991
+ ```js
992
+ let pins = await I.grabTextFromAll('#pin li');
993
+ ```
994
+
995
+ #### Parameters
996
+
997
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
998
+
999
+ Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
1000
+
1001
+ ### grabTitle
1002
+
1003
+ Retrieves a page title and returns it to test.
1004
+ Resumes test execution, so **should be used inside async with `await`** operator.
1005
+
1006
+ ```js
1007
+ let title = await I.grabTitle();
1008
+ ```
1009
+
1010
+ Returns **[Promise][12]<[string][3]>** title
1011
+
1012
+ ### grabValueFrom
1013
+
1014
+ Retrieves a value from a form element located by CSS or XPath and returns it to test.
1015
+ Resumes test execution, so **should be used inside async function with `await`** operator.
1016
+ If more than one element is found - value of first element is returned.
1017
+
1018
+ ```js
1019
+ let email = await I.grabValueFrom('input[name=email]');
1020
+ ```
1021
+
1022
+ #### Parameters
1023
+
1024
+ * `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
1025
+
1026
+ Returns **[Promise][12]<[string][3]>** attribute value
1027
+
1028
+ ### grabValueFromAll
1029
+
1030
+ Retrieves an array of value from a form located by CSS or XPath and returns it to test.
1031
+ Resumes test execution, so **should be used inside async function with `await`** operator.
1032
+
1033
+ ```js
1034
+ let inputs = await I.grabValueFromAll('//form/input');
1035
+ ```
1036
+
1037
+ #### Parameters
1038
+
1039
+ * `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
1040
+
1041
+ Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
1042
+
1043
+ ### grabWebElement
1044
+
1045
+ Grab WebElement for given locator
1046
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
1047
+
1048
+ ```js
1049
+ const webElement = await I.grabWebElement('#button');
1050
+ ```
1051
+
1052
+ #### Parameters
1053
+
1054
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1055
+
1056
+ Returns **[Promise][12]<any>** WebElement of being used Web helper
1057
+
1058
+ ### grabWebElements
1059
+
1060
+ Grab WebElements for given locator
1061
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
1062
+
1063
+ ```js
1064
+ const webElements = await I.grabWebElements('#button');
1065
+ ```
1066
+
1067
+ #### Parameters
1068
+
1069
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1070
+
1071
+ Returns **[Promise][12]<any>** WebElement of being used Web helper
1072
+
1073
+ ### pressKey
1074
+
1075
+ Presses a key or a key combination on the focused element.
1076
+
1077
+ ```js
1078
+ I.pressKey('Enter');
1079
+ I.pressKey(['Control', 'a']);
1080
+ ```
1081
+
1082
+ #### Parameters
1083
+
1084
+ * `key` **([string][3] | [Array][15]<[string][3]>)** a key or an array of keys to combine (modifiers first).
1085
+
1086
+ Returns **void** automatically synchronized promise through #recorder
1087
+
1088
+ ### refreshPage
1089
+
1090
+ Reload the current page.
1091
+
1092
+ ```js
1093
+ I.refreshPage();
1094
+ ```
1095
+
1096
+ Returns **void** automatically synchronized promise through #recorder
1097
+
1098
+ ### resizeWindow
1099
+
1100
+ Resize the current window to provided width and height.
1101
+ First parameter can be set to `maximize`.
1102
+
1103
+ #### Parameters
1104
+
1105
+ * `width` **[number][8]** width in pixels or `maximize`.
1106
+ * `height` **[number][8]** height in pixels.
1107
+
1108
+ Returns **void** automatically synchronized promise through #recorder
1109
+
1110
+ ### rightClick
1111
+
1112
+ Performs right click on a clickable element matched by semantic locator, CSS or XPath.
1113
+
1114
+ ```js
1115
+ // right click element with id el
1116
+ I.rightClick('#el');
1117
+ // right click link or button with text "Click me"
1118
+ I.rightClick('Click me');
1119
+ // right click button with text "Click me" inside .context
1120
+ I.rightClick('Click me', '.context');
1121
+ ```
1122
+
1123
+ #### Parameters
1124
+
1125
+ * `locator` **([string][3] | [object][4])** clickable element located by CSS|XPath|strict locator.
1126
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1127
+
1128
+ Returns **void** automatically synchronized promise through #recorder
1129
+
1130
+ ### saveElementScreenshot
1131
+
1132
+ Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
1133
+ Filename is relative to output folder.
1134
+
1135
+ ```js
1136
+ I.saveElementScreenshot(`#submit`,'debug.png');
1137
+ ```
1138
+
1139
+ #### Parameters
1140
+
1141
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1142
+ * `fileName` **[string][3]** file name to save.
1143
+
1144
+ Returns **void** automatically synchronized promise through #recorder
1145
+
1146
+ ### saveScreenshot
1147
+
1148
+ Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
1149
+ Filename is relative to the output folder.
1150
+
1151
+ ```js
1152
+ I.saveScreenshot('debug.png');
1153
+ ```
1154
+
1155
+ #### Parameters
1156
+
1157
+ * `fileName` **[string][3]** file name to save.
1158
+
1159
+ Returns **void** automatically synchronized promise through #recorder
1160
+
1161
+ ### scrollPageToBottom
1162
+
1163
+ Scroll page to the bottom.
1164
+
1165
+ ```js
1166
+ I.scrollPageToBottom();
1167
+ ```
1168
+
1169
+ Returns **void** automatically synchronized promise through #recorder
1170
+
1171
+ ### scrollPageToTop
1172
+
1173
+ Scroll page to the top.
1174
+
1175
+ ```js
1176
+ I.scrollPageToTop();
1177
+ ```
1178
+
1179
+ Returns **void** automatically synchronized promise through #recorder
1180
+
1181
+ ### scrollTo
1182
+
1183
+ Scrolls to element matched by locator.
1184
+ Extra shift can be set with offsetX and offsetY options.
1185
+
1186
+ ```js
1187
+ I.scrollTo('footer');
1188
+ I.scrollTo('#submit', 5, 5);
1189
+ ```
1190
+
1191
+ #### Parameters
1192
+
1193
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
1194
+ * `offsetX` **[number][8]** (optional, `0` by default) X-axis offset.
1195
+ * `offsetY` **[number][8]** (optional, `0` by default) Y-axis offset.
1196
+
1197
+ Returns **void** automatically synchronized promise through #recorder
1198
+
1199
+ ### see
1200
+
1201
+ Checks that a page contains a visible text.
1202
+ Use context parameter to narrow down the search.
1203
+
1204
+ ```js
1205
+ I.see('Welcome'); // text welcome on a page
1206
+ I.see('Welcome', '.content'); // text inside .content div
1207
+ I.see('Register', {css: 'form.register'}); // use strict locator
1208
+ ```
1209
+
1210
+ #### Parameters
1211
+
1212
+ * `text` **[string][3]** expected on page.
1213
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
1214
+
1215
+ Returns **void** automatically synchronized promise through #recorder
1216
+
1217
+ ### seeAttributesOnElements
1218
+
1219
+ Checks that all elements with given locator have given attributes.
1220
+
1221
+ ```js
1222
+ I.seeAttributesOnElements('//form', { method: "post"});
1223
+ ```
1224
+
1225
+ #### Parameters
1226
+
1227
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
1228
+ * `attributes` **[object][4]** attributes and their values to check.
1229
+
1230
+ Returns **void** automatically synchronized promise through #recorder
1231
+
1232
+ ### seeCheckboxIsChecked
1233
+
1234
+ Verifies that the specified checkbox is checked.
1235
+
1236
+ ```js
1237
+ I.seeCheckboxIsChecked('Agree');
1238
+ I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1239
+ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1240
+ ```
1241
+
1242
+ #### Parameters
1243
+
1244
+ * `locator` &#x20;
1245
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
1246
+
1247
+ Returns **void** automatically synchronized promise through #recorder
1248
+
1249
+ ### seeClipboardEquals
1250
+
1251
+ Checks that the system clipboard is equal to the given text.
1252
+
1253
+ ```js
1254
+ I.click('Copy to clipboard');
1255
+ I.seeClipboardEquals('https://codecept.io');
1256
+ ```
1257
+
1258
+ Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
1259
+ in Chromium-based browsers, where read access is granted automatically.
1260
+
1261
+ #### Parameters
1262
+
1263
+ * `text` **[string][3]** value to check.
1264
+
1265
+ Returns **void** automatically synchronized promise through #recorder
1266
+
1267
+ ### seeCookie
1268
+
1269
+ Checks that cookie with given name exists.
1270
+
1271
+ ```js
1272
+ I.seeCookie('Auth');
1273
+ ```
1274
+
1275
+ #### Parameters
1276
+
1277
+ * `name` **[string][3]** cookie name.
1278
+
1279
+ Returns **void** automatically synchronized promise through #recorder
1280
+
1281
+ ### seeCssPropertiesOnElements
1282
+
1283
+ Checks that all elements with given locator have given CSS properties.
1284
+
1285
+ ```js
1286
+ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1287
+ ```
1288
+
1289
+ #### Parameters
1290
+
1291
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
1292
+ * `cssProperties` **[object][4]** object with CSS properties and their values to check.
1293
+
1294
+ Returns **void** automatically synchronized promise through #recorder
1295
+
1296
+ ### seeCurrentPathEquals
1297
+
1298
+ Checks that current URL path matches the expected path.
1299
+ Query strings and URL fragments are ignored.
1300
+
1301
+ ```js
1302
+ I.seeCurrentPathEquals('/info'); // passes for '/info', '/info?user=1', '/info#section'
1303
+ I.seeCurrentPathEquals('/'); // passes for '/', '/?user=ok', '/#top'
1304
+ ```
1305
+
1306
+ #### Parameters
1307
+
1308
+ * `path` **[string][3]** value to check.
1309
+
1310
+ Returns **void** automatically synchronized promise through #recorder
1311
+
1312
+ ### seeCurrentUrlEquals
1313
+
1314
+ Checks that current url is equal to provided one.
1315
+ If a relative url provided, a configured url will be prepended to it.
1316
+ So both examples will work:
1317
+
1318
+ ```js
1319
+ I.seeCurrentUrlEquals('/register');
1320
+ I.seeCurrentUrlEquals('http://my.site.com/register');
1321
+ ```
1322
+
1323
+ #### Parameters
1324
+
1325
+ * `url` **[string][3]** value to check.
1326
+
1327
+ Returns **void** automatically synchronized promise through #recorder
1328
+
1329
+ ### seeElement
1330
+
1331
+ Checks that a given Element is visible
1332
+ Element is located by CSS or XPath.
1333
+
1334
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
1335
+
1336
+ ```js
1337
+ I.seeElement('#modal');
1338
+ I.seeElement('#modal', '#container');
1339
+ // using ARIA role locator
1340
+ I.seeElement({role: 'dialog'});
1341
+ ```
1342
+
1343
+ > ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][7].
1344
+
1345
+ #### Parameters
1346
+
1347
+ * `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
1348
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1349
+
1350
+ Returns **void** automatically synchronized promise through #recorder
1351
+
1352
+ ### seeElementInDOM
1353
+
1354
+ Checks that a given Element is present in the DOM
1355
+ Element is located by CSS or XPath.
1356
+
1357
+ ```js
1358
+ I.seeElementInDOM('#modal');
1359
+ ```
1360
+
1361
+ #### Parameters
1362
+
1363
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1364
+
1365
+ Returns **void** automatically synchronized promise through #recorder
1366
+
1367
+ ### seeInClipboard
1368
+
1369
+ Checks that the system clipboard contains the given text.
1370
+
1371
+ ```js
1372
+ I.click('Copy to clipboard');
1373
+ I.seeInClipboard('https://codecept.io');
1374
+ ```
1375
+
1376
+ Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
1377
+ in Chromium-based browsers, where read access is granted automatically.
1378
+
1379
+ #### Parameters
1380
+
1381
+ * `text` **[string][3]** value to check.
1382
+
1383
+ Returns **void** automatically synchronized promise through #recorder
1384
+
1385
+ ### seeInCurrentUrl
1386
+
1387
+ Checks that current url contains a provided fragment.
1388
+
1389
+ ```js
1390
+ I.seeInCurrentUrl('/register'); // we are on registration page
1391
+ ```
1392
+
1393
+ #### Parameters
1394
+
1395
+ * `url` **[string][3]** a fragment to check
1396
+
1397
+ Returns **void** automatically synchronized promise through #recorder
1398
+
1399
+ ### seeInField
1400
+
1401
+ Checks that the given input field or textarea equals to given value.
1402
+ For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1403
+
1404
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1405
+
1406
+ ```js
1407
+ I.seeInField('Username', 'davert');
1408
+ I.seeInField({css: 'form textarea'},'Type your comment here');
1409
+ I.seeInField('form input[type=hidden]','hidden_value');
1410
+ I.seeInField('#searchform input','Search');
1411
+ // within a context
1412
+ I.seeInField('Name', 'John', '.form-container');
1413
+ ```
1414
+
1415
+ #### Parameters
1416
+
1417
+ * `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
1418
+ * `value` **([string][3] | [object][4])** value to check.
1419
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1420
+
1421
+ Returns **void** automatically synchronized promise through #recorder
1422
+
1423
+ ### seeInSource
1424
+
1425
+ Checks that the current page contains the given string in its raw source code.
1426
+
1427
+ ```js
1428
+ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1429
+ ```
1430
+
1431
+ #### Parameters
1432
+
1433
+ * `text` **[string][3]** value to check.
1434
+
1435
+ Returns **void** automatically synchronized promise through #recorder
1436
+
1437
+ ### seeInTitle
1438
+
1439
+ Checks that title contains text.
1440
+
1441
+ ```js
1442
+ I.seeInTitle('Home Page');
1443
+ ```
1444
+
1445
+ #### Parameters
1446
+
1447
+ * `text` **[string][3]** text value to check.
1448
+
1449
+ Returns **void** automatically synchronized promise through #recorder
1450
+
1451
+ ### seeNumberOfVisibleElements
1452
+
1453
+ Asserts that an element is visible a given number of times.
1454
+ Element is located by CSS or XPath.
1455
+
1456
+ ```js
1457
+ I.seeNumberOfVisibleElements('.buttons', 3);
1458
+ ```
1459
+
1460
+ #### Parameters
1461
+
1462
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1463
+ * `num` **[number][8]** number of elements.
1464
+
1465
+ Returns **void** automatically synchronized promise through #recorder
1466
+
1467
+ ### seeTraffic
1468
+
1469
+ Verifies that a certain request is part of network traffic.
1470
+
1471
+ ```js
1472
+ // checking the request url contains certain query strings
1473
+ I.amOnPage('https://openai.com/blog/chatgpt');
1474
+ I.startRecordingTraffic();
1475
+ await I.seeTraffic({
1476
+ name: 'sentry event',
1477
+ url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
1478
+ parameters: {
1479
+ width: '1919',
1480
+ height: '1138',
1481
+ },
1482
+ });
1483
+ ```
1484
+
1485
+ ```js
1486
+ // checking the request url contains certain post data
1487
+ I.amOnPage('https://openai.com/blog/chatgpt');
1488
+ I.startRecordingTraffic();
1489
+ await I.seeTraffic({
1490
+ name: 'event',
1491
+ url: 'https://cloudflareinsights.com/cdn-cgi/rum',
1492
+ requestPostData: {
1493
+ st: 2,
1494
+ },
1495
+ });
1496
+ ```
1497
+
1498
+ #### Parameters
1499
+
1500
+ * `opts` **[Object][4]** options when checking the traffic network.
1501
+
1502
+ * `opts.name` **[string][3]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
1503
+ * `opts.url` **[string][3]** Expected URL of request in network traffic
1504
+ * `opts.parameters` **[Object][4]?** Expected parameters of that request in network traffic
1505
+ * `opts.requestPostData` **[Object][4]?** Expected that request contains post data in network traffic
1506
+ * `opts.timeout` **[number][8]?** Timeout to wait for request in seconds. Default is 10 seconds.
1507
+
1508
+ Returns **void** automatically synchronized promise through #recorder
1509
+
1510
+ ### selectOption
1511
+
1512
+ Selects an option in a drop-down select.
1513
+ Field is searched by label | name | CSS | XPath.
1514
+ Option is selected by visible text or by value.
1515
+
1516
+ The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1517
+
1518
+ ```js
1519
+ I.selectOption('Choose Plan', 'Monthly'); // select by label
1520
+ I.selectOption('subscription', 'Monthly'); // match option by text
1521
+ I.selectOption('subscription', '0'); // or by value
1522
+ I.selectOption('//form/select[@name=account]','Premium');
1523
+ I.selectOption('form select[name=account]', 'Premium');
1524
+ I.selectOption({css: 'form select[name=account]'}, 'Premium');
1525
+ // within a context
1526
+ I.selectOption('age', '21-60', '#section2');
1527
+ ```
1528
+
1529
+ Provide an array for the second argument to select multiple options.
1530
+
1531
+ ```js
1532
+ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
1533
+ ```
1534
+
1535
+ #### Parameters
1536
+
1537
+ * `select` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
1538
+ * `option` **([string][3] | [Array][15]<any>)** visible text or value of option.
1539
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1540
+
1541
+ Returns **void** automatically synchronized promise through #recorder
1542
+
1543
+ ### setCookie
1544
+
1545
+ Sets cookie(s).
1546
+
1547
+ Can be a single cookie object or an array of cookies:
1548
+
1549
+ ```js
1550
+ I.setCookie({name: 'auth', value: true});
1551
+
1552
+ // as array
1553
+ I.setCookie([
1554
+ {name: 'auth', value: true},
1555
+ {name: 'agree', value: true}
1556
+ ]);
1557
+ ```
1558
+
1559
+ #### Parameters
1560
+
1561
+ * `cookie` **(Cookie | [Array][15]<Cookie>)** a cookie object or array of cookie objects.
1562
+
1563
+ Returns **void** automatically synchronized promise through #recorder
1564
+
1565
+ ### startRecordingTraffic
1566
+
1567
+ Starts recording the network traffics.
1568
+ This also resets recorded network requests.
1569
+
1570
+ ```js
1571
+ I.startRecordingTraffic();
1572
+ ```
1573
+
1574
+ Returns **void** automatically synchronized promise through #recorder
1575
+
1576
+ ### startScreencast
1577
+
1578
+ Starts recording a video of the page. Stop it with `stopScreencast`.
1579
+ Usually enabled through the `screencast` plugin rather than called directly.
1580
+
1581
+ ```js
1582
+ I.startScreencast();
1583
+ ```
1584
+
1585
+ #### Parameters
1586
+
1587
+ * `options` **[object][4]?** `{ maxWidth, maxHeight, quality, everyNthFrame }`
1588
+
1589
+ Returns **void** automatically synchronized promise through #recorder
1590
+
1591
+ ### stopRecordingTraffic
1592
+
1593
+ Stops recording of network traffic. Recorded traffic is not flashed.
1594
+
1595
+ ```js
1596
+ I.stopRecordingTraffic();
1597
+ ```
1598
+
1599
+ ### stopScreencast
1600
+
1601
+ Stops the recording started by `startScreencast` and returns it as an animated PNG.
1602
+
1603
+ ```js
1604
+ const video = await I.stopScreencast();
1605
+ ```
1606
+
1607
+ #### Parameters
1608
+
1609
+ * `options` **[object][4]?** `{ lastFrameDelayMs }`: how long the last frame is shown, in milliseconds (1000 by default).
1610
+
1611
+ Returns **[Promise][12]<([Buffer][16] | null)>** APNG data, or `null` if no frames were recorded.
1612
+
1613
+ ### type
1614
+
1615
+ Types out the given text into an active field.
1616
+ To slow down typing use a second parameter, to set interval between key presses.
1617
+ *Note:* Should be used when [`fillField`][17] is not an option.
1618
+
1619
+ ```js
1620
+ // passing in a string
1621
+ I.type('Type this out.');
1622
+
1623
+ // typing values with a 100ms interval
1624
+ I.type('4141555311111111', 100);
1625
+
1626
+ // passing in an array
1627
+ I.type(['T', 'E', 'X', 'T']);
1628
+
1629
+ // passing a secret
1630
+ I.type(secret('123456'));
1631
+ ```
1632
+
1633
+ #### Parameters
1634
+
1635
+ * `keys` &#x20;
1636
+ * `delay` **[number][8]?** (optional) delay in ms between key presses
1637
+ * `key` **([string][3] | [Array][15]<[string][3]>)** or array of keys to type.
1638
+
1639
+ Returns **void** automatically synchronized promise through #recorder
1640
+
1641
+ ### uncheckOption
1642
+
1643
+ Unselects a checkbox or radio button.
1644
+ Element is located by label or name or CSS or XPath.
1645
+
1646
+ The second parameter is an optional context (CSS or XPath locator) to narrow the search.
1647
+
1648
+ ```js
1649
+ I.uncheckOption('#agree');
1650
+ I.uncheckOption('I Agree to Terms and Conditions');
1651
+ I.uncheckOption('agree', '//form');
1652
+ ```
1653
+
1654
+ #### Parameters
1655
+
1656
+ * `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
1657
+ * `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1658
+
1659
+ Returns **void** automatically synchronized promise through #recorder
1660
+
1661
+ ### wait
1662
+
1663
+ Pauses execution for a number of seconds.
1664
+
1665
+ ```js
1666
+ I.wait(2); // wait 2 secs
1667
+ ```
1668
+
1669
+ #### Parameters
1670
+
1671
+ * `sec` **[number][8]** number of second to wait.
1672
+
1673
+ Returns **void** automatically synchronized promise through #recorder
1674
+
1675
+ ### waitCurrentPathEquals
1676
+
1677
+ Waits for the current URL path to match the expected path.
1678
+ Query strings and URL fragments are ignored.
1679
+
1680
+ ```js
1681
+ I.waitCurrentPathEquals('/info', 5);
1682
+ ```
1683
+
1684
+ #### Parameters
1685
+
1686
+ * `path` **[string][3]** value to check.
1687
+ * `sec` **[number][8]?** (optional, `waitForTimeout` by default) time in seconds to wait
1688
+
1689
+ Returns **void** automatically synchronized promise through #recorder
1690
+
1691
+ ### waitForCookie
1692
+
1693
+ Waits for the specified cookie in the cookies.
1694
+
1695
+ ```js
1696
+ I.waitForCookie("token");
1697
+ ```
1698
+
1699
+ #### Parameters
1700
+
1701
+ * `name` **[string][3]** expected cookie name.
1702
+ * `sec` **[number][8]** (optional, `3` by default) time in seconds to wait
1703
+
1704
+ Returns **void** automatically synchronized promise through #recorder
1705
+
1706
+ ### waitForDetached
1707
+
1708
+ Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
1709
+ Element can be located by CSS or XPath.
1710
+
1711
+ ```js
1712
+ I.waitForDetached('#popup');
1713
+ ```
1714
+
1715
+ #### Parameters
1716
+
1717
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1718
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1719
+
1720
+ Returns **void** automatically synchronized promise through #recorder
1721
+
1722
+ ### waitForElement
1723
+
1724
+ Waits for element to be present on page (by default waits for 1sec).
1725
+ Element can be located by CSS or XPath.
1726
+
1727
+ ```js
1728
+ I.waitForElement('.btn.continue');
1729
+ I.waitForElement('.btn.continue', 5); // wait for 5 secs
1730
+ ```
1731
+
1732
+ #### Parameters
1733
+
1734
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1735
+ * `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
1736
+
1737
+ Returns **void** automatically synchronized promise through #recorder
1738
+
1739
+ ### waitForFunction
1740
+
1741
+ Waits for a function to return true (waits for 1 sec by default).
1742
+ Running in browser context.
1743
+
1744
+ ```js
1745
+ I.waitForFunction(fn[, [args[, timeout]])
1746
+ ```
1747
+
1748
+ ```js
1749
+ I.waitForFunction(() => window.requests == 0);
1750
+ I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1751
+ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
1752
+ ```
1753
+
1754
+ #### Parameters
1755
+
1756
+ * `fn` **([string][3] | [function][11])** to be executed in browser context.
1757
+ * `argsOrSec` **([Array][15]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds.
1758
+ * `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
1759
+
1760
+ Returns **void** automatically synchronized promise through #recorder
1761
+
1762
+ ### waitForInvisible
1763
+
1764
+ Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1765
+ Element can be located by CSS or XPath.
1766
+
1767
+ ```js
1768
+ I.waitForInvisible('#popup');
1769
+ ```
1770
+
1771
+ #### Parameters
1772
+
1773
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1774
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1775
+
1776
+ Returns **void** automatically synchronized promise through #recorder
1777
+
1778
+ ### waitForText
1779
+
1780
+ Waits for a text to appear (by default waits for 1sec).
1781
+ Element can be located by CSS or XPath.
1782
+ Narrow down search results by providing context.
1783
+
1784
+ ```js
1785
+ I.waitForText('Thank you, form has been submitted');
1786
+ I.waitForText('Thank you, form has been submitted', 5, '#modal');
1787
+ ```
1788
+
1789
+ #### Parameters
1790
+
1791
+ * `text` **[string][3]** to wait for.
1792
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1793
+ * `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator.
1794
+
1795
+ Returns **void** automatically synchronized promise through #recorder
1796
+
1797
+ ### waitForVisible
1798
+
1799
+ Waits for an element to become visible on a page (by default waits for 1sec).
1800
+ Element can be located by CSS or XPath.
1801
+
1802
+ ```js
1803
+ I.waitForVisible('#popup');
1804
+ ```
1805
+
1806
+ #### Parameters
1807
+
1808
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1809
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1810
+
1811
+ Returns **void** automatically synchronized promise through #recorder
1812
+
1813
+ ### waitInUrl
1814
+
1815
+ Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
1816
+
1817
+ ```js
1818
+ I.waitInUrl('/info', 2);
1819
+ ```
1820
+
1821
+ #### Parameters
1822
+
1823
+ * `urlPart` **[string][3]** value to check.
1824
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1825
+
1826
+ Returns **void** automatically synchronized promise through #recorder
1827
+
1828
+ ### waitToHide
1829
+
1830
+ Waits for an element to hide (by default waits for 1sec).
1831
+ Element can be located by CSS or XPath.
1832
+
1833
+ ```js
1834
+ I.waitToHide('#popup');
1835
+ ```
1836
+
1837
+ #### Parameters
1838
+
1839
+ * `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1840
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1841
+
1842
+ Returns **void** automatically synchronized promise through #recorder
1843
+
1844
+ ### waitUrlEquals
1845
+
1846
+ Waits for the entire URL to match the expected
1847
+
1848
+ ```js
1849
+ I.waitUrlEquals('/info', 2);
1850
+ I.waitUrlEquals('http://127.0.0.1:8000/info');
1851
+ ```
1852
+
1853
+ #### Parameters
1854
+
1855
+ * `urlPart` **[string][3]** value to check.
1856
+ * `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
1857
+
1858
+ Returns **void** automatically synchronized promise through #recorder
1859
+
1860
+ ### _connect
1861
+
1862
+ In SELF-MANAGED mode, resolves and spawns the browser server (or courtesy-attaches to an
1863
+ already-running one on :9222) exactly once via `_resolveSelfManaged`. Then resolves the CDP
1864
+ endpoint and opens the underlying `CDPConnection`, storing it on `this.cdp`.
1865
+
1866
+ ### _findFreePort
1867
+
1868
+ Picks a free TCP port on 127.0.0.1 by briefly listening on port 0 and reading back the
1869
+ OS-assigned port. Used when `options.port` isn't explicitly set, so multiple `run-workers`
1870
+ workers never collide on the same port.
1871
+
1872
+ Returns **[Promise][12]<[number][8]>** a free port.
1873
+
1874
+ ### _manageServer
1875
+
1876
+ Opts a subclass into managing its own browser server process. Called from a subclass
1877
+ constructor with the raw user config and a server descriptor:
1878
+
1879
+ * `name` — binary name looked up on `PATH`, also used in messages
1880
+ * `envVar` — environment variable that may point at the binary
1881
+ * `args(port)` — arguments the binary is spawned with to serve CDP on `port`
1882
+ * `env` — extra environment variables for the spawned process
1883
+ * `releases` — URL shown when no binary can be resolved
1884
+
1885
+ An explicit `endpoint` in the user config always wins: the helper stays in ATTACH mode and
1886
+ never spawns or kills anything. Otherwise the helper becomes SELF-MANAGED and the default
1887
+ `endpoint` is cleared until `_resolveSelfManaged` sets the real one.
1888
+
1889
+ #### Parameters
1890
+
1891
+ * `config` **[object][4]** the config object the helper was constructed with.
1892
+ * `server` **[object][4]** the server descriptor described above.
1893
+
1894
+ ### _probeUp
1895
+
1896
+ Probes a `/json/version`-style URL with a short timeout, used for the courtesy-attach check.
1897
+
1898
+ #### Parameters
1899
+
1900
+ * `url` **[string][3]**&#x20;
1901
+
1902
+ Returns **[Promise][12]<[boolean][18]>** true if the URL answered.
1903
+
1904
+ ### _resolveBinary
1905
+
1906
+ Resolves the binary to spawn, in priority order: `options.binaryPath`, then the server
1907
+ descriptor's environment variable, then its name on `PATH`. The `PATH` lookup walks the
1908
+ directories itself instead of shelling out to `which`, which does not exist on Windows: on
1909
+ Windows every `PATHEXT` suffix is tried, so a `.exe` on `PATH` is found too.
1910
+
1911
+ Returns **([string][3] | null)** an absolute or relative path to the binary, or null if none resolved.
1912
+
1913
+ ### _resolveSelfManaged
1914
+
1915
+ Resolves how to reach a SELF-MANAGED browser, trying, in order: spawn a binary
1916
+ (`binaryPath` config, then the descriptor's `envVar`, then its `name` on `PATH`) on
1917
+ `options.port` or a free port, courtesy-attach to `http://127.0.0.1:9222` if something already
1918
+ answers there (never killed by this helper), or throw a loud, actionable error. Sets
1919
+ `this.options.endpoint` as a side effect.
1920
+
1921
+ A spawn failure (e.g. a bad binary) is delivered asynchronously by Node as an `error` event;
1922
+ it is recorded on `this.serverError` and surfaced as a rejection from `_waitForServer` instead
1923
+ of crashing the process as an uncaught exception.
1924
+
1925
+ ### _waitForServer
1926
+
1927
+ Polls `http://127.0.0.1:<port>/json/version` until the spawned server responds,
1928
+ `this.serverError` is set by the process' `error` event, or `options.serverStartTimeout`
1929
+ elapses. The process typically comes up within tens of milliseconds — a 20ms retry interval
1930
+ keeps the wasted tail after the server is actually ready small, since this cost is paid once
1931
+ per run and counts directly toward real-world startup latency.
1932
+
131
1933
  [1]: https://lightpanda.io
132
1934
 
133
1935
  [2]: https://lightpanda.io/docs/open-source/installation
134
1936
 
135
- [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
1937
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1938
+
1939
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
1940
+
1941
+ [5]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
1942
+
1943
+ [6]: https://playwright.dev/docs/api/class-locator#locator-blur
1944
+
1945
+ [7]: /locators#aria-locators
1946
+
1947
+ [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
1948
+
1949
+ [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp
1950
+
1951
+ [10]: https://vuejs.org/v2/api/#Vue-nextTick
1952
+
1953
+ [11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1954
+
1955
+ [12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1956
+
1957
+ [13]: https://playwright.dev/docs/api/class-locator#locator-focus
1958
+
1959
+ [14]: https://playwright.dev/docs/aria-snapshots
1960
+
1961
+ [15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
1962
+
1963
+ [16]: https://nodejs.org/api/buffer.html
136
1964
 
137
- [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1965
+ [17]: #fillfield
138
1966
 
139
- [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
1967
+ [18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean