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..3d88ad7 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; @@ -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);