diff --git a/lib/appium-driver.ts b/lib/appium-driver.ts index 5330b84..4c4ecdc 100644 --- a/lib/appium-driver.ts +++ b/lib/appium-driver.ts @@ -590,6 +590,9 @@ export class AppiumDriver { // First time capture if (!existsSync(pathExpectedImage)) { const pathActualImage = resolvePath(this._storageByDeviceName, imageName.replace(".", "_actual.")); + if (this.imageHelper.waitOnCreatingInitialSnapshot > 0) { + await this.driver.wait(this.imageHelper.waitOnCreatingInitialSnapshot); + } await this.takeScreenshot(pathActualImage); if (rect) { diff --git a/lib/image-helper.d.ts b/lib/image-helper.d.ts index 5b2d5df..1495a81 100644 --- a/lib/image-helper.d.ts +++ b/lib/image-helper.d.ts @@ -5,7 +5,9 @@ export declare class ImageHelper { private _args; private _imageCropRect; private _blockOutAreas; + private _waitOnCreatingInitialSnapshot; constructor(_args: INsCapabilities); + waitOnCreatingInitialSnapshot: number; imageCropRect: IRectangle; blockOutAreas: IRectangle[]; imageOutputLimit(): ImageOptions; diff --git a/lib/image-helper.ts b/lib/image-helper.ts index e9145df..27d63aa 100644 --- a/lib/image-helper.ts +++ b/lib/image-helper.ts @@ -10,10 +10,19 @@ export class ImageHelper { private _imageCropRect: IRectangle; private _blockOutAreas: IRectangle[]; + private _waitOnCreatingInitialSnapshot: number; constructor(private _args: INsCapabilities) { } + get waitOnCreatingInitialSnapshot() { + return this._waitOnCreatingInitialSnapshot; + } + + set waitOnCreatingInitialSnapshot(waitOnCreatingInitialSnapshot: number) { + this._waitOnCreatingInitialSnapshot = waitOnCreatingInitialSnapshot; + } + get imageCropRect(): IRectangle { return this._imageCropRect; } @@ -103,9 +112,11 @@ export class ImageHelper { if (typeThreshold == ImageOptions.percent) { valueThreshold = Math.floor(valueThreshold * 100); + console.log(`Using ${valueThreshold}\ ${typeThreshold} tolerance`); + } else { + console.log(`Using ${valueThreshold} tolerance`); } - console.log(`Using ${valueThreshold}\ ${typeThreshold} tolerance`); const result = this.runDiff(diff, output); this._blockOutAreas = undefined; return result;