@@ -12,7 +12,8 @@ import { Direction } from "./direction";
1212import { Locator } from "./locators" ;
1313import {
1414 log ,
15- getStorage ,
15+ getStorageByPlatform ,
16+ getStorageByDeviceName ,
1617 resolve ,
1718 fileExists ,
1819 getAppPath ,
@@ -37,7 +38,8 @@ export class AppiumDriver {
3738 private _isAlive : boolean = false ;
3839 private _locators : Locator ;
3940 private _logPath : string ;
40- private _storage : string ;
41+ private _storageByDeviceName : string ;
42+ private _storageByPlatform : string ;
4143
4244 private constructor ( private _driver : any , private _wd , private _webio : any , private _driverConfig , private _args : INsCapabilities ) {
4345 this . _elementHelper = new ElementHelper ( this . _args ) ;
@@ -271,19 +273,31 @@ export class AppiumDriver {
271273 imageName = imageName . concat ( AppiumDriver . pngFileExt ) ;
272274 }
273275
274- if ( ! this . _storage ) {
275- this . _storage = getStorage ( this . _args ) ;
276+ if ( ! this . _storageByDeviceName ) {
277+ this . _storageByDeviceName = getStorageByDeviceName ( this . _args ) ;
276278 }
277279
280+ let expectedImage = resolve ( this . _storageByDeviceName , imageName ) ;
281+ if ( ! fileExists ( expectedImage ) ) {
282+ if ( ! this . _storageByPlatform ) {
283+ this . _storageByPlatform = getStorageByPlatform ( this . _args ) ;
284+ }
285+ expectedImage = resolve ( this . _storageByPlatform , imageName ) ;
286+ }
287+
288+ if ( ! fileExists ( expectedImage ) ) {
289+ expectedImage = resolve ( this . _storageByDeviceName , imageName ) ;
290+ }
291+
278292 if ( ! this . _logPath ) {
279293 this . _logPath = getReportPath ( this . _args ) ;
280294 }
281295
282- let expectedImage = resolve ( this . _storage , imageName ) ;
296+ expectedImage = resolve ( this . _storageByDeviceName , imageName ) ;
283297
284298 // Firts capture of screen when the expected image is not available
285299 if ( ! fileExists ( expectedImage ) ) {
286- await this . takeScreenshot ( resolve ( this . _storage , imageName . replace ( "." , "_actual." ) ) ) ;
300+ await this . takeScreenshot ( resolve ( this . _storageByDeviceName , imageName . replace ( "." , "_actual." ) ) ) ;
287301 console . log ( "Remove the 'actual' suffix to continue using the image as expected one " , expectedImage ) ;
288302 let eventStartTime = Date . now ( ) . valueOf ( ) ;
289303 let counter = 1 ;
0 commit comments