@@ -126,7 +126,14 @@ class ResembleHelper extends Helper {
126
126
const el = els [ 0 ] ;
127
127
128
128
await el . saveScreenshot ( this . screenshotFolder + name + '.png' ) ;
129
- } else throw new Error ( "Method only works with Puppeteer and WebDriver helpers." ) ;
129
+ } else if ( this . helpers [ 'TestCafe' ] ) {
130
+ await helper . waitForVisible ( selector ) ;
131
+ const els = await helper . _locate ( selector ) ;
132
+ if ( ! await els . count ) throw new Error ( `Element ${ selector } couldn't be located` ) ;
133
+ const { t } = this . helpers [ 'TestCafe' ] ;
134
+
135
+ await t . takeElementScreenshot ( els , name ) ;
136
+ } else throw new Error ( "Method only works with Puppeteer, WebDriver or TestCafe helpers." ) ;
130
137
}
131
138
132
139
/**
@@ -302,25 +309,18 @@ class ResembleHelper extends Helper {
302
309
}
303
310
304
311
const awsC = this . config . aws ;
305
-
306
312
if ( awsC !== undefined && options . prepareBaseImage === false ) {
307
313
await this . _download ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage ) ;
308
314
}
309
-
310
315
if ( options . prepareBaseImage !== undefined && options . prepareBaseImage ) {
311
316
await this . _prepareBaseImage ( baseImage ) ;
312
317
}
313
-
314
318
if ( selector ) {
315
319
options . boundingBox = await this . _getBoundingBox ( selector ) ;
316
320
}
317
-
318
321
const misMatch = await this . _fetchMisMatchPercentage ( baseImage , options ) ;
319
-
320
322
this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
321
-
322
323
this . _addMochaContext ( baseImage , misMatch , options . tolerance ) ;
323
-
324
324
if ( awsC !== undefined ) {
325
325
await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , options . prepareBaseImage )
326
326
}
@@ -377,17 +377,24 @@ class ResembleHelper extends Helper {
377
377
const helper = this . _getHelper ( ) ;
378
378
await helper . waitForVisible ( selector ) ;
379
379
const els = await helper . _locate ( selector ) ;
380
- if ( ! els . length ) throw new Error ( `Element ${ selector } couldn't be located` ) ;
381
- const el = els [ 0 ] ;
380
+
381
+ if ( this . helpers [ 'TestCafe' ] ) {
382
+ if ( await els . count != 1 ) throw new Error ( `Element ${ selector } couldn't be located or isn't unique on the page` ) ;
383
+ }
384
+ else {
385
+ if ( ! els . length ) throw new Error ( `Element ${ selector } couldn't be located` ) ;
386
+ }
382
387
383
388
let location , size ;
384
389
385
390
if ( this . helpers [ 'Puppeteer' ] ) {
391
+ const el = els [ 0 ] ;
386
392
const box = await el . boundingBox ( ) ;
387
393
size = location = box ;
388
394
}
389
395
390
396
if ( this . helpers [ 'WebDriver' ] || this . helpers [ 'Appium' ] ) {
397
+ const el = els [ 0 ] ;
391
398
location = await el . getLocation ( ) ;
392
399
size = await el . getSize ( ) ;
393
400
}
@@ -396,6 +403,9 @@ class ResembleHelper extends Helper {
396
403
location = await helper . browser . getLocation ( selector ) ;
397
404
size = await helper . browser . getElementSize ( selector ) ;
398
405
}
406
+ if ( this . helpers [ 'TestCafe' ] ) {
407
+ return await els . boundingClientRect ;
408
+ }
399
409
400
410
if ( ! size ) {
401
411
throw new Error ( "Cannot get element size!" ) ;
@@ -429,8 +439,11 @@ class ResembleHelper extends Helper {
429
439
if ( this . helpers [ 'WebDriverIO' ] ) {
430
440
return this . helpers [ 'WebDriverIO' ] ;
431
441
}
442
+ if ( this . helpers [ 'TestCafe' ] ) {
443
+ return this . helpers [ 'TestCafe' ] ;
444
+ }
432
445
433
- throw new Error ( 'No matching helper found. Supported helpers: WebDriver/Appium/Puppeteer' ) ;
446
+ throw new Error ( 'No matching helper found. Supported helpers: WebDriver/Appium/Puppeteer/TestCafe ' ) ;
434
447
}
435
448
}
436
449
0 commit comments