codeceptjs 3.2.2 → 3.3.0-beta.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.
- package/CHANGELOG.md +57 -0
- package/docs/advanced.md +2 -2
- package/docs/api.md +227 -188
- package/docs/build/ApiDataFactory.js +13 -6
- package/docs/build/Appium.js +98 -36
- package/docs/build/FileSystem.js +11 -1
- package/docs/build/GraphQL.js +11 -0
- package/docs/build/JSONResponse.js +297 -0
- package/docs/build/Nightmare.js +48 -48
- package/docs/build/Playwright.js +271 -151
- package/docs/build/Puppeteer.js +76 -67
- package/docs/build/REST.js +36 -0
- package/docs/build/TestCafe.js +44 -44
- package/docs/build/WebDriver.js +69 -69
- package/docs/changelog.md +7 -0
- package/docs/configuration.md +8 -8
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +9 -9
- package/docs/helpers/ApiDataFactory.md +7 -0
- package/docs/helpers/Appium.md +240 -198
- package/docs/helpers/FileSystem.md +11 -1
- package/docs/helpers/JSONResponse.md +230 -0
- package/docs/helpers/Playwright.md +283 -216
- package/docs/helpers/Puppeteer.md +9 -1
- package/docs/helpers/REST.md +30 -9
- package/docs/installation.md +3 -1
- package/docs/internal-api.md +265 -0
- package/docs/mobile.md +11 -11
- package/docs/nightmare.md +3 -3
- package/docs/playwright.md +73 -18
- package/docs/plugins.md +136 -36
- package/docs/puppeteer.md +28 -12
- package/docs/quickstart.md +2 -3
- package/docs/reports.md +44 -3
- package/docs/testcafe.md +1 -1
- package/docs/translation.md +2 -2
- package/docs/videos.md +2 -2
- package/docs/visual.md +2 -2
- package/docs/vue.md +1 -1
- package/docs/webdriver.md +92 -4
- package/lib/cli.js +25 -20
- package/lib/command/init.js +5 -15
- package/lib/command/workers/runTests.js +25 -7
- package/lib/config.js +17 -13
- package/lib/helper/ApiDataFactory.js +13 -6
- package/lib/helper/Appium.js +65 -3
- package/lib/helper/FileSystem.js +11 -1
- package/lib/helper/GraphQL.js +11 -0
- package/lib/helper/JSONResponse.js +297 -0
- package/lib/helper/Playwright.js +209 -89
- package/lib/helper/Puppeteer.js +12 -3
- package/lib/helper/REST.js +36 -0
- package/lib/helper/extras/Console.js +8 -0
- package/lib/helper/extras/PlaywrightRestartOpts.js +35 -0
- package/lib/interfaces/bdd.js +3 -1
- package/lib/plugin/allure.js +12 -0
- package/lib/plugin/autoLogin.js +1 -1
- package/lib/plugin/eachElement.js +127 -0
- package/lib/plugin/tryTo.js +6 -0
- package/lib/utils.js +20 -0
- package/package.json +25 -23
- package/translations/pt-BR.js +8 -0
- package/typings/index.d.ts +4 -0
- package/typings/types.d.ts +318 -109
package/typings/types.d.ts
CHANGED
|
@@ -186,11 +186,14 @@ declare namespace CodeceptJS {
|
|
|
186
186
|
* // create user with defined email
|
|
187
187
|
* // and receive it when inside async function
|
|
188
188
|
* const user = await I.have('user', { email: 'user@user.com'});
|
|
189
|
+
* // create a user with options that will not be included in the final request
|
|
190
|
+
* I.have('user', { }, { age: 33, height: 55 })
|
|
189
191
|
* ```
|
|
190
192
|
* @param factory - factory to use
|
|
191
193
|
* @param params - predefined parameters
|
|
194
|
+
* @param options - options for programmatically generate the attributes
|
|
192
195
|
*/
|
|
193
|
-
have(factory: any, params: any): void;
|
|
196
|
+
have(factory: any, params: any, options: any): void;
|
|
194
197
|
/**
|
|
195
198
|
* Generates bunch of records and saves multiple API requests to store them.
|
|
196
199
|
*
|
|
@@ -200,9 +203,12 @@ declare namespace CodeceptJS {
|
|
|
200
203
|
*
|
|
201
204
|
* // create 3 posts by one author
|
|
202
205
|
* I.haveMultiple('post', 3, { author: 'davert' });
|
|
206
|
+
*
|
|
207
|
+
* // create 3 posts by one author with options
|
|
208
|
+
* I.haveMultiple('post', 3, { author: 'davert' }, { publish_date: '01.01.1997' });
|
|
203
209
|
* ```
|
|
204
210
|
*/
|
|
205
|
-
haveMultiple(factory: any, times: any, params: any): void;
|
|
211
|
+
haveMultiple(factory: any, times: any, params: any, options: any): void;
|
|
206
212
|
/**
|
|
207
213
|
* Executes request to create a record in API.
|
|
208
214
|
* Can be replaced from a in custom helper.
|
|
@@ -249,7 +255,7 @@ declare namespace CodeceptJS {
|
|
|
249
255
|
* });
|
|
250
256
|
* ```
|
|
251
257
|
*/
|
|
252
|
-
runOnIOS(caps: any, fn: any):
|
|
258
|
+
runOnIOS(caps: any, fn: any): Promise<any>;
|
|
253
259
|
/**
|
|
254
260
|
* Execute code only on Android
|
|
255
261
|
*
|
|
@@ -281,7 +287,7 @@ declare namespace CodeceptJS {
|
|
|
281
287
|
* });
|
|
282
288
|
* ```
|
|
283
289
|
*/
|
|
284
|
-
runOnAndroid(caps: any, fn: any):
|
|
290
|
+
runOnAndroid(caps: any, fn: any): Promise<any>;
|
|
285
291
|
/**
|
|
286
292
|
* Check if an app is installed.
|
|
287
293
|
*
|
|
@@ -289,10 +295,9 @@ declare namespace CodeceptJS {
|
|
|
289
295
|
* I.seeAppIsInstalled("com.example.android.apis");
|
|
290
296
|
* ```
|
|
291
297
|
* @param bundleId - String ID of bundled app
|
|
292
|
-
*
|
|
293
|
-
* Appium: support only Android
|
|
298
|
+
* @returns Appium: support only Android
|
|
294
299
|
*/
|
|
295
|
-
seeAppIsInstalled(bundleId: string): void
|
|
300
|
+
seeAppIsInstalled(bundleId: string): Promise<void>;
|
|
296
301
|
/**
|
|
297
302
|
* Check if an app is not installed.
|
|
298
303
|
*
|
|
@@ -300,10 +305,9 @@ declare namespace CodeceptJS {
|
|
|
300
305
|
* I.seeAppIsNotInstalled("com.example.android.apis");
|
|
301
306
|
* ```
|
|
302
307
|
* @param bundleId - String ID of bundled app
|
|
303
|
-
*
|
|
304
|
-
* Appium: support only Android
|
|
308
|
+
* @returns Appium: support only Android
|
|
305
309
|
*/
|
|
306
|
-
seeAppIsNotInstalled(bundleId: string): void
|
|
310
|
+
seeAppIsNotInstalled(bundleId: string): Promise<void>;
|
|
307
311
|
/**
|
|
308
312
|
* Install an app on device.
|
|
309
313
|
*
|
|
@@ -311,10 +315,9 @@ declare namespace CodeceptJS {
|
|
|
311
315
|
* I.installApp('/path/to/file.apk');
|
|
312
316
|
* ```
|
|
313
317
|
* @param path - path to apk file
|
|
314
|
-
*
|
|
315
|
-
* Appium: support only Android
|
|
318
|
+
* @returns Appium: support only Android
|
|
316
319
|
*/
|
|
317
|
-
installApp(path: string): void
|
|
320
|
+
installApp(path: string): Promise<void>;
|
|
318
321
|
/**
|
|
319
322
|
* Remove an app from the device.
|
|
320
323
|
*
|
|
@@ -332,29 +335,27 @@ declare namespace CodeceptJS {
|
|
|
332
335
|
* ```js
|
|
333
336
|
* I.seeCurrentActivityIs(".HomeScreenActivity")
|
|
334
337
|
* ```
|
|
335
|
-
* @
|
|
338
|
+
* @returns Appium: support only Android
|
|
336
339
|
*/
|
|
337
|
-
seeCurrentActivityIs(currentActivity: string): void
|
|
340
|
+
seeCurrentActivityIs(currentActivity: string): Promise<void>;
|
|
338
341
|
/**
|
|
339
342
|
* Check whether the device is locked.
|
|
340
343
|
*
|
|
341
344
|
* ```js
|
|
342
345
|
* I.seeDeviceIsLocked();
|
|
343
346
|
* ```
|
|
344
|
-
*
|
|
345
|
-
* Appium: support only Android
|
|
347
|
+
* @returns Appium: support only Android
|
|
346
348
|
*/
|
|
347
|
-
seeDeviceIsLocked(): void
|
|
349
|
+
seeDeviceIsLocked(): Promise<void>;
|
|
348
350
|
/**
|
|
349
351
|
* Check whether the device is not locked.
|
|
350
352
|
*
|
|
351
353
|
* ```js
|
|
352
354
|
* I.seeDeviceIsUnlocked();
|
|
353
355
|
* ```
|
|
354
|
-
*
|
|
355
|
-
* Appium: support only Android
|
|
356
|
+
* @returns Appium: support only Android
|
|
356
357
|
*/
|
|
357
|
-
seeDeviceIsUnlocked(): void
|
|
358
|
+
seeDeviceIsUnlocked(): Promise<void>;
|
|
358
359
|
/**
|
|
359
360
|
* Check the device orientation
|
|
360
361
|
*
|
|
@@ -366,7 +367,7 @@ declare namespace CodeceptJS {
|
|
|
366
367
|
*
|
|
367
368
|
* Appium: support Android and iOS
|
|
368
369
|
*/
|
|
369
|
-
seeOrientationIs(orientation: 'LANDSCAPE' | 'PORTRAIT'): void
|
|
370
|
+
seeOrientationIs(orientation: 'LANDSCAPE' | 'PORTRAIT'): Promise<void>;
|
|
370
371
|
/**
|
|
371
372
|
* Set a device orientation. Will fail, if app will not set orientation
|
|
372
373
|
*
|
|
@@ -375,40 +376,36 @@ declare namespace CodeceptJS {
|
|
|
375
376
|
* I.setOrientation('LANDSCAPE')
|
|
376
377
|
* ```
|
|
377
378
|
* @param orientation - LANDSCAPE or PORTRAIT
|
|
378
|
-
*
|
|
379
|
-
* Appium: support Android and iOS
|
|
379
|
+
* @returns Appium: support Android and iOS
|
|
380
380
|
*/
|
|
381
|
-
setOrientation(orientation: 'LANDSCAPE' | 'PORTRAIT'):
|
|
381
|
+
setOrientation(orientation: 'LANDSCAPE' | 'PORTRAIT'): Promise<any>;
|
|
382
382
|
/**
|
|
383
383
|
* Get list of all available contexts
|
|
384
384
|
*
|
|
385
385
|
* ```
|
|
386
386
|
* let contexts = await I.grabAllContexts();
|
|
387
387
|
* ```
|
|
388
|
-
*
|
|
389
|
-
* Appium: support Android and iOS
|
|
388
|
+
* @returns Appium: support Android and iOS
|
|
390
389
|
*/
|
|
391
|
-
grabAllContexts():
|
|
390
|
+
grabAllContexts(): Promise<string[]>;
|
|
392
391
|
/**
|
|
393
392
|
* Retrieve current context
|
|
394
393
|
*
|
|
395
394
|
* ```js
|
|
396
395
|
* let context = await I.grabContext();
|
|
397
396
|
* ```
|
|
398
|
-
*
|
|
399
|
-
* Appium: support Android and iOS
|
|
397
|
+
* @returns Appium: support Android and iOS
|
|
400
398
|
*/
|
|
401
|
-
grabContext():
|
|
399
|
+
grabContext(): Promise<string | null>;
|
|
402
400
|
/**
|
|
403
401
|
* Get current device activity.
|
|
404
402
|
*
|
|
405
403
|
* ```js
|
|
406
404
|
* let activity = await I.grabCurrentActivity();
|
|
407
405
|
* ```
|
|
408
|
-
*
|
|
409
|
-
* Appium: support only Android
|
|
406
|
+
* @returns Appium: support only Android
|
|
410
407
|
*/
|
|
411
|
-
grabCurrentActivity():
|
|
408
|
+
grabCurrentActivity(): Promise<string>;
|
|
412
409
|
/**
|
|
413
410
|
* Get information about the current network connection (Data/WIFI/Airplane).
|
|
414
411
|
* The actual server value will be a number. However WebdriverIO additional
|
|
@@ -417,30 +414,27 @@ declare namespace CodeceptJS {
|
|
|
417
414
|
* ```js
|
|
418
415
|
* let con = await I.grabNetworkConnection();
|
|
419
416
|
* ```
|
|
420
|
-
*
|
|
421
|
-
* Appium: support only Android
|
|
417
|
+
* @returns Appium: support only Android
|
|
422
418
|
*/
|
|
423
|
-
grabNetworkConnection():
|
|
419
|
+
grabNetworkConnection(): Promise<{}>;
|
|
424
420
|
/**
|
|
425
421
|
* Get current orientation.
|
|
426
422
|
*
|
|
427
423
|
* ```js
|
|
428
424
|
* let orientation = await I.grabOrientation();
|
|
429
425
|
* ```
|
|
430
|
-
*
|
|
431
|
-
* Appium: support Android and iOS
|
|
426
|
+
* @returns Appium: support Android and iOS
|
|
432
427
|
*/
|
|
433
|
-
grabOrientation():
|
|
428
|
+
grabOrientation(): Promise<string>;
|
|
434
429
|
/**
|
|
435
430
|
* Get all the currently specified settings.
|
|
436
431
|
*
|
|
437
432
|
* ```js
|
|
438
433
|
* let settings = await I.grabSettings();
|
|
439
434
|
* ```
|
|
440
|
-
*
|
|
441
|
-
* Appium: support Android and iOS
|
|
435
|
+
* @returns Appium: support Android and iOS
|
|
442
436
|
*/
|
|
443
|
-
grabSettings():
|
|
437
|
+
grabSettings(): Promise<string>;
|
|
444
438
|
/**
|
|
445
439
|
* Switch to the specified context.
|
|
446
440
|
* @param context - the context to switch to
|
|
@@ -458,7 +452,7 @@ declare namespace CodeceptJS {
|
|
|
458
452
|
* I.switchToWeb('WEBVIEW_io.selendroid.testapp');
|
|
459
453
|
* ```
|
|
460
454
|
*/
|
|
461
|
-
switchToWeb(context?: string): void
|
|
455
|
+
switchToWeb(context?: string): Promise<void>;
|
|
462
456
|
/**
|
|
463
457
|
* Switches to native context.
|
|
464
458
|
* By default switches to NATIVE_APP context unless other specified.
|
|
@@ -470,17 +464,16 @@ declare namespace CodeceptJS {
|
|
|
470
464
|
* I.switchToNative('SOME_OTHER_CONTEXT');
|
|
471
465
|
* ```
|
|
472
466
|
*/
|
|
473
|
-
switchToNative(context: any): void
|
|
467
|
+
switchToNative(context: any): Promise<void>;
|
|
474
468
|
/**
|
|
475
469
|
* Start an arbitrary Android activity during a session.
|
|
476
470
|
*
|
|
477
471
|
* ```js
|
|
478
472
|
* I.startActivity('io.selendroid.testapp', '.RegisterUserActivity');
|
|
479
473
|
* ```
|
|
480
|
-
*
|
|
481
|
-
* Appium: support only Android
|
|
474
|
+
* @returns Appium: support only Android
|
|
482
475
|
*/
|
|
483
|
-
startActivity(): void
|
|
476
|
+
startActivity(): Promise<void>;
|
|
484
477
|
/**
|
|
485
478
|
* Set network connection mode.
|
|
486
479
|
*
|
|
@@ -496,10 +489,9 @@ declare namespace CodeceptJS {
|
|
|
496
489
|
* I.setNetworkConnection(6) // airplane mode off, wifi on, data on
|
|
497
490
|
* ```
|
|
498
491
|
* See corresponding [webdriverio reference](http://webdriver.io/api/mobile/setNetworkConnection.html).
|
|
499
|
-
*
|
|
500
|
-
* Appium: support only Android
|
|
492
|
+
* @returns Appium: support only Android
|
|
501
493
|
*/
|
|
502
|
-
setNetworkConnection():
|
|
494
|
+
setNetworkConnection(): Promise<{}>;
|
|
503
495
|
/**
|
|
504
496
|
* Update the current setting on the device
|
|
505
497
|
*
|
|
@@ -507,10 +499,9 @@ declare namespace CodeceptJS {
|
|
|
507
499
|
* I.setSettings({cyberdelia: 'open'});
|
|
508
500
|
* ```
|
|
509
501
|
* @param settings - object
|
|
510
|
-
*
|
|
511
|
-
* Appium: support Android and iOS
|
|
502
|
+
* @returns Appium: support Android and iOS
|
|
512
503
|
*/
|
|
513
|
-
setSettings(settings: any):
|
|
504
|
+
setSettings(settings: any): Promise<any>;
|
|
514
505
|
/**
|
|
515
506
|
* Hide the keyboard.
|
|
516
507
|
*
|
|
@@ -536,20 +527,18 @@ declare namespace CodeceptJS {
|
|
|
536
527
|
* I.sendDeviceKeyEvent(3);
|
|
537
528
|
* ```
|
|
538
529
|
* @param keyValue - Device specific key value
|
|
539
|
-
*
|
|
540
|
-
* Appium: support only Android
|
|
530
|
+
* @returns Appium: support only Android
|
|
541
531
|
*/
|
|
542
|
-
sendDeviceKeyEvent(keyValue: number): void
|
|
532
|
+
sendDeviceKeyEvent(keyValue: number): Promise<void>;
|
|
543
533
|
/**
|
|
544
534
|
* Open the notifications panel on the device.
|
|
545
535
|
*
|
|
546
536
|
* ```js
|
|
547
537
|
* I.openNotifications();
|
|
548
538
|
* ```
|
|
549
|
-
*
|
|
550
|
-
* Appium: support only Android
|
|
539
|
+
* @returns Appium: support only Android
|
|
551
540
|
*/
|
|
552
|
-
openNotifications(): void
|
|
541
|
+
openNotifications(): Promise<void>;
|
|
553
542
|
/**
|
|
554
543
|
* The Touch Action API provides the basis of all gestures that can be
|
|
555
544
|
* automated in Appium. At its core is the ability to chain together ad hoc
|
|
@@ -560,10 +549,9 @@ declare namespace CodeceptJS {
|
|
|
560
549
|
* ```js
|
|
561
550
|
* I.makeTouchAction("~buttonStartWebviewCD", 'tap');
|
|
562
551
|
* ```
|
|
563
|
-
*
|
|
564
|
-
* Appium: support Android and iOS
|
|
552
|
+
* @returns Appium: support Android and iOS
|
|
565
553
|
*/
|
|
566
|
-
makeTouchAction(): void
|
|
554
|
+
makeTouchAction(): Promise<void>;
|
|
567
555
|
/**
|
|
568
556
|
* Taps on element.
|
|
569
557
|
*
|
|
@@ -573,16 +561,16 @@ declare namespace CodeceptJS {
|
|
|
573
561
|
*
|
|
574
562
|
* Shortcut for `makeTouchAction`
|
|
575
563
|
*/
|
|
576
|
-
tap(locator: any): void
|
|
564
|
+
tap(locator: any): Promise<void>;
|
|
577
565
|
/**
|
|
578
566
|
* Perform a swipe on the screen.
|
|
579
567
|
*
|
|
580
568
|
* ```js
|
|
581
|
-
* I.
|
|
569
|
+
* I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 });
|
|
582
570
|
* ```
|
|
583
571
|
* @param to - Appium: support Android and iOS
|
|
584
572
|
*/
|
|
585
|
-
performSwipe(from:
|
|
573
|
+
performSwipe(from: any, to: any): void;
|
|
586
574
|
/**
|
|
587
575
|
* Perform a swipe down on an element.
|
|
588
576
|
*
|
|
@@ -594,10 +582,9 @@ declare namespace CodeceptJS {
|
|
|
594
582
|
* ```
|
|
595
583
|
* @param [yoffset = 1000] - (optional)
|
|
596
584
|
* @param [speed = 1000] - (optional), 1000 by default
|
|
597
|
-
*
|
|
598
|
-
* Appium: support Android and iOS
|
|
585
|
+
* @returns Appium: support Android and iOS
|
|
599
586
|
*/
|
|
600
|
-
swipeDown(locator: CodeceptJS.LocatorOrString, yoffset?: number, speed?: number): void
|
|
587
|
+
swipeDown(locator: CodeceptJS.LocatorOrString, yoffset?: number, speed?: number): Promise<void>;
|
|
601
588
|
/**
|
|
602
589
|
* Perform a swipe left on an element.
|
|
603
590
|
*
|
|
@@ -609,10 +596,9 @@ declare namespace CodeceptJS {
|
|
|
609
596
|
* ```
|
|
610
597
|
* @param [xoffset = 1000] - (optional)
|
|
611
598
|
* @param [speed = 1000] - (optional), 1000 by default
|
|
612
|
-
*
|
|
613
|
-
* Appium: support Android and iOS
|
|
599
|
+
* @returns Appium: support Android and iOS
|
|
614
600
|
*/
|
|
615
|
-
swipeLeft(locator: CodeceptJS.LocatorOrString, xoffset?: number, speed?: number): void
|
|
601
|
+
swipeLeft(locator: CodeceptJS.LocatorOrString, xoffset?: number, speed?: number): Promise<void>;
|
|
616
602
|
/**
|
|
617
603
|
* Perform a swipe right on an element.
|
|
618
604
|
*
|
|
@@ -624,10 +610,9 @@ declare namespace CodeceptJS {
|
|
|
624
610
|
* ```
|
|
625
611
|
* @param [xoffset = 1000] - (optional)
|
|
626
612
|
* @param [speed = 1000] - (optional), 1000 by default
|
|
627
|
-
*
|
|
628
|
-
* Appium: support Android and iOS
|
|
613
|
+
* @returns Appium: support Android and iOS
|
|
629
614
|
*/
|
|
630
|
-
swipeRight(locator: CodeceptJS.LocatorOrString, xoffset?: number, speed?: number): void
|
|
615
|
+
swipeRight(locator: CodeceptJS.LocatorOrString, xoffset?: number, speed?: number): Promise<void>;
|
|
631
616
|
/**
|
|
632
617
|
* Perform a swipe up on an element.
|
|
633
618
|
*
|
|
@@ -639,10 +624,9 @@ declare namespace CodeceptJS {
|
|
|
639
624
|
* ```
|
|
640
625
|
* @param [yoffset = 1000] - (optional)
|
|
641
626
|
* @param [speed = 1000] - (optional), 1000 by default
|
|
642
|
-
*
|
|
643
|
-
* Appium: support Android and iOS
|
|
627
|
+
* @returns Appium: support Android and iOS
|
|
644
628
|
*/
|
|
645
|
-
swipeUp(locator: CodeceptJS.LocatorOrString, yoffset?: number, speed?: number): void
|
|
629
|
+
swipeUp(locator: CodeceptJS.LocatorOrString, yoffset?: number, speed?: number): Promise<void>;
|
|
646
630
|
/**
|
|
647
631
|
* Perform a swipe in selected direction on an element to searchable element.
|
|
648
632
|
*
|
|
@@ -655,9 +639,9 @@ declare namespace CodeceptJS {
|
|
|
655
639
|
* 100,
|
|
656
640
|
* 500);
|
|
657
641
|
* ```
|
|
658
|
-
* @
|
|
642
|
+
* @returns Appium: support Android and iOS
|
|
659
643
|
*/
|
|
660
|
-
swipeTo(searchableLocator: string, scrollLocator: string, direction: string, timeout: number, offset: number, speed: number): void
|
|
644
|
+
swipeTo(searchableLocator: string, scrollLocator: string, direction: string, timeout: number, offset: number, speed: number): Promise<void>;
|
|
661
645
|
/**
|
|
662
646
|
* Performs a specific touch action.
|
|
663
647
|
* The action object need to contain the action name, x/y coordinates
|
|
@@ -694,20 +678,18 @@ declare namespace CodeceptJS {
|
|
|
694
678
|
* // save file to output dir
|
|
695
679
|
* I.pullFile('/storage/emulated/0/DCIM/logo.png', output_dir);
|
|
696
680
|
* ```
|
|
697
|
-
*
|
|
698
|
-
* Appium: support Android and iOS
|
|
681
|
+
* @returns Appium: support Android and iOS
|
|
699
682
|
*/
|
|
700
|
-
pullFile():
|
|
683
|
+
pullFile(path: string, dest: string): Promise<string>;
|
|
701
684
|
/**
|
|
702
685
|
* Perform a shake action on the device.
|
|
703
686
|
*
|
|
704
687
|
* ```js
|
|
705
688
|
* I.shakeDevice();
|
|
706
689
|
* ```
|
|
707
|
-
*
|
|
708
|
-
* Appium: support only iOS
|
|
690
|
+
* @returns Appium: support only iOS
|
|
709
691
|
*/
|
|
710
|
-
shakeDevice(): void
|
|
692
|
+
shakeDevice(): Promise<void>;
|
|
711
693
|
/**
|
|
712
694
|
* Perform a rotation gesture centered on the specified element.
|
|
713
695
|
*
|
|
@@ -716,18 +698,16 @@ declare namespace CodeceptJS {
|
|
|
716
698
|
* ```
|
|
717
699
|
*
|
|
718
700
|
* See corresponding [webdriverio reference](http://webdriver.io/api/mobile/rotate.html).
|
|
719
|
-
*
|
|
720
|
-
* Appium: support only iOS
|
|
701
|
+
* @returns Appium: support only iOS
|
|
721
702
|
*/
|
|
722
|
-
rotate(): void
|
|
703
|
+
rotate(): Promise<void>;
|
|
723
704
|
/**
|
|
724
705
|
* Set immediate value in app.
|
|
725
706
|
*
|
|
726
707
|
* See corresponding [webdriverio reference](http://webdriver.io/api/mobile/setImmediateValue.html).
|
|
727
|
-
*
|
|
728
|
-
* Appium: support only iOS
|
|
708
|
+
* @returns Appium: support only iOS
|
|
729
709
|
*/
|
|
730
|
-
setImmediateValue(): void
|
|
710
|
+
setImmediateValue(): Promise<void>;
|
|
731
711
|
/**
|
|
732
712
|
* Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
|
|
733
713
|
*
|
|
@@ -736,21 +716,19 @@ declare namespace CodeceptJS {
|
|
|
736
716
|
* I.touchId(true); // simulates valid fingerprint
|
|
737
717
|
* I.touchId(false); // simulates invalid fingerprint
|
|
738
718
|
* ```
|
|
739
|
-
*
|
|
740
|
-
* Appium: support only iOS
|
|
719
|
+
* @returns Appium: support only iOS
|
|
741
720
|
* TODO: not tested
|
|
742
721
|
*/
|
|
743
|
-
simulateTouchId(): void
|
|
722
|
+
simulateTouchId(): Promise<void>;
|
|
744
723
|
/**
|
|
745
724
|
* Close the given application.
|
|
746
725
|
*
|
|
747
726
|
* ```js
|
|
748
727
|
* I.closeApp();
|
|
749
728
|
* ```
|
|
750
|
-
*
|
|
751
|
-
* Appium: support only iOS
|
|
729
|
+
* @returns Appium: support only iOS
|
|
752
730
|
*/
|
|
753
|
-
closeApp(): void
|
|
731
|
+
closeApp(): Promise<void>;
|
|
754
732
|
/**
|
|
755
733
|
* Appends text to a input field or textarea.
|
|
756
734
|
* Field is located by name, label, CSS or XPath
|
|
@@ -959,7 +937,7 @@ declare namespace CodeceptJS {
|
|
|
959
937
|
* ```
|
|
960
938
|
* @param fileName - file name to save.
|
|
961
939
|
*/
|
|
962
|
-
saveScreenshot(fileName: string): void
|
|
940
|
+
saveScreenshot(fileName: string): Promise<void>;
|
|
963
941
|
/**
|
|
964
942
|
* Scroll element into viewport.
|
|
965
943
|
*
|
|
@@ -1106,7 +1084,17 @@ declare namespace CodeceptJS {
|
|
|
1106
1084
|
* I.amInPath('test');
|
|
1107
1085
|
* I.seeFile('codecept.json');
|
|
1108
1086
|
* I.seeInThisFile('FileSystem');
|
|
1109
|
-
* I.dontSeeInThisFile("
|
|
1087
|
+
* I.dontSeeInThisFile("WebDriver");
|
|
1088
|
+
* ```
|
|
1089
|
+
*
|
|
1090
|
+
* ## Configuration
|
|
1091
|
+
*
|
|
1092
|
+
* Enable helper in config file:
|
|
1093
|
+
*
|
|
1094
|
+
* ```js
|
|
1095
|
+
* helpers: {
|
|
1096
|
+
* FileSystem: {},
|
|
1097
|
+
* }
|
|
1110
1098
|
* ```
|
|
1111
1099
|
*
|
|
1112
1100
|
* ## Methods
|
|
@@ -1451,6 +1439,179 @@ declare namespace CodeceptJS {
|
|
|
1451
1439
|
*/
|
|
1452
1440
|
_requestDelete(operation: string, data: any): void;
|
|
1453
1441
|
}
|
|
1442
|
+
/**
|
|
1443
|
+
* This helper allows performing assertions on JSON responses paired with following helpers:
|
|
1444
|
+
*
|
|
1445
|
+
* * REST
|
|
1446
|
+
* * GraphQL
|
|
1447
|
+
* * Playwright
|
|
1448
|
+
*
|
|
1449
|
+
* It can check status codes, response data, response structure.
|
|
1450
|
+
*
|
|
1451
|
+
*
|
|
1452
|
+
* ## Configuration
|
|
1453
|
+
*
|
|
1454
|
+
* * `requestHelper` - a helper which will perform requests. `REST` by default, also `Playwright` or `GraphQL` can be used. Custom helpers must have `onResponse` hook in their config, which will be executed when request is performed.
|
|
1455
|
+
*
|
|
1456
|
+
* ### Examples
|
|
1457
|
+
*
|
|
1458
|
+
* Zero-configuration when paired with REST:
|
|
1459
|
+
*
|
|
1460
|
+
* ```js
|
|
1461
|
+
* // inside codecept.conf.js
|
|
1462
|
+
* {
|
|
1463
|
+
* helpers: {
|
|
1464
|
+
* REST: {
|
|
1465
|
+
* endpoint: 'http://site.com/api',
|
|
1466
|
+
* },
|
|
1467
|
+
* JSONResponse: {}
|
|
1468
|
+
* }
|
|
1469
|
+
* }
|
|
1470
|
+
* ```
|
|
1471
|
+
* Explicitly setting request helper if you use `makeApiRequest` of Playwright to perform requests and not paired REST:
|
|
1472
|
+
*
|
|
1473
|
+
* ```js
|
|
1474
|
+
* // inside codecept.conf.js
|
|
1475
|
+
* // ...
|
|
1476
|
+
* helpers: {
|
|
1477
|
+
* Playwright: {
|
|
1478
|
+
* url: 'https://localhost',
|
|
1479
|
+
* browser: 'chromium',
|
|
1480
|
+
* },
|
|
1481
|
+
* JSONResponse: {
|
|
1482
|
+
* requestHelper: 'Playwright',
|
|
1483
|
+
* }
|
|
1484
|
+
* }
|
|
1485
|
+
* ```
|
|
1486
|
+
* ## Access From Helpers
|
|
1487
|
+
*
|
|
1488
|
+
* If you plan to add custom assertions it is recommended to create a helper that will retrieve response object from JSONResponse:
|
|
1489
|
+
*
|
|
1490
|
+
*
|
|
1491
|
+
* ```js
|
|
1492
|
+
* // inside custom helper
|
|
1493
|
+
* const response = this.helpers.JSONResponse.response;
|
|
1494
|
+
* ```
|
|
1495
|
+
*
|
|
1496
|
+
* ## Methods
|
|
1497
|
+
*/
|
|
1498
|
+
class JSONResponse {
|
|
1499
|
+
/**
|
|
1500
|
+
* Checks that response code is equal to the provided one
|
|
1501
|
+
*
|
|
1502
|
+
* ```js
|
|
1503
|
+
* I.seeResponseCodeIs(200);
|
|
1504
|
+
* ```
|
|
1505
|
+
*/
|
|
1506
|
+
seeResponseCodeIs(code: number): void;
|
|
1507
|
+
/**
|
|
1508
|
+
* Checks that response code is not equal to the provided one
|
|
1509
|
+
*
|
|
1510
|
+
* ```js
|
|
1511
|
+
* I.dontSeeResponseCodeIs(500);
|
|
1512
|
+
* ```
|
|
1513
|
+
*/
|
|
1514
|
+
dontSeeResponseCodeIs(code: number): void;
|
|
1515
|
+
/**
|
|
1516
|
+
* Checks that the response code is 4xx
|
|
1517
|
+
*/
|
|
1518
|
+
seeResponseCodeIsClientError(): void;
|
|
1519
|
+
/**
|
|
1520
|
+
* Checks that the response code is 3xx
|
|
1521
|
+
*/
|
|
1522
|
+
seeResponseCodeIsRedirection(): void;
|
|
1523
|
+
/**
|
|
1524
|
+
* Checks that the response code is 5xx
|
|
1525
|
+
*/
|
|
1526
|
+
seeResponseCodeIsServerError(): void;
|
|
1527
|
+
/**
|
|
1528
|
+
* Checks that the response code is 2xx
|
|
1529
|
+
* Use it instead of seeResponseCodeIs(200) if server can return 204 instead.
|
|
1530
|
+
*
|
|
1531
|
+
* ```js
|
|
1532
|
+
* I.seeResponseCodeIsSuccessful();
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
seeResponseCodeIsSuccessful(): void;
|
|
1536
|
+
/**
|
|
1537
|
+
* Checks for deep inclusion of a provided json in a response data.
|
|
1538
|
+
*
|
|
1539
|
+
* ```js
|
|
1540
|
+
* // response.data == { user: { name: 'jon', email: 'jon@doe.com' } }
|
|
1541
|
+
*
|
|
1542
|
+
* I.seeResponseContainsJson({ user: { email: 'jon@doe.com' } });
|
|
1543
|
+
* ```
|
|
1544
|
+
*/
|
|
1545
|
+
seeResponseContainsJson(json: any): void;
|
|
1546
|
+
/**
|
|
1547
|
+
* Checks for deep inclusion of a provided json in a response data.
|
|
1548
|
+
*
|
|
1549
|
+
* ```js
|
|
1550
|
+
* // response.data == { data: { user: 1 } }
|
|
1551
|
+
*
|
|
1552
|
+
* I.dontSeeResponseContainsJson({ user: 2 });
|
|
1553
|
+
* ```
|
|
1554
|
+
*/
|
|
1555
|
+
dontSeeResponseContainsJson(json: any): void;
|
|
1556
|
+
/**
|
|
1557
|
+
* Checks for deep inclusion of a provided json in a response data.
|
|
1558
|
+
*
|
|
1559
|
+
* ```js
|
|
1560
|
+
* // response.data == { user: { name: 'jon', email: 'jon@doe.com' } }
|
|
1561
|
+
*
|
|
1562
|
+
* I.seeResponseContainsKeys(['user']);
|
|
1563
|
+
* ```
|
|
1564
|
+
*/
|
|
1565
|
+
seeResponseContainsKeys(keys: any[]): void;
|
|
1566
|
+
/**
|
|
1567
|
+
* Executes a callback function passing in `response` object and chai assertions with `expect`
|
|
1568
|
+
* Use it to perform custom checks of response data
|
|
1569
|
+
*
|
|
1570
|
+
* ```js
|
|
1571
|
+
* I.seeResponseValidByCallback({ data, status, expect } => {
|
|
1572
|
+
* expect(status).to.eql(200);
|
|
1573
|
+
* expect(data).keys.to.include(['user', 'company']);
|
|
1574
|
+
* });
|
|
1575
|
+
* ```
|
|
1576
|
+
*/
|
|
1577
|
+
seeResponseValidByCallback(fn: (...params: any[]) => any): void;
|
|
1578
|
+
/**
|
|
1579
|
+
* Checks that response data equals to expected:
|
|
1580
|
+
*
|
|
1581
|
+
* ```js
|
|
1582
|
+
* // response.data is { error: 'Not allowed' }
|
|
1583
|
+
*
|
|
1584
|
+
* I.seeResponseEquals({ error: 'Not allowed' })
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
seeResponseEquals(resp: any): void;
|
|
1588
|
+
/**
|
|
1589
|
+
* Validates JSON structure of response using [joi library](https://joi.dev).
|
|
1590
|
+
* See [joi API](https://joi.dev/api/) for complete reference on usage.
|
|
1591
|
+
*
|
|
1592
|
+
* Use pre-initialized joi instance by passing function callback:
|
|
1593
|
+
*
|
|
1594
|
+
* ```js
|
|
1595
|
+
* // response.data is { name: 'jon', id: 1 }
|
|
1596
|
+
*
|
|
1597
|
+
* I.seeResponseMatchesJsonSchema(joi => {
|
|
1598
|
+
* return joi.object({
|
|
1599
|
+
* name: joi.string();
|
|
1600
|
+
* id: joi.number();
|
|
1601
|
+
* })
|
|
1602
|
+
* });
|
|
1603
|
+
*
|
|
1604
|
+
* // or pass a valid schema
|
|
1605
|
+
* const joi = require('joi);
|
|
1606
|
+
*
|
|
1607
|
+
* I.seeResponseMatchesJsonSchema(joi.object({
|
|
1608
|
+
* name: joi.string();
|
|
1609
|
+
* id: joi.number();
|
|
1610
|
+
* });
|
|
1611
|
+
* ```
|
|
1612
|
+
*/
|
|
1613
|
+
seeResponseMatchesJsonSchema(fnOrSchema: any): void;
|
|
1614
|
+
}
|
|
1454
1615
|
/**
|
|
1455
1616
|
* Nightmare helper wraps [Nightmare](https://github.com/segmentio/nightmare) library to provide
|
|
1456
1617
|
* fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
|
|
@@ -2403,12 +2564,18 @@ declare namespace CodeceptJS {
|
|
|
2403
2564
|
*
|
|
2404
2565
|
* This helper works with a browser out of the box with no additional tools required to install.
|
|
2405
2566
|
*
|
|
2406
|
-
* Requires `playwright` package version ^1 to be installed:
|
|
2567
|
+
* Requires `playwright` or `playwright-core` package version ^1 to be installed:
|
|
2407
2568
|
*
|
|
2408
2569
|
* ```
|
|
2409
|
-
* npm i playwright@^1 --save
|
|
2570
|
+
* npm i playwright@^1.18 --save
|
|
2571
|
+
* ```
|
|
2572
|
+
* or
|
|
2573
|
+
* ```
|
|
2574
|
+
* npm i playwright-core@^1.18 --save
|
|
2410
2575
|
* ```
|
|
2411
2576
|
*
|
|
2577
|
+
* Using playwright-core package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
|
|
2578
|
+
*
|
|
2412
2579
|
* ## Configuration
|
|
2413
2580
|
*
|
|
2414
2581
|
* This helper should be configured in codecept.json or codecept.conf.js
|
|
@@ -2426,7 +2593,7 @@ declare namespace CodeceptJS {
|
|
|
2426
2593
|
* * `keepBrowserState`: (optional, default: false) - keep browser state between tests when `restart` is set to false.
|
|
2427
2594
|
* * `keepCookies`: (optional, default: false) - keep cookies between tests when `restart` is set to false.
|
|
2428
2595
|
* * `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
2429
|
-
* * `waitForNavigation`: (optional, default: 'load'). When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API](https://github.com/microsoft/playwright/blob/
|
|
2596
|
+
* * `waitForNavigation`: (optional, default: 'load'). When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API](https://github.com/microsoft/playwright/blob/main/docs/api.md#pagewaitfornavigationoptions).
|
|
2430
2597
|
* * `pressKeyDelay`: (optional, default: '10'). Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
|
|
2431
2598
|
* * `getPageTimeout` (optional, default: '0') config option to set maximum navigation time in milliseconds.
|
|
2432
2599
|
* * `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
|
|
@@ -2437,6 +2604,7 @@ declare namespace CodeceptJS {
|
|
|
2437
2604
|
* * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
2438
2605
|
* * `chromium`: (optional) pass additional chromium options
|
|
2439
2606
|
* * `electron`: (optional) pass additional electron options
|
|
2607
|
+
* * `channel`: (optional) While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge).
|
|
2440
2608
|
*
|
|
2441
2609
|
* #### Video Recording Customization
|
|
2442
2610
|
*
|
|
@@ -2591,15 +2759,15 @@ declare namespace CodeceptJS {
|
|
|
2591
2759
|
* First argument is a description of an action.
|
|
2592
2760
|
* Second argument is async function that gets this helper as parameter.
|
|
2593
2761
|
*
|
|
2594
|
-
* { [`page`](https://github.com/microsoft/playwright/blob/
|
|
2762
|
+
* { [`page`](https://github.com/microsoft/playwright/blob/main/docs/src/api/class-page.md), [`browserContext`](https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browsercontext.md) [`browser`](https://github.com/microsoft/playwright/blob/main/docs/src/api/class-browser.md) } objects from Playwright API are available.
|
|
2595
2763
|
*
|
|
2596
2764
|
* ```js
|
|
2597
|
-
* I.usePlaywrightTo('emulate offline mode', async ({
|
|
2598
|
-
* await
|
|
2765
|
+
* I.usePlaywrightTo('emulate offline mode', async ({ browserContext }) => {
|
|
2766
|
+
* await browserContext.setOffline(true);
|
|
2599
2767
|
* });
|
|
2600
2768
|
* ```
|
|
2601
2769
|
* @param description - used to show in logs.
|
|
2602
|
-
* @param fn - async
|
|
2770
|
+
* @param fn - async function that executed with Playwright helper as argument
|
|
2603
2771
|
*/
|
|
2604
2772
|
usePlaywrightTo(description: string, fn: (...params: any[]) => any): void;
|
|
2605
2773
|
/**
|
|
@@ -2889,7 +3057,7 @@ declare namespace CodeceptJS {
|
|
|
2889
3057
|
* I.openNewTab();
|
|
2890
3058
|
* ```
|
|
2891
3059
|
*
|
|
2892
|
-
* You can pass in [page options](https://github.com/microsoft/playwright/blob/
|
|
3060
|
+
* You can pass in [page options](https://github.com/microsoft/playwright/blob/main/docs/api.md#browsernewpageoptions) to emulate device on this page
|
|
2893
3061
|
*
|
|
2894
3062
|
* ```js
|
|
2895
3063
|
* // enable mobile
|
|
@@ -3730,6 +3898,23 @@ declare namespace CodeceptJS {
|
|
|
3730
3898
|
* @param [fullPage = false] - (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
3731
3899
|
*/
|
|
3732
3900
|
saveScreenshot(fileName: string, fullPage?: boolean): void;
|
|
3901
|
+
/**
|
|
3902
|
+
* Performs [api request](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get) using
|
|
3903
|
+
* the cookies from the current browser session.
|
|
3904
|
+
*
|
|
3905
|
+
* ```js
|
|
3906
|
+
* const users = await I.makeApiRequest('GET', '/api/users', { params: { page: 1 }});
|
|
3907
|
+
* users[0]
|
|
3908
|
+
* I.makeApiRequest('PATCH', )
|
|
3909
|
+
* ```
|
|
3910
|
+
*
|
|
3911
|
+
* > This is Playwright's built-in alternative to using REST helper's sendGet, sendPost, etc methods.
|
|
3912
|
+
* @param method - HTTP method
|
|
3913
|
+
* @param url - endpoint
|
|
3914
|
+
* @param options - request options depending on method used
|
|
3915
|
+
* @returns response
|
|
3916
|
+
*/
|
|
3917
|
+
makeApiRequest(method: string, url: string, options: any): Promise<object>;
|
|
3733
3918
|
/**
|
|
3734
3919
|
* Pauses execution for a number of seconds.
|
|
3735
3920
|
*
|
|
@@ -5291,7 +5476,15 @@ declare namespace CodeceptJS {
|
|
|
5291
5476
|
* Browser control is executed via DevTools Protocol (instead of Selenium).
|
|
5292
5477
|
* This helper works with a browser out of the box with no additional tools required to install.
|
|
5293
5478
|
*
|
|
5294
|
-
* Requires `puppeteer` package to be installed.
|
|
5479
|
+
* Requires `puppeteer` or `puppeteer-core` package to be installed.
|
|
5480
|
+
* ```
|
|
5481
|
+
* npm i puppeteer --save
|
|
5482
|
+
* ```
|
|
5483
|
+
* or
|
|
5484
|
+
* ```
|
|
5485
|
+
* npm i puppeteer-core --save
|
|
5486
|
+
* ```
|
|
5487
|
+
* Using `puppeteer-core` package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
|
|
5295
5488
|
*
|
|
5296
5489
|
* > Experimental Firefox support [can be activated](https://codecept.io/helpers/Puppeteer-firefox).
|
|
5297
5490
|
*
|
|
@@ -6936,6 +7129,21 @@ declare namespace CodeceptJS {
|
|
|
6936
7129
|
* ## Methods
|
|
6937
7130
|
*/
|
|
6938
7131
|
class REST {
|
|
7132
|
+
/**
|
|
7133
|
+
* Sets request headers for all requests of this test
|
|
7134
|
+
* @param headers - headers list
|
|
7135
|
+
*/
|
|
7136
|
+
haveRequestHeaders(headers: any): void;
|
|
7137
|
+
/**
|
|
7138
|
+
* Adds a header for Bearer authentication
|
|
7139
|
+
*
|
|
7140
|
+
* ```js
|
|
7141
|
+
* // we use secret function to hide token from logs
|
|
7142
|
+
* I.amBearerAuthenticated(secret('heregoestoken'))
|
|
7143
|
+
* ```
|
|
7144
|
+
* @param accessToken - Bearer access token
|
|
7145
|
+
*/
|
|
7146
|
+
amBearerAuthenticated(accessToken: string): void;
|
|
6939
7147
|
/**
|
|
6940
7148
|
* Executes axios request
|
|
6941
7149
|
* @returns response
|
|
@@ -9836,6 +10044,7 @@ declare namespace CodeceptJS {
|
|
|
9836
10044
|
* If js file provided: require it and get .config key
|
|
9837
10045
|
* If json file provided: load and parse JSON
|
|
9838
10046
|
* If directory provided:
|
|
10047
|
+
* * try to load `codecept.config.js` from it
|
|
9839
10048
|
* * try to load `codecept.conf.js` from it
|
|
9840
10049
|
* * try to load `codecept.json` from it
|
|
9841
10050
|
* If none of above: fail.
|