From 149351646bca79075a8fdee69f8756836af47912 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Wed, 26 Jun 2019 17:30:45 +0300 Subject: [PATCH] feat: resolve symlinked storages --- lib/appium-driver.ts | 3 +-- lib/enums/log-image-type.d.ts | 4 ++-- lib/utils.ts | 11 ++++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/appium-driver.ts b/lib/appium-driver.ts index d55507c..5440ba6 100644 --- a/lib/appium-driver.ts +++ b/lib/appium-driver.ts @@ -239,7 +239,7 @@ export class AppiumDriver { prepareApp(args); if (!args.device) { if (args.isAndroid) { - args.device = DeviceManager.getDefaultDevice(args, sessionInfo.capabilities.avd, sessionInfo.capabilities.deviceUDID.replace("emulator-", ""), sessionInfo.capabilities.deviceUDID.includes("emulator") ? DeviceType.EMULATOR : DeviceType.SIMULATOR, sessionInfo.capabilities.desired.platformVersion || sessionInfo.capabilities.platformVersion); + args.device = DeviceManager.getDefaultDevice(args, sessionInfo.capabilities.deviceName, sessionInfo.capabilities.deviceUDID.replace("emulator-", ""), sessionInfo.capabilities.deviceUDID.includes("emulator") ? DeviceType.EMULATOR : DeviceType.SIMULATOR, sessionInfo.capabilities.desired.platformVersion || sessionInfo.capabilities.platformVersion); } else { args.device = DeviceManager.getDefaultDevice(args); } @@ -605,7 +605,6 @@ export class AppiumDriver { console.log("Remove the 'actual' suffix to continue using the image as expected one ", pathExpectedImage); this._args.testReporterLog(basename(pathActualImage).replace(/\.\w{3,3}$/ig, "")); this._args.testReporterLog(join(this._logPath, basename(pathActualImage))); - return false; } diff --git a/lib/enums/log-image-type.d.ts b/lib/enums/log-image-type.d.ts index c022605..04966e8 100644 --- a/lib/enums/log-image-type.d.ts +++ b/lib/enums/log-image-type.d.ts @@ -1,12 +1,12 @@ export declare enum LogImageType { /** - * Setting this property to add each image + * Set this property to add each image * during the image comparison into the report. * If not set, it will be logged only the last image comparison. */ everyImage = "everyImage", /** - * Setting this property to take screenshot on each hook + * Set this property to take screenshot on each hook * and add the images into the report. */ screenshots = "screenshots" diff --git a/lib/utils.ts b/lib/utils.ts index c8defec..471ed5a 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -13,7 +13,10 @@ import { mkdirSync, readdirSync, writeFileSync, - readFileSync + readFileSync, + readlinkSync, + lstatSync, + realpathSync } from "fs"; import { extname, @@ -440,6 +443,12 @@ export async function scroll(wd, driver, direction: Direction, isIOS: boolean, y function createStorageFolder(storage, directory) { storage = resolvePath(storage, directory); + try { + storage = readlinkSync(storage); + } catch (error) { } + try { + storage = realpathSync(storage); + } catch (error) { } if (!existsSync(storage)) { mkdirSync(storage); }