webdriver-image-comparison
Advanced tools
Comparing version 0.15.0 to 0.16.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getElementPositionTopScreenNativeMobile = void 0; | ||
function getElementPositionTopScreenNativeMobile(statusBarAddressBarHeight, element) { | ||
@@ -4,0 +5,0 @@ var _a = window.screen, width = _a.width, height = _a.height; |
@@ -69,3 +69,2 @@ "use strict"; | ||
executeCompareOptions = { | ||
debug: checkElementOptions.wic.debug, | ||
devicePixelRatio: devicePixelRatio, | ||
@@ -89,2 +88,3 @@ compareOptions: { | ||
isHybridApp: checkElementOptions.wic.isHybridApp, | ||
logLevel: checkElementOptions.wic.logLevel, | ||
platformName: instanceData.platformName, | ||
@@ -91,0 +91,0 @@ }; |
@@ -73,3 +73,2 @@ "use strict"; | ||
executeCompareOptions = { | ||
debug: checkFullPageOptions.wic.debug, | ||
devicePixelRatio: devicePixelRatio, | ||
@@ -93,2 +92,3 @@ compareOptions: { | ||
isHybridApp: checkFullPageOptions.wic.isHybridApp, | ||
logLevel: checkFullPageOptions.wic.logLevel, | ||
platformName: instanceData.platformName, | ||
@@ -95,0 +95,0 @@ }; |
@@ -69,3 +69,2 @@ "use strict"; | ||
executeCompareOptions = { | ||
debug: checkScreenOptions.wic.debug, | ||
devicePixelRatio: devicePixelRatio, | ||
@@ -87,2 +86,3 @@ compareOptions: { | ||
}, | ||
logLevel: checkScreenOptions.wic.logLevel, | ||
isAndroidNativeWebScreenshot: instanceData.nativeWebScreenshot, | ||
@@ -89,0 +89,0 @@ isHybridApp: checkScreenOptions.wic.isHybridApp, |
@@ -47,7 +47,7 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, addressBarShadowPadding, formatImageName, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, resizeDimensions, hideElements, removeElements, beforeOptions, enrichedInstanceData, screenshot, elementRectangleOptions, rectangles, croppedBase64Image, afterOptions; | ||
var _a, addressBarShadowPadding, formatImageName, logLevel, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, resizeDimensions, hideElements, removeElements, beforeOptions, enrichedInstanceData, base64Image, elementRectangleOptions, rectangles, croppedBase64Image, afterOptions; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = saveElementOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, formatImageName = _a.formatImageName, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
_a = saveElementOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, formatImageName = _a.formatImageName, logLevel = _a.logLevel, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
disableCSSAnimation = 'disableCSSAnimation' in saveElementOptions.method | ||
@@ -67,2 +67,3 @@ ? saveElementOptions.method.disableCSSAnimation | ||
hideElements: hideElements, | ||
logLevel: logLevel, | ||
noScrollBars: hideScrollBars, | ||
@@ -77,3 +78,3 @@ removeElements: removeElements, | ||
case 2: | ||
screenshot = _b.sent(); | ||
base64Image = _b.sent(); | ||
elementRectangleOptions = { | ||
@@ -86,6 +87,11 @@ devicePixelRatio: enrichedInstanceData.dimensions.window.devicePixelRatio, | ||
}; | ||
return [4, rectangles_1.determineElementRectangles(methods.executor, screenshot, elementRectangleOptions, element)]; | ||
return [4, rectangles_1.determineElementRectangles({ | ||
executor: methods.executor, | ||
base64Image: base64Image, | ||
options: elementRectangleOptions, | ||
element: element | ||
})]; | ||
case 3: | ||
rectangles = _b.sent(); | ||
return [4, images_1.makeCroppedBase64Image(screenshot, rectangles, resizeDimensions)]; | ||
return [4, images_1.makeCroppedBase64Image({ base64Image: base64Image, rectangles: rectangles, logLevel: logLevel, resizeDimensions: resizeDimensions })]; | ||
case 4: | ||
@@ -123,2 +129,3 @@ croppedBase64Image = _b.sent(); | ||
}, | ||
logLevel: logLevel, | ||
platformName: instanceData.platformName, | ||
@@ -125,0 +132,0 @@ removeElements: removeElements, |
@@ -45,7 +45,7 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, addressBarShadowPadding, autoSaveBaseline, formatImageName, isHybridApp, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, fullPageScrollTimeout, hideElements, removeElements, hideAfterFirstScroll, beforeOptions, enrichedInstanceData, fullPageScreenshotOptions, screenshotsData, fullPageBase64Image, afterOptions; | ||
var _a, addressBarShadowPadding, autoSaveBaseline, formatImageName, isHybridApp, logLevel, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, fullPageScrollTimeout, hideElements, removeElements, hideAfterFirstScroll, beforeOptions, enrichedInstanceData, fullPageScreenshotOptions, screenshotsData, fullPageBase64Image, afterOptions; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = saveFullPageOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, autoSaveBaseline = _a.autoSaveBaseline, formatImageName = _a.formatImageName, isHybridApp = _a.isHybridApp, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
_a = saveFullPageOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, autoSaveBaseline = _a.autoSaveBaseline, formatImageName = _a.formatImageName, isHybridApp = _a.isHybridApp, logLevel = _a.logLevel, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
disableCSSAnimation = 'disableCSSAnimation' in saveFullPageOptions.method | ||
@@ -68,2 +68,3 @@ ? saveFullPageOptions.method.disableCSSAnimation | ||
hideElements: hideElements, | ||
logLevel: logLevel, | ||
noScrollBars: hideScrollBars, | ||
@@ -87,2 +88,3 @@ removeElements: removeElements, | ||
isIos: enrichedInstanceData.isIos, | ||
logLevel: logLevel, | ||
toolBarShadowPadding: enrichedInstanceData.toolBarShadowPadding, | ||
@@ -127,2 +129,3 @@ }; | ||
}, | ||
logLevel: logLevel, | ||
platformName: instanceData.platformName, | ||
@@ -129,0 +132,0 @@ removeElements: removeElements, |
@@ -46,7 +46,7 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, addressBarShadowPadding, formatImageName, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, hideElements, removeElements, beforeOptions, enrichedInstanceData, screenshot, screenRectangleOptions, rectangles, croppedBase64Image, afterOptions; | ||
var _a, addressBarShadowPadding, formatImageName, logLevel, savePerInstance, toolBarShadowPadding, disableCSSAnimation, hideScrollBars, hideElements, removeElements, beforeOptions, enrichedInstanceData, base64Image, screenRectangleOptions, rectangles, croppedBase64Image, afterOptions; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = saveScreenOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, formatImageName = _a.formatImageName, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
_a = saveScreenOptions.wic, addressBarShadowPadding = _a.addressBarShadowPadding, formatImageName = _a.formatImageName, logLevel = _a.logLevel, savePerInstance = _a.savePerInstance, toolBarShadowPadding = _a.toolBarShadowPadding; | ||
disableCSSAnimation = 'disableCSSAnimation' in saveScreenOptions.method | ||
@@ -65,2 +65,3 @@ ? saveScreenOptions.method.disableCSSAnimation | ||
hideElements: hideElements, | ||
logLevel: logLevel, | ||
noScrollBars: hideScrollBars, | ||
@@ -75,3 +76,3 @@ removeElements: removeElements, | ||
case 2: | ||
screenshot = _b.sent(); | ||
base64Image = _b.sent(); | ||
screenRectangleOptions = { | ||
@@ -85,4 +86,4 @@ devicePixelRatio: enrichedInstanceData.dimensions.window.devicePixelRatio, | ||
}; | ||
rectangles = rectangles_1.determineScreenRectangles(screenshot, screenRectangleOptions); | ||
return [4, images_1.makeCroppedBase64Image(screenshot, rectangles)]; | ||
rectangles = rectangles_1.determineScreenRectangles(base64Image, screenRectangleOptions); | ||
return [4, images_1.makeCroppedBase64Image({ base64Image: base64Image, rectangles: rectangles, logLevel: logLevel })]; | ||
case 3: | ||
@@ -120,2 +121,3 @@ croppedBase64Image = _b.sent(); | ||
}, | ||
logLevel: logLevel, | ||
platformName: instanceData.platformName, | ||
@@ -122,0 +124,0 @@ removeElements: removeElements, |
@@ -0,1 +1,2 @@ | ||
import { LogLevel } from "./options.interface"; | ||
export interface ScreenshotOutput { | ||
@@ -14,2 +15,3 @@ devicePixelRatio: number; | ||
hideElements: (HTMLElement | HTMLElement[])[]; | ||
logLevel: LogLevel; | ||
platformName: string; | ||
@@ -16,0 +18,0 @@ removeElements: (HTMLElement | HTMLElement[])[]; |
@@ -47,9 +47,10 @@ "use strict"; | ||
var chalk_1 = require("chalk"); | ||
var options_interface_1 = require("./options.interface"); | ||
function afterScreenshot(executor, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var actualFolder, base64Image, disableCSSAnimation, fileNameOptions, filePath, hideElements, noScrollBars, platformName, removeElements, path, fileName, e_1; | ||
var actualFolder, base64Image, disableCSSAnimation, fileNameOptions, filePath, hideElements, noScrollBars, logLevel, platformName, removeElements, path, fileName, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
actualFolder = options.actualFolder, base64Image = options.base64Image, disableCSSAnimation = options.disableCSSAnimation, fileNameOptions = options.fileName, filePath = options.filePath, hideElements = options.hideElements, noScrollBars = options.hideScrollBars, platformName = options.platformName, removeElements = options.removeElements; | ||
actualFolder = options.actualFolder, base64Image = options.base64Image, disableCSSAnimation = options.disableCSSAnimation, fileNameOptions = options.fileName, filePath = options.filePath, hideElements = options.hideElements, noScrollBars = options.hideScrollBars, logLevel = options.logLevel, platformName = options.platformName, removeElements = options.removeElements; | ||
path = utils_1.getAndCreatePath(actualFolder, filePath); | ||
@@ -76,3 +77,5 @@ fileName = utils_1.formatFileName(fileNameOptions); | ||
e_1 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_1 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_1 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
} | ||
return [3, 7]; | ||
@@ -79,0 +82,0 @@ case 7: |
@@ -42,2 +42,3 @@ "use strict"; | ||
var fs_extra_1 = require("fs-extra"); | ||
var options_interface_1 = require("./options.interface"); | ||
describe('afterScreenshot', function () { | ||
@@ -81,2 +82,3 @@ var folder = path_1.join(process.cwd(), '/.tmp/afterScreenshot'); | ||
}, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
hideElements: ['<div></div>'], | ||
@@ -83,0 +85,0 @@ platformName: '', |
import { EnrichedInstanceData, InstanceData } from '../methods/instanceData.interfaces'; | ||
import { LogLevel } from "./options.interface"; | ||
export interface BeforeScreenshotOptions { | ||
@@ -6,2 +7,3 @@ instanceData: InstanceData; | ||
disableCSSAnimation: boolean; | ||
logLevel: LogLevel; | ||
noScrollBars: boolean; | ||
@@ -8,0 +10,0 @@ toolBarShadowPadding: number; |
@@ -57,6 +57,7 @@ "use strict"; | ||
var chalk_1 = require("chalk"); | ||
var options_interface_1 = require("./options.interface"); | ||
function beforeScreenshot(executor, options, addShadowPadding) { | ||
if (addShadowPadding === void 0) { addShadowPadding = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, browserName, nativeWebScreenshot, platformName, addressBarShadowPadding, disableCSSAnimation, hideElements, noScrollBars, removeElements, toolBarShadowPadding, addressBarPadding, toolBarPadding, e_1, instanceOptions; | ||
var _a, browserName, nativeWebScreenshot, platformName, addressBarShadowPadding, disableCSSAnimation, hideElements, logLevel, noScrollBars, removeElements, toolBarShadowPadding, addressBarPadding, toolBarPadding, e_1, instanceOptions; | ||
return __generator(this, function (_b) { | ||
@@ -66,3 +67,3 @@ switch (_b.label) { | ||
_a = options.instanceData, browserName = _a.browserName, nativeWebScreenshot = _a.nativeWebScreenshot, platformName = _a.platformName; | ||
addressBarShadowPadding = options.addressBarShadowPadding, disableCSSAnimation = options.disableCSSAnimation, hideElements = options.hideElements, noScrollBars = options.noScrollBars, removeElements = options.removeElements, toolBarShadowPadding = options.toolBarShadowPadding; | ||
addressBarShadowPadding = options.addressBarShadowPadding, disableCSSAnimation = options.disableCSSAnimation, hideElements = options.hideElements, logLevel = options.logLevel, noScrollBars = options.noScrollBars, removeElements = options.removeElements, toolBarShadowPadding = options.toolBarShadowPadding; | ||
addressBarPadding = utils_1.getAddressBarShadowPadding({ | ||
@@ -92,3 +93,5 @@ platformName: platformName, | ||
e_1 = _b.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_1 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_1 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
} | ||
return [3, 6]; | ||
@@ -95,0 +98,0 @@ case 6: |
@@ -40,2 +40,3 @@ "use strict"; | ||
var beforeScreenshot_1 = require("./beforeScreenshot"); | ||
var options_interface_1 = require("./options.interface"); | ||
describe('beforeScreenshot', function () { | ||
@@ -61,2 +62,3 @@ it('should be able to return the enriched instance data with default options', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
disableCSSAnimation: true, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
noScrollBars: true, | ||
@@ -95,2 +97,3 @@ toolBarShadowPadding: 6, | ||
noScrollBars: true, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -97,0 +100,0 @@ hideElements: ['<div></div>'], |
@@ -28,11 +28,2 @@ export declare const DEFAULT_FORMAT_STRING = "{tag}-{browserName}-{width}x{height}-dpr-{dpr}"; | ||
export declare const FULL_PAGE_SCROLL_TIMEOUT = 1500; | ||
export declare const LOG_METHODS: string[]; | ||
export declare const LOG_LEVELS: { | ||
ERROR: string; | ||
WARN: string; | ||
INFO: string; | ||
DEBUG: string; | ||
TRACE: string; | ||
SILENT: string; | ||
}; | ||
export declare const OFFSETS: { | ||
@@ -39,0 +30,0 @@ ANDROID: { |
@@ -14,2 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_TABBABLE_OPTIONS = exports.OFFSETS = exports.FULL_PAGE_SCROLL_TIMEOUT = exports.DEFAULT_RESIZE_DIMENSIONS = exports.CUSTOM_CSS_ID = exports.DESKTOP = exports.DEFAULT_SHADOW = exports.FOLDERS = exports.PLATFORMS = exports.DEFAULT_FORMAT_STRING = void 0; | ||
exports.DEFAULT_FORMAT_STRING = '{tag}-{browserName}-{width}x{height}-dpr-{dpr}'; | ||
@@ -42,11 +43,2 @@ exports.PLATFORMS = { | ||
exports.FULL_PAGE_SCROLL_TIMEOUT = 1500; | ||
exports.LOG_METHODS = ['error', 'warn', 'info', 'debug', 'trace', 'silent']; | ||
exports.LOG_LEVELS = { | ||
ERROR: 'error', | ||
WARN: 'warn', | ||
INFO: 'info', | ||
DEBUG: 'debug', | ||
TRACE: 'trace', | ||
SILENT: 'silent', | ||
}; | ||
var androidDefaultOffsets = { | ||
@@ -53,0 +45,0 @@ STATUS_BAR: 24, |
@@ -7,5 +7,5 @@ import { TabbableOptions } from "../commands/tabbable.interfaces"; | ||
clearRuntimeFolder?: boolean; | ||
debug?: boolean; | ||
formatImageName?: string; | ||
isHybridApp?: boolean; | ||
logLevel?: LogLevel; | ||
savePerInstance?: boolean; | ||
@@ -34,3 +34,2 @@ screenshotPath?: any; | ||
clearFolder: boolean; | ||
debug: boolean; | ||
formatImageName: string; | ||
@@ -43,2 +42,3 @@ isHybridApp: boolean; | ||
hideScrollBars: boolean; | ||
logLevel: LogLevel; | ||
compareOptions: CompareOptions; | ||
@@ -60,2 +60,8 @@ tabbableOptions: TabbableOptions; | ||
} | ||
export declare enum LogLevel { | ||
debug = "debug", | ||
info = "info", | ||
warn = "warn", | ||
silent = "silent" | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LogLevel = void 0; | ||
var LogLevel; | ||
(function (LogLevel) { | ||
LogLevel["debug"] = "debug"; | ||
LogLevel["info"] = "info"; | ||
LogLevel["warn"] = "warn"; | ||
LogLevel["silent"] = "silent"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
//# sourceMappingURL=options.interface.js.map |
@@ -14,3 +14,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.methodCompareOptions = exports.screenMethodCompareOptions = exports.defaultOptions = void 0; | ||
var constants_1 = require("./constants"); | ||
var options_interface_1 = require("./options.interface"); | ||
function defaultOptions(options) { | ||
@@ -21,5 +23,5 @@ return { | ||
clearFolder: options.clearRuntimeFolder || false, | ||
debug: options.debug || false, | ||
formatImageName: options.formatImageName || constants_1.DEFAULT_FORMAT_STRING, | ||
isHybridApp: options.isHybridApp || false, | ||
logLevel: options.logLevel || options_interface_1.LogLevel.info, | ||
savePerInstance: options.savePerInstance || false, | ||
@@ -26,0 +28,0 @@ toolBarShadowPadding: options.toolBarShadowPadding || constants_1.DEFAULT_SHADOW.TOOL_BAR, |
@@ -13,3 +13,2 @@ "use strict"; | ||
autoSaveBaseline: true, | ||
debug: true, | ||
formatImageName: '{foo}-{bar}', | ||
@@ -16,0 +15,0 @@ savePerInstance: true, |
@@ -39,2 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getScreenshotSize = exports.waitFor = exports.calculateDprData = exports.getToolBarShadowPadding = exports.getAddressBarShadowPadding = exports.checkAndroidChromeDriverScreenshot = exports.checkAndroidNativeWebScreenshot = exports.checkTestInMobileBrowser = exports.checkTestInBrowser = exports.checkIsIos = exports.checkIsAndroid = exports.checkIsMobile = exports.formatFileName = exports.getAndCreatePath = void 0; | ||
var path_1 = require("path"); | ||
@@ -41,0 +42,0 @@ var constants_1 = require("./constants"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkTabbablePage = exports.checkFullPageScreen = exports.checkElement = exports.checkScreen = exports.saveTabbablePage = exports.saveFullPageScreen = exports.saveElement = exports.saveScreen = exports.BaseClass = void 0; | ||
var base_1 = require("./base"); | ||
@@ -4,0 +5,0 @@ exports.BaseClass = base_1.default; |
@@ -39,2 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getElementPositionIos = exports.getElementPositionDesktop = exports.getElementPositionAndroid = void 0; | ||
var getElementPositionTopWindow_1 = require("../clientSideScripts/getElementPositionTopWindow"); | ||
@@ -41,0 +42,0 @@ var getElementPositionTopDom_1 = require("../clientSideScripts/getElementPositionTopDom"); |
@@ -1,10 +0,10 @@ | ||
import { RectanglesOutput } from './rectangles.interfaces'; | ||
import { IgnoreBoxes, ImageCompareOptions, ImageCompareResult, ResizeDimensions } from './images.interfaces'; | ||
import { CroppedBase64Image, IgnoreBoxes, ImageCompareOptions, ImageCompareResult } from './images.interfaces'; | ||
import { FullPageScreenshotsData } from './screenshots.interfaces'; | ||
import { Executor } from './methods.interface'; | ||
export declare function checkBaselineImageExists(actualFilePath: string, baselineFilePath: string, autoSaveBaseline: boolean): Promise<void>; | ||
import { LogLevel } from "../helpers/options.interface"; | ||
export declare function checkBaselineImageExists(actualFilePath: string, baselineFilePath: string, autoSaveBaseline: boolean, logLevel: LogLevel): Promise<void>; | ||
export declare function makeCroppedBase64Image({ base64Image, rectangles, logLevel, resizeDimensions, }: CroppedBase64Image): Promise<string>; | ||
export declare function executeImageCompare(executor: Executor, options: ImageCompareOptions, isViewPortScreenshot?: boolean): Promise<ImageCompareResult | number>; | ||
export declare function makeCroppedBase64Image(base64Image: string, rectangles: RectanglesOutput, resizeDimensions?: number | ResizeDimensions): Promise<string>; | ||
export declare function makeFullPageBase64Image(screenshotsData: FullPageScreenshotsData): Promise<string>; | ||
export declare function saveBase64Image(base64Image: string, filePath: string): Promise<void>; | ||
export declare function addBlockOuts(screenshot: string, ignoredBoxes: IgnoreBoxes[]): Promise<string>; |
import { RectanglesOutput } from './rectangles.interfaces'; | ||
import { LogLevel } from "../helpers/options.interface"; | ||
export interface ResizeDimensions { | ||
@@ -9,3 +10,2 @@ bottom: number; | ||
export interface ImageCompareOptions { | ||
debug: boolean; | ||
devicePixelRatio: number; | ||
@@ -19,2 +19,3 @@ compareOptions: { | ||
isHybridApp: boolean; | ||
logLevel: LogLevel; | ||
platformName: string; | ||
@@ -86,1 +87,7 @@ isAndroidNativeWebScreenshot: boolean; | ||
} | ||
export interface CroppedBase64Image { | ||
base64Image: string; | ||
rectangles: RectanglesOutput; | ||
logLevel: LogLevel; | ||
resizeDimensions?: number | ResizeDimensions; | ||
} |
@@ -50,2 +50,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addBlockOuts = exports.saveBase64Image = exports.makeFullPageBase64Image = exports.executeImageCompare = exports.makeCroppedBase64Image = exports.checkBaselineImageExists = void 0; | ||
var chalk_1 = require("chalk"); | ||
@@ -58,4 +59,5 @@ var fs_extra_1 = require("fs-extra"); | ||
var rectangles_1 = require("./rectangles"); | ||
var options_interface_1 = require("../helpers/options.interface"); | ||
var _a = require('canvas'), createCanvas = _a.createCanvas, loadImage = _a.loadImage; | ||
function checkBaselineImageExists(actualFilePath, baselineFilePath, autoSaveBaseline) { | ||
function checkBaselineImageExists(actualFilePath, baselineFilePath, autoSaveBaseline, logLevel) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -69,3 +71,5 @@ return __generator(this, function (_a) { | ||
fs_extra_1.copySync(actualFilePath, baselineFilePath); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n INFO:\n Autosaved the image to\n " + baselineFilePath + "\n#####################################################################################\n")); | ||
if (logLevel === options_interface_1.LogLevel.info) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n INFO:\n Autosaved the image to\n " + baselineFilePath + "\n#####################################################################################\n")); | ||
} | ||
} | ||
@@ -87,10 +91,61 @@ catch (error) { | ||
exports.checkBaselineImageExists = checkBaselineImageExists; | ||
function makeCroppedBase64Image(_a) { | ||
var base64Image = _a.base64Image, rectangles = _a.rectangles, logLevel = _a.logLevel, _b = _a.resizeDimensions, resizeDimensions = _b === void 0 ? constants_1.DEFAULT_RESIZE_DIMENSIONS : _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resizeValues, _c, top, right, bottom, left, height, width, x, y, canvasWidth, canvasHeight, canvas, image, ctx, sourceXStart, sourceYStart; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
if (typeof resizeDimensions === 'number') { | ||
resizeValues = { | ||
top: resizeDimensions, | ||
right: resizeDimensions, | ||
bottom: resizeDimensions, | ||
left: resizeDimensions, | ||
}; | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n THE 'resizeDimensions' NEEDS TO BE AN OBJECT LIKE\n {\n top: 10,\n right: 20,\n bottom: 15,\n left: 25,\n }\n NOW IT WILL BE DEFAULTED TO\n {\n top: " + resizeDimensions + ",\n right: " + resizeDimensions + ",\n bottom: " + resizeDimensions + ",\n left: " + resizeDimensions + ",\n }\n THIS IS DEPRACATED AND WILL BE REMOVED IN A NEW MAJOR RELEASE\n#####################################################################################\n")); | ||
} | ||
} | ||
else { | ||
resizeValues = resizeDimensions; | ||
} | ||
_c = __assign(__assign({}, constants_1.DEFAULT_RESIZE_DIMENSIONS), resizeValues), top = _c.top, right = _c.right, bottom = _c.bottom, left = _c.left; | ||
height = rectangles.height, width = rectangles.width, x = rectangles.x, y = rectangles.y; | ||
canvasWidth = width + left + right; | ||
canvasHeight = height + top + bottom; | ||
canvas = createCanvas(canvasWidth, canvasHeight); | ||
return [4, loadImage("data:image/png;base64," + base64Image)]; | ||
case 1: | ||
image = _d.sent(); | ||
ctx = canvas.getContext('2d'); | ||
sourceXStart = x - left; | ||
sourceYStart = y - top; | ||
if (sourceXStart < 0) { | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n THE RESIZE DIMENSION LEFT '" + left + "' MADE THE CROPPING GO OUT OF\n THE IMAGE BOUNDARIES RESULTING IN AN IMAGE STARTPOSITION '" + sourceXStart + "'.\n THIS HAS BEEN DEFAULTED TO '0'\n#####################################################################################\n")); | ||
} | ||
sourceXStart = 0; | ||
} | ||
if (sourceYStart < 0) { | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n THE RESIZE DIMENSION LEFT '" + top + "' MADE THE CROPPING GO OUT OF\n THE IMAGE BOUNDARIES RESULTING IN AN IMAGE STARTPOSITION '" + sourceYStart + "'.\n THIS HAS BEEN DEFAULTED TO '0'\n#####################################################################################\n")); | ||
} | ||
sourceYStart = 0; | ||
} | ||
ctx.drawImage(image, sourceXStart, sourceYStart, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight); | ||
return [2, canvas.toDataURL().replace(/^data:image\/png;base64,/, '')]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.makeCroppedBase64Image = makeCroppedBase64Image; | ||
function executeImageCompare(executor, options, isViewPortScreenshot) { | ||
if (isViewPortScreenshot === void 0) { isViewPortScreenshot = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var debug, devicePixelRatio, fileName, isAndroidNativeWebScreenshot, isHybridApp, platformName, _a, actualFolder, autoSaveBaseline, baselineFolder, browserName, deviceName, diffFolder, isMobile, savePerInstance, diffFilePath, imageCompareOptions, createFolderOptions, actualFolderPath, baselineFolderPath, actualFilePath, baselineFilePath, resembleIgnoreDefaults, ignore, blockOut, statusAddressToolBarOptions, ignoredBoxes, _b, _c, compareOptions, data, misMatchPercentage, isDifference, isDifferenceMessage, debugMessage, diffFolderPath, _d; | ||
var devicePixelRatio, fileName, isAndroidNativeWebScreenshot, isHybridApp, logLevel, platformName, _a, actualFolder, autoSaveBaseline, baselineFolder, browserName, deviceName, diffFolder, isMobile, savePerInstance, diffFilePath, imageCompareOptions, createFolderOptions, actualFolderPath, baselineFolderPath, actualFilePath, baselineFilePath, resembleIgnoreDefaults, ignore, blockOut, statusAddressToolBarOptions, ignoredBoxes, _b, _c, compareOptions, data, misMatchPercentage, isDifference, isDifferenceMessage, debugMessage, diffFolderPath, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
debug = options.debug, devicePixelRatio = options.devicePixelRatio, fileName = options.fileName, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot, isHybridApp = options.isHybridApp, platformName = options.platformName; | ||
devicePixelRatio = options.devicePixelRatio, fileName = options.fileName, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot, isHybridApp = options.isHybridApp, logLevel = options.logLevel, platformName = options.platformName; | ||
_a = options.folderOptions, actualFolder = _a.actualFolder, autoSaveBaseline = _a.autoSaveBaseline, baselineFolder = _a.baselineFolder, browserName = _a.browserName, deviceName = _a.deviceName, diffFolder = _a.diffFolder, isMobile = _a.isMobile, savePerInstance = _a.savePerInstance; | ||
@@ -103,3 +158,3 @@ imageCompareOptions = __assign(__assign({}, options.compareOptions.wic), options.compareOptions.method); | ||
baselineFilePath = path_1.join(baselineFolderPath, fileName); | ||
return [4, checkBaselineImageExists(actualFilePath, baselineFilePath, autoSaveBaseline)]; | ||
return [4, checkBaselineImageExists(actualFilePath, baselineFilePath, autoSaveBaseline, logLevel)]; | ||
case 1: | ||
@@ -141,3 +196,3 @@ _e.sent(); | ||
: Number(data.rawMisMatchPercentage.toFixed(2)); | ||
if (!(misMatchPercentage > imageCompareOptions.saveAboveTolerance || debug)) return [3, 6]; | ||
if (!(misMatchPercentage > imageCompareOptions.saveAboveTolerance || logLevel === options_interface_1.LogLevel.debug)) return [3, 6]; | ||
isDifference = misMatchPercentage > imageCompareOptions.saveAboveTolerance; | ||
@@ -150,7 +205,6 @@ isDifferenceMessage = 'WARNING:\n There was a difference. Saved the difference to'; | ||
return [4, addBlockOuts(Buffer.from(data.getBuffer()).toString('base64'), ignoredBoxes)]; | ||
case 4: return [4, _d.apply(void 0, [_e.sent(), | ||
diffFilePath])]; | ||
case 4: return [4, _d.apply(void 0, [_e.sent(), diffFilePath])]; | ||
case 5: | ||
_e.sent(); | ||
if (debug) { | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n " + (isDifference ? isDifferenceMessage : debugMessage) + "\n " + diffFilePath + "\n#####################################################################################\n")); | ||
@@ -169,47 +223,2 @@ } | ||
exports.executeImageCompare = executeImageCompare; | ||
function makeCroppedBase64Image(base64Image, rectangles, resizeDimensions) { | ||
if (resizeDimensions === void 0) { resizeDimensions = constants_1.DEFAULT_RESIZE_DIMENSIONS; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resizeValues, _a, top, right, bottom, left, height, width, x, y, canvasWidth, canvasHeight, canvas, image, ctx, sourceXStart, sourceYStart; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (typeof resizeDimensions === 'number') { | ||
resizeValues = { | ||
top: resizeDimensions, | ||
right: resizeDimensions, | ||
bottom: resizeDimensions, | ||
left: resizeDimensions, | ||
}; | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n THE 'resizeDimensions' NEEDS TO BE AN OBJECT LIKE\n {\n top: 10,\n right: 20,\n bottom: 15,\n left: 25,\n }\n NOW IT WILL BE DEFAULTED TO\n {\n top: " + resizeDimensions + ",\n right: " + resizeDimensions + ",\n bottom: " + resizeDimensions + ",\n left: " + resizeDimensions + ",\n }\n THIS IS DEPRACATED AND WILL BE REMOVED IN A NEW MAJOR RELEASE\n#####################################################################################\n")); | ||
} | ||
else { | ||
resizeValues = resizeDimensions; | ||
} | ||
_a = __assign(__assign({}, constants_1.DEFAULT_RESIZE_DIMENSIONS), resizeValues), top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left; | ||
height = rectangles.height, width = rectangles.width, x = rectangles.x, y = rectangles.y; | ||
canvasWidth = width + left + right; | ||
canvasHeight = height + top + bottom; | ||
canvas = createCanvas(canvasWidth, canvasHeight); | ||
return [4, loadImage("data:image/png;base64," + base64Image)]; | ||
case 1: | ||
image = _b.sent(); | ||
ctx = canvas.getContext('2d'); | ||
sourceXStart = x - left; | ||
sourceYStart = y - top; | ||
if (sourceXStart < 0) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n THE RESIZE DIMENSION LEFT '" + left + "' MADE THE CROPPING GO OUT OF\n THE IMAGE BOUNDARIES RESULTING IN AN IMAGE STARTPOSITION '" + sourceXStart + "'.\n THIS HAS BEEN DEFAULTED TO '0'\n#####################################################################################\n")); | ||
sourceXStart = 0; | ||
} | ||
if (sourceYStart < 0) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n THE RESIZE DIMENSION LEFT '" + top + "' MADE THE CROPPING GO OUT OF\n THE IMAGE BOUNDARIES RESULTING IN AN IMAGE STARTPOSITION '" + sourceYStart + "'.\n THIS HAS BEEN DEFAULTED TO '0'\n#####################################################################################\n")); | ||
sourceYStart = 0; | ||
} | ||
ctx.drawImage(image, sourceXStart, sourceYStart, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight); | ||
return [2, canvas.toDataURL().replace(/^data:image\/png;base64,/, '')]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.makeCroppedBase64Image = makeCroppedBase64Image; | ||
function makeFullPageBase64Image(screenshotsData) { | ||
@@ -216,0 +225,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -1,5 +0,5 @@ | ||
import { ElementRectanglesOptions, RectanglesOutput, ScreenRectanglesOptions, StatusAddressToolBarRectangles, StatusAddressToolBarRectanglesOptions } from './rectangles.interfaces'; | ||
import { ElementRectangles, RectanglesOutput, ScreenRectanglesOptions, StatusAddressToolBarRectangles, StatusAddressToolBarRectanglesOptions } from './rectangles.interfaces'; | ||
import { Executor } from './methods.interface'; | ||
export declare function determineElementRectangles(executor: Executor, screenshot: string, options: ElementRectanglesOptions, element: any): Promise<RectanglesOutput>; | ||
export declare function determineScreenRectangles(screenshot: string, options: ScreenRectanglesOptions): RectanglesOutput; | ||
export declare function determineElementRectangles({ executor, base64Image, options, element, }: ElementRectangles): Promise<RectanglesOutput>; | ||
export declare function determineScreenRectangles(base64Image: string, options: ScreenRectanglesOptions): RectanglesOutput; | ||
export declare function determineStatusAddressToolBarRectangles(executor: Executor, options: StatusAddressToolBarRectanglesOptions): Promise<StatusAddressToolBarRectangles>; |
@@ -0,1 +1,2 @@ | ||
import { Executor } from "./methods.interface"; | ||
export interface RectanglesOptions { | ||
@@ -31,1 +32,7 @@ devicePixelRatio: number; | ||
} | ||
export interface ElementRectangles { | ||
executor: Executor; | ||
base64Image: string; | ||
options: ElementRectanglesOptions; | ||
element: any; | ||
} |
@@ -39,2 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.determineStatusAddressToolBarRectangles = exports.determineScreenRectangles = exports.determineElementRectangles = void 0; | ||
var utils_1 = require("../helpers/utils"); | ||
@@ -45,14 +46,15 @@ var elementPosition_1 = require("./elementPosition"); | ||
var getAndroidStatusAddressToolBarHeight_1 = require("../clientSideScripts/getAndroidStatusAddressToolBarHeight"); | ||
function determineElementRectangles(executor, screenshot, options, element) { | ||
function determineElementRectangles(_a) { | ||
var executor = _a.executor, base64Image = _a.base64Image, options = _a.options, element = _a.element; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var devicePixelRatio, innerHeight, isAndroid, isAndroidNativeWebScreenshot, isIos, height, elementPosition; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
devicePixelRatio = options.devicePixelRatio, innerHeight = options.innerHeight, isAndroid = options.isAndroid, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot, isIos = options.isIos; | ||
height = utils_1.getScreenshotSize(screenshot, devicePixelRatio).height; | ||
height = utils_1.getScreenshotSize(base64Image, devicePixelRatio).height; | ||
if (!isIos) return [3, 2]; | ||
return [4, elementPosition_1.getElementPositionIos(executor, element)]; | ||
case 1: | ||
elementPosition = _a.sent(); | ||
elementPosition = _b.sent(); | ||
return [3, 6]; | ||
@@ -63,8 +65,8 @@ case 2: | ||
case 3: | ||
elementPosition = _a.sent(); | ||
elementPosition = _b.sent(); | ||
return [3, 6]; | ||
case 4: return [4, elementPosition_1.getElementPositionDesktop(executor, innerHeight, height, element)]; | ||
case 5: | ||
elementPosition = _a.sent(); | ||
_a.label = 6; | ||
elementPosition = _b.sent(); | ||
_b.label = 6; | ||
case 6: return [2, utils_1.calculateDprData({ | ||
@@ -81,5 +83,5 @@ height: elementPosition.height, | ||
exports.determineElementRectangles = determineElementRectangles; | ||
function determineScreenRectangles(screenshot, options) { | ||
function determineScreenRectangles(base64Image, options) { | ||
var devicePixelRatio = options.devicePixelRatio, innerHeight = options.innerHeight, innerWidth = options.innerWidth, isIos = options.isIos, isAndroidChromeDriverScreenshot = options.isAndroidChromeDriverScreenshot, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot; | ||
var _a = utils_1.getScreenshotSize(screenshot, devicePixelRatio), height = _a.height, width = _a.width; | ||
var _a = utils_1.getScreenshotSize(base64Image, devicePixelRatio), height = _a.height, width = _a.width; | ||
var screenshotWidth = isAndroidChromeDriverScreenshot ? width : innerWidth; | ||
@@ -86,0 +88,0 @@ return utils_1.calculateDprData({ |
@@ -77,3 +77,8 @@ "use strict"; | ||
_a = expect; | ||
return [4, rectangles_1.determineElementRectangles(MOCKED_EXECUTOR, mocks_1.IMAGE_STRING, options, 'element')]; | ||
return [4, rectangles_1.determineElementRectangles({ | ||
executor: MOCKED_EXECUTOR, | ||
base64Image: mocks_1.IMAGE_STRING, | ||
options: options, | ||
element: 'element', | ||
})]; | ||
case 1: | ||
@@ -119,3 +124,8 @@ _a.apply(void 0, [_b.sent()]).toMatchSnapshot(); | ||
_a = expect; | ||
return [4, rectangles_1.determineElementRectangles(MOCKED_EXECUTOR, mocks_1.IMAGE_STRING, options, 'element')]; | ||
return [4, rectangles_1.determineElementRectangles({ | ||
executor: MOCKED_EXECUTOR, | ||
base64Image: mocks_1.IMAGE_STRING, | ||
options: options, | ||
element: 'element', | ||
})]; | ||
case 1: | ||
@@ -147,3 +157,8 @@ _a.apply(void 0, [_b.sent()]).toMatchSnapshot(); | ||
_a = expect; | ||
return [4, rectangles_1.determineElementRectangles(MOCKED_EXECUTOR, mocks_1.IMAGE_STRING, options, 'element')]; | ||
return [4, rectangles_1.determineElementRectangles({ | ||
executor: MOCKED_EXECUTOR, | ||
base64Image: mocks_1.IMAGE_STRING, | ||
options: options, | ||
element: 'element', | ||
})]; | ||
case 1: | ||
@@ -175,3 +190,8 @@ _a.apply(void 0, [_b.sent()]).toMatchSnapshot(); | ||
_a = expect; | ||
return [4, rectangles_1.determineElementRectangles(MOCKED_EXECUTOR, mocks_1.IMAGE_STRING, options, 'element')]; | ||
return [4, rectangles_1.determineElementRectangles({ | ||
executor: MOCKED_EXECUTOR, | ||
base64Image: mocks_1.IMAGE_STRING, | ||
options: options, | ||
element: 'element', | ||
})]; | ||
case 1: | ||
@@ -178,0 +198,0 @@ _a.apply(void 0, [_b.sent()]).toMatchSnapshot(); |
@@ -0,1 +1,2 @@ | ||
import { LogLevel } from "../helpers/options.interface"; | ||
export interface FullPageScreenshotsData { | ||
@@ -25,2 +26,3 @@ fullPageHeight: number; | ||
isIos: boolean; | ||
logLevel: LogLevel; | ||
toolBarShadowPadding: number; | ||
@@ -33,2 +35,3 @@ } | ||
innerHeight: number; | ||
logLevel: LogLevel; | ||
statusAddressBarHeight: number; | ||
@@ -43,3 +46,4 @@ toolBarShadowPadding: number; | ||
hideAfterFirstScroll: (HTMLElement | HTMLElement[])[]; | ||
logLevel: LogLevel; | ||
} | ||
export {}; |
@@ -50,2 +50,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.takeBase64Screenshot = exports.getFullPageScreenshotsDataDesktop = exports.getFullPageScreenshotsDataAndroidChromeDriver = exports.getFullPageScreenshotsDataNativeMobile = exports.getBase64FullPageScreenshotsData = void 0; | ||
var chalk_1 = require("chalk"); | ||
@@ -60,9 +61,10 @@ var scrollToPosition_1 = require("../clientSideScripts/scrollToPosition"); | ||
var hideScrollbars_1 = require("../clientSideScripts/hideScrollbars"); | ||
var options_interface_1 = require("../helpers/options.interface"); | ||
function getBase64FullPageScreenshotsData(takeScreenshot, executor, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var addressBarShadowPadding, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, isAndroid, isAndroidNativeWebScreenshot, isAndroidChromeDriverScreenshot, isHybridApp, isIos, toolBarShadowPadding, desktopOptions, nativeMobileOptions, statusAddressBarHeight, androidNativeMobileOptions, chromeDriverOptions, statusAddressBarHeight, iosNativeMobileOptions; | ||
var addressBarShadowPadding, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, isAndroid, isAndroidNativeWebScreenshot, isAndroidChromeDriverScreenshot, isHybridApp, isIos, logLevel, toolBarShadowPadding, desktopOptions, nativeMobileOptions, statusAddressBarHeight, androidNativeMobileOptions, chromeDriverOptions, statusAddressBarHeight, iosNativeMobileOptions; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
addressBarShadowPadding = options.addressBarShadowPadding, devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, isAndroid = options.isAndroid, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot, isAndroidChromeDriverScreenshot = options.isAndroidChromeDriverScreenshot, isHybridApp = options.isHybridApp, isIos = options.isIos, toolBarShadowPadding = options.toolBarShadowPadding; | ||
addressBarShadowPadding = options.addressBarShadowPadding, devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, isAndroid = options.isAndroid, isAndroidNativeWebScreenshot = options.isAndroidNativeWebScreenshot, isAndroidChromeDriverScreenshot = options.isAndroidChromeDriverScreenshot, isHybridApp = options.isHybridApp, isIos = options.isIos, logLevel = options.logLevel, toolBarShadowPadding = options.toolBarShadowPadding; | ||
desktopOptions = { | ||
@@ -73,2 +75,3 @@ devicePixelRatio: devicePixelRatio, | ||
innerHeight: innerHeight, | ||
logLevel: logLevel, | ||
}; | ||
@@ -85,3 +88,3 @@ nativeMobileOptions = __assign(__assign({}, desktopOptions), { addressBarShadowPadding: addressBarShadowPadding, | ||
if (!(isAndroid && isAndroidChromeDriverScreenshot)) return [3, 3]; | ||
chromeDriverOptions = { devicePixelRatio: devicePixelRatio, fullPageScrollTimeout: fullPageScrollTimeout, hideAfterFirstScroll: hideAfterFirstScroll, innerHeight: innerHeight }; | ||
chromeDriverOptions = { devicePixelRatio: devicePixelRatio, fullPageScrollTimeout: fullPageScrollTimeout, hideAfterFirstScroll: hideAfterFirstScroll, innerHeight: innerHeight, logLevel: logLevel }; | ||
return [2, getFullPageScreenshotsDataAndroidChromeDriver(takeScreenshot, executor, chromeDriverOptions)]; | ||
@@ -103,3 +106,3 @@ case 3: | ||
return __awaiter(this, void 0, void 0, function () { | ||
var viewportScreenshots, addressBarShadowPadding, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, statusAddressBarHeight, toolBarShadowPadding, iosViewportHeight, amountOfScrollsArray, scrollHeight, screenshotSizeWidth, i, scrollY_1, e_1, screenshot, imageHeight, imageYPosition, e_2; | ||
var viewportScreenshots, addressBarShadowPadding, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, logLevel, statusAddressBarHeight, toolBarShadowPadding, iosViewportHeight, amountOfScrollsArray, scrollHeight, screenshotSizeWidth, i, scrollY_1, e_1, screenshot, imageHeight, imageYPosition, e_2; | ||
return __generator(this, function (_a) { | ||
@@ -109,3 +112,3 @@ switch (_a.label) { | ||
viewportScreenshots = []; | ||
addressBarShadowPadding = options.addressBarShadowPadding, devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, statusAddressBarHeight = options.statusAddressBarHeight, toolBarShadowPadding = options.toolBarShadowPadding; | ||
addressBarShadowPadding = options.addressBarShadowPadding, devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, logLevel = options.logLevel, statusAddressBarHeight = options.statusAddressBarHeight, toolBarShadowPadding = options.toolBarShadowPadding; | ||
iosViewportHeight = innerHeight - addressBarShadowPadding - toolBarShadowPadding; | ||
@@ -137,3 +140,3 @@ amountOfScrollsArray = []; | ||
e_1 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_1 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_1, logLevel); | ||
return [3, 8]; | ||
@@ -177,3 +180,3 @@ case 8: return [4, takeBase64Screenshot(takeScreenshot)]; | ||
e_2 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_2 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_2, logLevel); | ||
return [3, 17]; | ||
@@ -191,3 +194,3 @@ case 17: return [2, __assign(__assign({}, utils_1.calculateDprData({ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var viewportScreenshots, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, amountOfScrollsArray, scrollHeight, screenshotSize, i, scrollY_2, e_3, screenshot, imageHeight, imageYPosition, e_4; | ||
var viewportScreenshots, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, logLevel, amountOfScrollsArray, scrollHeight, screenshotSize, i, scrollY_2, e_3, screenshot, imageHeight, imageYPosition, e_4; | ||
return __generator(this, function (_a) { | ||
@@ -197,3 +200,3 @@ switch (_a.label) { | ||
viewportScreenshots = []; | ||
devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight; | ||
devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, logLevel = options.logLevel; | ||
amountOfScrollsArray = []; | ||
@@ -224,3 +227,3 @@ i = 0; | ||
e_3 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_3 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_3, logLevel); | ||
return [3, 8]; | ||
@@ -264,3 +267,3 @@ case 8: return [4, takeBase64Screenshot(takeScreenshot)]; | ||
e_4 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_4 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_4, logLevel); | ||
return [3, 17]; | ||
@@ -278,3 +281,3 @@ case 17: return [2, __assign(__assign({}, utils_1.calculateDprData({ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var viewportScreenshots, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, actualInnerHeight, amountOfScrollsArray, scrollHeight, screenshotSize, i, scrollY_3, e_5, screenshot, imageHeight, imageYPosition, e_6; | ||
var viewportScreenshots, devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight, logLevel, actualInnerHeight, amountOfScrollsArray, scrollHeight, screenshotSize, i, scrollY_3, e_5, screenshot, imageHeight, imageYPosition, e_6; | ||
return __generator(this, function (_a) { | ||
@@ -284,3 +287,3 @@ switch (_a.label) { | ||
viewportScreenshots = []; | ||
devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight; | ||
devicePixelRatio = options.devicePixelRatio, fullPageScrollTimeout = options.fullPageScrollTimeout, hideAfterFirstScroll = options.hideAfterFirstScroll, innerHeight = options.innerHeight, logLevel = options.logLevel; | ||
actualInnerHeight = innerHeight; | ||
@@ -309,3 +312,3 @@ amountOfScrollsArray = []; | ||
e_5 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_5 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_5, logLevel); | ||
return [3, 7]; | ||
@@ -353,3 +356,3 @@ case 7: return [4, takeBase64Screenshot(takeScreenshot)]; | ||
e_6 = _a.sent(); | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + e_6 + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
logHiddenRemovedError(e_6, logLevel); | ||
return [3, 15]; | ||
@@ -373,2 +376,7 @@ case 15: return [2, __assign(__assign({}, utils_1.calculateDprData({ | ||
exports.takeBase64Screenshot = takeBase64Screenshot; | ||
function logHiddenRemovedError(error, logLevel) { | ||
if (logLevel === options_interface_1.LogLevel.debug || logLevel === options_interface_1.LogLevel.warn) { | ||
console.log(chalk_1.yellow("\n#####################################################################################\n WARNING:\n (One of) the elements that needed to be hidden or removed could not be found on the\n page and caused this error\n Error: " + error + "\n We made sure the test didn't break.\n#####################################################################################\n")); | ||
} | ||
} | ||
//# sourceMappingURL=screenshots.js.map |
@@ -41,2 +41,3 @@ "use strict"; | ||
var mocks_1 = require("../mocks/mocks"); | ||
var options_interface_1 = require("../helpers/options.interface"); | ||
describe('screenshots', function () { | ||
@@ -61,2 +62,3 @@ describe('getBase64FullPageScreenshotsData', function () { | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -95,2 +97,3 @@ hideAfterFirstScroll: [], | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -135,2 +138,3 @@ hideAfterFirstScroll: ['<div/>'], | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -172,2 +176,3 @@ hideAfterFirstScroll: [], | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -211,2 +216,3 @@ hideAfterFirstScroll: ['<div/>'], | ||
isIos: true, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -249,2 +255,3 @@ hideAfterFirstScroll: [], | ||
isIos: true, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -289,2 +296,3 @@ hideAfterFirstScroll: ['<div/>'], | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -328,2 +336,3 @@ hideAfterFirstScroll: [], | ||
isIos: false, | ||
logLevel: options_interface_1.LogLevel.debug, | ||
toolBarShadowPadding: 6, | ||
@@ -330,0 +339,0 @@ hideAfterFirstScroll: ['<div/>'], |
{ | ||
"name": "webdriver-image-comparison", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "An image compare module that can be used for different NodeJS Test automation frameworks that support the webdriver protocol", | ||
@@ -34,22 +34,22 @@ "main": "./build/index.js", | ||
"canvas": "^2.6.1", | ||
"chalk": "^3.0.0", | ||
"fs-extra": "^8.1.0" | ||
"chalk": "^4.1.0", | ||
"fs-extra": "^9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/fs-extra": "^8.1.0", | ||
"@types/jest": "^25.2.1", | ||
"@types/node": "^13.13.0", | ||
"@types/selenium-webdriver": "^4.0.9", | ||
"@types/fs-extra": "^9.0.3", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.6", | ||
"@types/selenium-webdriver": "^4.0.10", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"coveralls": "^3.0.11", | ||
"husky": "^4.2.5", | ||
"jest": "^25.3.0", | ||
"np": "^6.2.1", | ||
"coveralls": "^3.1.0", | ||
"husky": "^4.3.0", | ||
"jest": "^26.6.3", | ||
"np": "^7.0.0", | ||
"rimraf": "^3.0.2", | ||
"source-map-loader": "^0.2.4", | ||
"ts-jest": "^25.4.0", | ||
"source-map-loader": "^1.1.2", | ||
"ts-jest": "^26.4.3", | ||
"tslint": "^6.1.1", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typescript": "^3.8.3", | ||
"typescript": "^4.0.5", | ||
"validate-commit-msg": "^2.14.0", | ||
@@ -56,0 +56,0 @@ "vrsource-tslint-rules": "^6.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
785368
7069
+ Addedat-least-node@1.0.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
- Removedchalk@3.0.0(transitive)
- Removedfs-extra@8.1.0(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)
Updatedchalk@^4.1.0
Updatedfs-extra@^9.0.1