From 9485d328b4e15aa103cf30f7a3da5a3b09a85535 Mon Sep 17 00:00:00 2001 From: Zdravko Branzov Date: Mon, 30 Sep 2019 14:11:21 +0300 Subject: [PATCH 1/2] fix: respect appium capabilities provided by the user in the json file --- lib/device-manager.ts | 4 +--- lib/image-helper.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/device-manager.ts b/lib/device-manager.ts index 604e67a..dc51caa 100644 --- a/lib/device-manager.ts +++ b/lib/device-manager.ts @@ -174,9 +174,7 @@ export class DeviceManager implements IDeviceManager { apiLevel: platformVersion || args.appiumCaps.platformVersion, config: { "density": args.appiumCaps.density, "offsetPixels": args.appiumCaps.offsetPixels } } - - delete args.appiumCaps.density; - delete args.appiumCaps.offsetPixels; + DeviceManager.cleanUnsetProperties(device); return device; diff --git a/lib/image-helper.ts b/lib/image-helper.ts index f546f43..b0023be 100644 --- a/lib/image-helper.ts +++ b/lib/image-helper.ts @@ -102,9 +102,9 @@ export class ImageHelper { ImageHelper.fullClone(this._args.device.viewportRect, this._defaultOptions.cropRectangle) } if (!this._defaultOptions.cropRectangle - || !isNumber(this._defaultOptions.cropRectangle.y)) { + || !isNumber(this._defaultOptions.cropRectangle.y) || this._args.appiumCaps.offsetPixels > 0) { this._defaultOptions.cropRectangle = this._defaultOptions.cropRectangle || {}; - this._defaultOptions.cropRectangle.y = this._args.device.config.offsetPixels || 0; + this._defaultOptions.cropRectangle.y = this._args.appiumCaps.offsetPixels || this._args.device.config.offsetPixels || 0; this._defaultOptions.cropRectangle.x = 0; if (this._args.device.deviceScreenSize && this._args.device.deviceScreenSize.width && this._args.device.deviceScreenSize.height) { this._defaultOptions.cropRectangle.height = this._args.device.deviceScreenSize.height - this._defaultOptions.cropRectangle.y; From 0147399a06b29ca0abd934aaa34d9f75c405e3db Mon Sep 17 00:00:00 2001 From: Zdravko Branzov Date: Mon, 30 Sep 2019 17:39:41 +0300 Subject: [PATCH 2/2] fix: saving every image when LogImageType.everyImage is provided --- lib/image-helper.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/image-helper.ts b/lib/image-helper.ts index b0023be..3d88ad7 100644 --- a/lib/image-helper.ts +++ b/lib/image-helper.ts @@ -270,8 +270,12 @@ export class ImageHelper { const eventStartTime = Date.now().valueOf(); let counter = 1; options.timeOutSeconds *= 1000; + let pathActualImageCounter = resolvePath(this._args.reportsPath, imageName.replace(".", "_actual.")); + const shouldLogEveryImage = checkImageLogType(this._args.testReporter, LogImageType.everyImage); while ((Date.now().valueOf() - eventStartTime) <= options.timeOutSeconds && !result) { - const pathActualImageCounter = resolvePath(this._args.reportsPath, imageName.replace(".", "_actual_" + counter + ".")); + if (shouldLogEveryImage) { + pathActualImageCounter = resolvePath(this._args.reportsPath, imageName.replace(".", "_actual_" + counter + ".")); + } pathActualImage = await this._driver.saveScreenshot(pathActualImageCounter); if (!options.keepOriginalImageSize) { await this.clipRectangleImage(options.cropRectangle, pathActualImage);