@wdio/image-comparison-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/assets/ios/ipadair4th.ipadair5th-bottom.png +0 -0
- package/assets/ios/ipadair4th.ipadair5th-top.png +0 -0
- package/assets/ios/ipadmini6th-bottom.png +0 -0
- package/assets/ios/ipadmini6th-top.png +0 -0
- package/assets/ios/ipadpro11-bottom.png +0 -0
- package/assets/ios/ipadpro11-top.png +0 -0
- package/assets/ios/ipadpro129-bottom.png +0 -0
- package/assets/ios/ipadpro129-top.png +0 -0
- package/assets/ios/iphone11promax-bottom.png +0 -0
- package/assets/ios/iphone11promax-top.png +0 -0
- package/assets/ios/iphone12.iphone12pro-top.png +0 -0
- package/assets/ios/iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom.png +0 -0
- package/assets/ios/iphone12mini-top.png +0 -0
- package/assets/ios/iphone12mini.iphone13mini-bottom.png +0 -0
- package/assets/ios/iphone12promax-top.png +0 -0
- package/assets/ios/iphone12promax.iphone13promax.iphone14plus-bottom.png +0 -0
- package/assets/ios/iphone13.iphone13pro.iphone14-top.png +0 -0
- package/assets/ios/iphone13mini-top.png +0 -0
- package/assets/ios/iphone13promax.iphone14plus-top.png +0 -0
- package/assets/ios/iphone14pro-bottom.png +0 -0
- package/assets/ios/iphone14pro-top.png +0 -0
- package/assets/ios/iphone14promax-bottom.png +0 -0
- package/assets/ios/iphone14promax-top.png +0 -0
- package/assets/ios/iphone15-bottom.png +0 -0
- package/assets/ios/iphone15-top.png +0 -0
- package/assets/ios/iphonex.iphonexs.iphone11pro-bottom.png +0 -0
- package/assets/ios/iphonex.iphonexs.iphone11pro-top.png +0 -0
- package/assets/ios/iphonexr.iphone11-bottom.png +0 -0
- package/assets/ios/iphonexr.iphone11-top.png +0 -0
- package/assets/ios/iphonexsmax-bottom.png +0 -0
- package/assets/ios/iphonexsmax-top.png +0 -0
- package/dist/base.d.ts +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.interfaces.d.ts +200 -0
- package/dist/base.interfaces.d.ts.map +1 -0
- package/dist/base.interfaces.js +1 -0
- package/dist/base.js +58 -0
- package/dist/base.test.d.ts +2 -0
- package/dist/base.test.d.ts.map +1 -0
- package/dist/base.test.js +45 -0
- package/dist/clientSideScripts/checkMetaTag.d.ts +2 -0
- package/dist/clientSideScripts/checkMetaTag.d.ts.map +1 -0
- package/dist/clientSideScripts/checkMetaTag.js +9 -0
- package/dist/clientSideScripts/checkMetaTag.test.d.ts +2 -0
- package/dist/clientSideScripts/checkMetaTag.test.d.ts.map +1 -0
- package/dist/clientSideScripts/checkMetaTag.test.js +25 -0
- package/dist/clientSideScripts/customCss.interfaces.d.ts +8 -0
- package/dist/clientSideScripts/customCss.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/customCss.interfaces.js +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.d.ts +8 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.d.ts +4 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.js +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.js +275 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.d.ts +2 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.js +251 -0
- package/dist/clientSideScripts/elementPosition.interfaces.d.ts +3 -0
- package/dist/clientSideScripts/elementPosition.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/elementPosition.interfaces.js +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.d.ts +6 -0
- package/dist/clientSideScripts/getBoundingClientRect.d.ts.map +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.js +12 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.d.ts +2 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.js +28 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.d.ts +5 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.d.ts.map +1 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.js +48 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.d.ts +2 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.js +30 -0
- package/dist/clientSideScripts/getElementPositionTopDom.d.ts +6 -0
- package/dist/clientSideScripts/getElementPositionTopDom.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopDom.js +11 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.d.ts +2 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.js +11 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.d.ts +14 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.js +19 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.d.ts +2 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.js +52 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.d.ts +6 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.d.ts.map +1 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.js +17 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.d.ts +2 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.js +47 -0
- package/dist/clientSideScripts/getScreenDimensions.d.ts +6 -0
- package/dist/clientSideScripts/getScreenDimensions.d.ts.map +1 -0
- package/dist/clientSideScripts/getScreenDimensions.js +104 -0
- package/dist/clientSideScripts/getScreenDimensions.test.d.ts +2 -0
- package/dist/clientSideScripts/getScreenDimensions.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getScreenDimensions.test.js +161 -0
- package/dist/clientSideScripts/hideRemoveElements.d.ts +8 -0
- package/dist/clientSideScripts/hideRemoveElements.d.ts.map +1 -0
- package/dist/clientSideScripts/hideRemoveElements.js +60 -0
- package/dist/clientSideScripts/hideRemoveElements.test.d.ts +2 -0
- package/dist/clientSideScripts/hideRemoveElements.test.d.ts.map +1 -0
- package/dist/clientSideScripts/hideRemoveElements.test.js +199 -0
- package/dist/clientSideScripts/hideScrollbars.d.ts +9 -0
- package/dist/clientSideScripts/hideScrollbars.d.ts.map +1 -0
- package/dist/clientSideScripts/hideScrollbars.js +15 -0
- package/dist/clientSideScripts/hideScrollbars.test.d.ts +2 -0
- package/dist/clientSideScripts/hideScrollbars.test.d.ts.map +1 -0
- package/dist/clientSideScripts/hideScrollbars.test.js +12 -0
- package/dist/clientSideScripts/injectWebviewOverlay.d.ts +5 -0
- package/dist/clientSideScripts/injectWebviewOverlay.d.ts.map +1 -0
- package/dist/clientSideScripts/injectWebviewOverlay.js +35 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.d.ts +2 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.d.ts.map +1 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.js +74 -0
- package/dist/clientSideScripts/removeElementFromDom.d.ts +5 -0
- package/dist/clientSideScripts/removeElementFromDom.d.ts.map +1 -0
- package/dist/clientSideScripts/removeElementFromDom.js +9 -0
- package/dist/clientSideScripts/removeElementFromDom.test.d.ts +2 -0
- package/dist/clientSideScripts/removeElementFromDom.test.d.ts.map +1 -0
- package/dist/clientSideScripts/removeElementFromDom.test.js +43 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.d.ts +96 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.js +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.d.ts +5 -0
- package/dist/clientSideScripts/scrollElementIntoView.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.js +31 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.d.ts +2 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.js +79 -0
- package/dist/clientSideScripts/scrollToPosition.d.ts +5 -0
- package/dist/clientSideScripts/scrollToPosition.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollToPosition.js +25 -0
- package/dist/clientSideScripts/scrollToPosition.test.d.ts +2 -0
- package/dist/clientSideScripts/scrollToPosition.test.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollToPosition.test.js +72 -0
- package/dist/clientSideScripts/setCustomCss.d.ts +6 -0
- package/dist/clientSideScripts/setCustomCss.d.ts.map +1 -0
- package/dist/clientSideScripts/setCustomCss.js +36 -0
- package/dist/clientSideScripts/setCustomCss.test.d.ts +2 -0
- package/dist/clientSideScripts/setCustomCss.test.d.ts.map +1 -0
- package/dist/clientSideScripts/setCustomCss.test.js +68 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.d.ts +11 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.js +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.d.ts +5 -0
- package/dist/clientSideScripts/toggleTextTransparency.d.ts.map +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.js +16 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.d.ts +2 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.d.ts.map +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.js +35 -0
- package/dist/clientSideScripts/waitForFonts.d.ts +8 -0
- package/dist/clientSideScripts/waitForFonts.d.ts.map +1 -0
- package/dist/clientSideScripts/waitForFonts.js +20 -0
- package/dist/clientSideScripts/waitForFonts.test.d.ts +2 -0
- package/dist/clientSideScripts/waitForFonts.test.d.ts.map +1 -0
- package/dist/clientSideScripts/waitForFonts.test.js +37 -0
- package/dist/commands/check.interfaces.d.ts +35 -0
- package/dist/commands/check.interfaces.d.ts.map +1 -0
- package/dist/commands/check.interfaces.js +1 -0
- package/dist/commands/checkAppElement.d.ts +7 -0
- package/dist/commands/checkAppElement.d.ts.map +1 -0
- package/dist/commands/checkAppElement.js +44 -0
- package/dist/commands/checkAppElement.test.d.ts +2 -0
- package/dist/commands/checkAppElement.test.d.ts.map +1 -0
- package/dist/commands/checkAppElement.test.js +241 -0
- package/dist/commands/checkAppScreen.d.ts +7 -0
- package/dist/commands/checkAppScreen.d.ts.map +1 -0
- package/dist/commands/checkAppScreen.js +73 -0
- package/dist/commands/checkAppScreen.test.d.ts +2 -0
- package/dist/commands/checkAppScreen.test.d.ts.map +1 -0
- package/dist/commands/checkAppScreen.test.js +295 -0
- package/dist/commands/checkElement.d.ts +7 -0
- package/dist/commands/checkElement.d.ts.map +1 -0
- package/dist/commands/checkElement.js +10 -0
- package/dist/commands/checkElement.test.d.ts +2 -0
- package/dist/commands/checkElement.test.d.ts.map +1 -0
- package/dist/commands/checkElement.test.js +66 -0
- package/dist/commands/checkFullPageScreen.d.ts +7 -0
- package/dist/commands/checkFullPageScreen.d.ts.map +1 -0
- package/dist/commands/checkFullPageScreen.js +56 -0
- package/dist/commands/checkFullPageScreen.test.d.ts +2 -0
- package/dist/commands/checkFullPageScreen.test.d.ts.map +1 -0
- package/dist/commands/checkFullPageScreen.test.js +259 -0
- package/dist/commands/checkScreen.d.ts +7 -0
- package/dist/commands/checkScreen.d.ts.map +1 -0
- package/dist/commands/checkScreen.js +10 -0
- package/dist/commands/checkScreen.test.d.ts +2 -0
- package/dist/commands/checkScreen.test.d.ts.map +1 -0
- package/dist/commands/checkScreen.test.js +62 -0
- package/dist/commands/checkTabbablePage.d.ts +7 -0
- package/dist/commands/checkTabbablePage.d.ts.map +1 -0
- package/dist/commands/checkTabbablePage.js +28 -0
- package/dist/commands/checkTabbablePage.test.d.ts +2 -0
- package/dist/commands/checkTabbablePage.test.d.ts.map +1 -0
- package/dist/commands/checkTabbablePage.test.js +200 -0
- package/dist/commands/checkWebElement.d.ts +7 -0
- package/dist/commands/checkWebElement.d.ts.map +1 -0
- package/dist/commands/checkWebElement.js +52 -0
- package/dist/commands/checkWebElement.test.d.ts +2 -0
- package/dist/commands/checkWebElement.test.d.ts.map +1 -0
- package/dist/commands/checkWebElement.test.js +278 -0
- package/dist/commands/checkWebScreen.d.ts +7 -0
- package/dist/commands/checkWebScreen.d.ts.map +1 -0
- package/dist/commands/checkWebScreen.js +50 -0
- package/dist/commands/checkWebScreen.test.d.ts +2 -0
- package/dist/commands/checkWebScreen.test.d.ts.map +1 -0
- package/dist/commands/checkWebScreen.test.js +227 -0
- package/dist/commands/element.interfaces.d.ts +27 -0
- package/dist/commands/element.interfaces.d.ts.map +1 -0
- package/dist/commands/element.interfaces.js +1 -0
- package/dist/commands/fullPage.interfaces.d.ts +38 -0
- package/dist/commands/fullPage.interfaces.d.ts.map +1 -0
- package/dist/commands/fullPage.interfaces.js +1 -0
- package/dist/commands/save.interfaces.d.ts +27 -0
- package/dist/commands/save.interfaces.d.ts.map +1 -0
- package/dist/commands/save.interfaces.js +1 -0
- package/dist/commands/saveAppElement.d.ts +7 -0
- package/dist/commands/saveAppElement.d.ts.map +1 -0
- package/dist/commands/saveAppElement.js +30 -0
- package/dist/commands/saveAppElement.test.d.ts +2 -0
- package/dist/commands/saveAppElement.test.d.ts.map +1 -0
- package/dist/commands/saveAppElement.test.js +199 -0
- package/dist/commands/saveAppScreen.d.ts +7 -0
- package/dist/commands/saveAppScreen.d.ts.map +1 -0
- package/dist/commands/saveAppScreen.js +43 -0
- package/dist/commands/saveAppScreen.test.d.ts +2 -0
- package/dist/commands/saveAppScreen.test.d.ts.map +1 -0
- package/dist/commands/saveAppScreen.test.js +221 -0
- package/dist/commands/saveElement.d.ts +7 -0
- package/dist/commands/saveElement.d.ts.map +1 -0
- package/dist/commands/saveElement.js +10 -0
- package/dist/commands/saveElement.test.d.ts +2 -0
- package/dist/commands/saveElement.test.d.ts.map +1 -0
- package/dist/commands/saveElement.test.js +62 -0
- package/dist/commands/saveFullPageScreen.d.ts +7 -0
- package/dist/commands/saveFullPageScreen.d.ts.map +1 -0
- package/dist/commands/saveFullPageScreen.js +60 -0
- package/dist/commands/saveFullPageScreen.test.d.ts +2 -0
- package/dist/commands/saveFullPageScreen.test.d.ts.map +1 -0
- package/dist/commands/saveFullPageScreen.test.js +293 -0
- package/dist/commands/saveScreen.d.ts +7 -0
- package/dist/commands/saveScreen.d.ts.map +1 -0
- package/dist/commands/saveScreen.js +10 -0
- package/dist/commands/saveScreen.test.d.ts +2 -0
- package/dist/commands/saveScreen.test.d.ts.map +1 -0
- package/dist/commands/saveScreen.test.js +47 -0
- package/dist/commands/saveTabbablePage.d.ts +7 -0
- package/dist/commands/saveTabbablePage.d.ts.map +1 -0
- package/dist/commands/saveTabbablePage.js +20 -0
- package/dist/commands/saveTabbablePage.test.d.ts +2 -0
- package/dist/commands/saveTabbablePage.test.d.ts.map +1 -0
- package/dist/commands/saveTabbablePage.test.js +74 -0
- package/dist/commands/saveWebElement.d.ts +7 -0
- package/dist/commands/saveWebElement.d.ts.map +1 -0
- package/dist/commands/saveWebElement.js +53 -0
- package/dist/commands/saveWebElement.test.d.ts +2 -0
- package/dist/commands/saveWebElement.test.d.ts.map +1 -0
- package/dist/commands/saveWebElement.test.js +253 -0
- package/dist/commands/saveWebScreen.d.ts +7 -0
- package/dist/commands/saveWebScreen.d.ts.map +1 -0
- package/dist/commands/saveWebScreen.js +48 -0
- package/dist/commands/saveWebScreen.test.d.ts +2 -0
- package/dist/commands/saveWebScreen.test.d.ts.map +1 -0
- package/dist/commands/saveWebScreen.test.js +222 -0
- package/dist/commands/screen.interfaces.d.ts +16 -0
- package/dist/commands/screen.interfaces.d.ts.map +1 -0
- package/dist/commands/screen.interfaces.js +1 -0
- package/dist/commands/tabbable.interfaces.d.ts +29 -0
- package/dist/commands/tabbable.interfaces.d.ts.map +1 -0
- package/dist/commands/tabbable.interfaces.js +1 -0
- package/dist/helpers/afterScreenshot.d.ts +7 -0
- package/dist/helpers/afterScreenshot.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.interfaces.d.ts +46 -0
- package/dist/helpers/afterScreenshot.interfaces.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.interfaces.js +1 -0
- package/dist/helpers/afterScreenshot.js +55 -0
- package/dist/helpers/afterScreenshot.test.d.ts +2 -0
- package/dist/helpers/afterScreenshot.test.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.test.js +241 -0
- package/dist/helpers/beforeScreenshot.d.ts +6 -0
- package/dist/helpers/beforeScreenshot.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.interfaces.d.ts +15 -0
- package/dist/helpers/beforeScreenshot.interfaces.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.interfaces.js +1 -0
- package/dist/helpers/beforeScreenshot.js +79 -0
- package/dist/helpers/beforeScreenshot.test.d.ts +2 -0
- package/dist/helpers/beforeScreenshot.test.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.test.js +261 -0
- package/dist/helpers/compare.interfaces.d.ts +16 -0
- package/dist/helpers/compare.interfaces.d.ts.map +1 -0
- package/dist/helpers/compare.interfaces.js +1 -0
- package/dist/helpers/constants.d.ts +108 -0
- package/dist/helpers/constants.d.ts.map +1 -0
- package/dist/helpers/constants.interfaces.d.ts +30 -0
- package/dist/helpers/constants.interfaces.d.ts.map +1 -0
- package/dist/helpers/constants.interfaces.js +11 -0
- package/dist/helpers/constants.js +436 -0
- package/dist/helpers/options.d.ts +64 -0
- package/dist/helpers/options.d.ts.map +1 -0
- package/dist/helpers/options.interfaces.d.ts +363 -0
- package/dist/helpers/options.interfaces.d.ts.map +1 -0
- package/dist/helpers/options.interfaces.js +1 -0
- package/dist/helpers/options.js +184 -0
- package/dist/helpers/options.test.d.ts +2 -0
- package/dist/helpers/options.test.d.ts.map +1 -0
- package/dist/helpers/options.test.js +428 -0
- package/dist/helpers/utils.d.ts +134 -0
- package/dist/helpers/utils.d.ts.map +1 -0
- package/dist/helpers/utils.interfaces.d.ts +254 -0
- package/dist/helpers/utils.interfaces.d.ts.map +1 -0
- package/dist/helpers/utils.interfaces.js +1 -0
- package/dist/helpers/utils.js +566 -0
- package/dist/helpers/utils.test.d.ts +2 -0
- package/dist/helpers/utils.test.d.ts.map +1 -0
- package/dist/helpers/utils.test.js +900 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/methods/compareReport.interfaces.d.ts +109 -0
- package/dist/methods/compareReport.interfaces.d.ts.map +1 -0
- package/dist/methods/compareReport.interfaces.js +1 -0
- package/dist/methods/createCompareReport.d.ts +7 -0
- package/dist/methods/createCompareReport.d.ts.map +1 -0
- package/dist/methods/createCompareReport.js +61 -0
- package/dist/methods/createCompareReport.test.d.ts +2 -0
- package/dist/methods/createCompareReport.test.d.ts.map +1 -0
- package/dist/methods/createCompareReport.test.js +236 -0
- package/dist/methods/elementPosition.d.ts +18 -0
- package/dist/methods/elementPosition.d.ts.map +1 -0
- package/dist/methods/elementPosition.interfaces.d.ts +14 -0
- package/dist/methods/elementPosition.interfaces.d.ts.map +1 -0
- package/dist/methods/elementPosition.interfaces.js +1 -0
- package/dist/methods/elementPosition.js +34 -0
- package/dist/methods/images.d.ts +69 -0
- package/dist/methods/images.d.ts.map +1 -0
- package/dist/methods/images.executeImageCompare.test.d.ts +2 -0
- package/dist/methods/images.executeImageCompare.test.d.ts.map +1 -0
- package/dist/methods/images.executeImageCompare.test.js +770 -0
- package/dist/methods/images.interfaces.d.ts +214 -0
- package/dist/methods/images.interfaces.d.ts.map +1 -0
- package/dist/methods/images.interfaces.js +1 -0
- package/dist/methods/images.js +428 -0
- package/dist/methods/images.test.d.ts +2 -0
- package/dist/methods/images.test.d.ts.map +1 -0
- package/dist/methods/images.test.js +1465 -0
- package/dist/methods/instanceData.d.ts +6 -0
- package/dist/methods/instanceData.d.ts.map +1 -0
- package/dist/methods/instanceData.interfaces.d.ts +57 -0
- package/dist/methods/instanceData.interfaces.d.ts.map +1 -0
- package/dist/methods/instanceData.interfaces.js +1 -0
- package/dist/methods/instanceData.js +42 -0
- package/dist/methods/instanceData.test.d.ts +2 -0
- package/dist/methods/instanceData.test.d.ts.map +1 -0
- package/dist/methods/instanceData.test.js +224 -0
- package/dist/methods/processDiffPixels.d.ts +59 -0
- package/dist/methods/processDiffPixels.d.ts.map +1 -0
- package/dist/methods/processDiffPixels.js +242 -0
- package/dist/methods/processDiffPixels.test.d.ts +2 -0
- package/dist/methods/processDiffPixels.test.d.ts.map +1 -0
- package/dist/methods/processDiffPixels.test.js +122 -0
- package/dist/methods/rectangles.d.ts +51 -0
- package/dist/methods/rectangles.d.ts.map +1 -0
- package/dist/methods/rectangles.interfaces.d.ts +146 -0
- package/dist/methods/rectangles.interfaces.d.ts.map +1 -0
- package/dist/methods/rectangles.interfaces.js +1 -0
- package/dist/methods/rectangles.js +266 -0
- package/dist/methods/rectangles.test.d.ts +2 -0
- package/dist/methods/rectangles.test.d.ts.map +1 -0
- package/dist/methods/rectangles.test.js +853 -0
- package/dist/methods/screenshots.d.ts +37 -0
- package/dist/methods/screenshots.d.ts.map +1 -0
- package/dist/methods/screenshots.interfaces.d.ts +203 -0
- package/dist/methods/screenshots.interfaces.d.ts.map +1 -0
- package/dist/methods/screenshots.interfaces.js +1 -0
- package/dist/methods/screenshots.js +394 -0
- package/dist/methods/screenshots.test.d.ts +2 -0
- package/dist/methods/screenshots.test.d.ts.map +1 -0
- package/dist/methods/screenshots.test.js +656 -0
- package/dist/methods/takeElementScreenshots.d.ts +3 -0
- package/dist/methods/takeElementScreenshots.d.ts.map +1 -0
- package/dist/methods/takeElementScreenshots.js +104 -0
- package/dist/methods/takeElementScreenshots.test.d.ts +2 -0
- package/dist/methods/takeElementScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeElementScreenshots.test.js +314 -0
- package/dist/methods/takeFullPageScreenshots.d.ts +3 -0
- package/dist/methods/takeFullPageScreenshots.d.ts.map +1 -0
- package/dist/methods/takeFullPageScreenshots.js +56 -0
- package/dist/methods/takeFullPageScreenshots.test.d.ts +2 -0
- package/dist/methods/takeFullPageScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeFullPageScreenshots.test.js +72 -0
- package/dist/methods/takeWebScreenshots.d.ts +3 -0
- package/dist/methods/takeWebScreenshots.d.ts.map +1 -0
- package/dist/methods/takeWebScreenshots.js +41 -0
- package/dist/methods/takeWebScreenshots.test.d.ts +2 -0
- package/dist/methods/takeWebScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeWebScreenshots.test.js +149 -0
- package/dist/mocks/image.d.ts +4 -0
- package/dist/mocks/image.d.ts.map +1 -0
- package/dist/mocks/image.js +3 -0
- package/dist/mocks/mocks.d.ts +745 -0
- package/dist/mocks/mocks.d.ts.map +1 -0
- package/dist/mocks/mocks.js +392 -0
- package/dist/resemble/compare.interfaces.d.ts +136 -0
- package/dist/resemble/compare.interfaces.d.ts.map +1 -0
- package/dist/resemble/compare.interfaces.js +1 -0
- package/dist/resemble/compareImages.d.ts +3 -0
- package/dist/resemble/compareImages.d.ts.map +1 -0
- package/dist/resemble/compareImages.js +21 -0
- package/dist/resemble/resemble.jimp.cjs +981 -0
- package/dist/resemble/resemble.jimp.d.cts +46 -0
- package/dist/resemble/resemble.jimp.d.cts.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import logger from '@wdio/logger';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { DESKTOP, NOT_KNOWN } from './constants.js';
|
|
4
|
+
import { mkdirSync } from 'node:fs';
|
|
5
|
+
import { checkMetaTag } from '../clientSideScripts/checkMetaTag.js';
|
|
6
|
+
import { injectWebviewOverlay } from '../clientSideScripts/injectWebviewOverlay.js';
|
|
7
|
+
import { getMobileWebviewClickAndDimensions } from '../clientSideScripts/getMobileWebviewClickAndDimensions.js';
|
|
8
|
+
const log = logger('@wdio/visual-service:@wdio/image-comparison-core:utils');
|
|
9
|
+
/**
|
|
10
|
+
* Get and create a folder
|
|
11
|
+
*/
|
|
12
|
+
export function getAndCreatePath(folder, options) {
|
|
13
|
+
const { browserName = NOT_KNOWN, deviceName = NOT_KNOWN, isMobile, savePerInstance, } = options;
|
|
14
|
+
const instanceName = (isMobile ? deviceName : `${DESKTOP}_${browserName}`).replace(/ /g, '_');
|
|
15
|
+
const subFolder = savePerInstance ? instanceName : '';
|
|
16
|
+
const folderName = join(folder, subFolder);
|
|
17
|
+
mkdirSync(folderName, { recursive: true });
|
|
18
|
+
return folderName;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Format the filename
|
|
22
|
+
*/
|
|
23
|
+
export function formatFileName(options) {
|
|
24
|
+
const { browserName = NOT_KNOWN, browserVersion = NOT_KNOWN, deviceName = NOT_KNOWN, devicePixelRatio, isMobile, screenHeight, screenWidth, outerHeight = screenHeight, outerWidth = screenWidth, isTestInBrowser, name, platformName, platformVersion, tag, } = options;
|
|
25
|
+
const defaults = {
|
|
26
|
+
browserName,
|
|
27
|
+
browserVersion,
|
|
28
|
+
deviceName,
|
|
29
|
+
dpr: devicePixelRatio,
|
|
30
|
+
height: isMobile ? screenHeight : outerHeight,
|
|
31
|
+
logName: options.logName,
|
|
32
|
+
mobile: isMobile && isTestInBrowser ? browserName : isMobile ? 'app' : NOT_KNOWN,
|
|
33
|
+
name: name,
|
|
34
|
+
platformName,
|
|
35
|
+
platformVersion,
|
|
36
|
+
tag,
|
|
37
|
+
width: isMobile ? screenWidth : outerWidth,
|
|
38
|
+
};
|
|
39
|
+
let fileName = options.formatImageName;
|
|
40
|
+
Object.keys(defaults).forEach((value) => {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
// @TODO: Fix this in a proper way
|
|
43
|
+
fileName = fileName.replace(`{${value}}`, defaults[value]);
|
|
44
|
+
});
|
|
45
|
+
return `${fileName.replace(/ /g, '_')}.png`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the test is executed in a browser
|
|
49
|
+
* checking for app is not sufficient because different vendors have different
|
|
50
|
+
* custom names and or solutions for the app
|
|
51
|
+
*/
|
|
52
|
+
export function checkTestInBrowser(browserName) {
|
|
53
|
+
return browserName !== '';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Checks if the test is executed in a browser on a mobile phone
|
|
57
|
+
*/
|
|
58
|
+
export function checkTestInMobileBrowser(isMobile, browserName) {
|
|
59
|
+
return isMobile && checkTestInBrowser(browserName);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Checks if this is a native webscreenshot on android
|
|
63
|
+
*/
|
|
64
|
+
export function checkAndroidNativeWebScreenshot(isAndroid, nativeWebscreenshot) {
|
|
65
|
+
return (isAndroid && nativeWebscreenshot) || false;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Checks if this is an Android chromedriver screenshot
|
|
69
|
+
*/
|
|
70
|
+
export function checkAndroidChromeDriverScreenshot(isAndroid, nativeWebScreenshot) {
|
|
71
|
+
return isAndroid && !checkAndroidNativeWebScreenshot(isAndroid, nativeWebScreenshot);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the address bar shadow padding. This is only needed for Android native webscreenshot and iOS
|
|
75
|
+
*/
|
|
76
|
+
export function getAddressBarShadowPadding(options) {
|
|
77
|
+
const { browserName, isAndroid, isIOS, isMobile, nativeWebScreenshot, addressBarShadowPadding, addShadowPadding } = options;
|
|
78
|
+
const isTestInMobileBrowser = checkTestInMobileBrowser(isMobile, browserName);
|
|
79
|
+
const isAndroidNativeWebScreenshot = checkAndroidNativeWebScreenshot(isAndroid, nativeWebScreenshot);
|
|
80
|
+
return isTestInMobileBrowser && ((isAndroidNativeWebScreenshot && isAndroid) || isIOS) && addShadowPadding
|
|
81
|
+
? addressBarShadowPadding
|
|
82
|
+
: 0;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the tool bar shadow padding. Add some extra padding for iOS when we have a home bar
|
|
86
|
+
*/
|
|
87
|
+
export function getToolBarShadowPadding(options) {
|
|
88
|
+
const { isMobile, browserName, isIOS, toolBarShadowPadding, addShadowPadding } = options;
|
|
89
|
+
return checkTestInMobileBrowser(isMobile, browserName) && addShadowPadding
|
|
90
|
+
? isIOS
|
|
91
|
+
? // The 9 extra are for iOS home bar for iPhones with a notch or iPads with a home bar
|
|
92
|
+
toolBarShadowPadding + 9
|
|
93
|
+
: toolBarShadowPadding
|
|
94
|
+
: 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Calculate the data based on the device pixel ratio
|
|
98
|
+
*/
|
|
99
|
+
export function calculateDprData(data, devicePixelRatio) {
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
// @TODO: need to figure this one out
|
|
102
|
+
Object.keys(data).map((key) => (data[key] = typeof data[key] === 'number' ? Math.round(data[key] * devicePixelRatio) : data[key]));
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Wait for an amount of milliseconds
|
|
107
|
+
*/
|
|
108
|
+
export async function waitFor(milliseconds) {
|
|
109
|
+
/* istanbul ignore next */
|
|
110
|
+
return new Promise((resolve) => setTimeout(() => resolve(), milliseconds));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the size of a screenshot in pixels without the device pixel ratio
|
|
114
|
+
*/
|
|
115
|
+
export function getBase64ScreenshotSize(screenshot, devicePixelRation = 1) {
|
|
116
|
+
return {
|
|
117
|
+
height: Math.round(Buffer.from(screenshot, 'base64').readUInt32BE(20) / devicePixelRation),
|
|
118
|
+
width: Math.round(Buffer.from(screenshot, 'base64').readUInt32BE(16) / devicePixelRation),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get the device pixel ratio
|
|
123
|
+
*/
|
|
124
|
+
export function getDevicePixelRatio(screenshot, deviceScreenSize) {
|
|
125
|
+
const screenshotSize = getBase64ScreenshotSize(screenshot);
|
|
126
|
+
const devicePixelRatio = screenshotSize.width / deviceScreenSize.width;
|
|
127
|
+
return Math.round(devicePixelRatio);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get the iOS bezel image names
|
|
131
|
+
*/
|
|
132
|
+
export function getIosBezelImageNames(normalizedDeviceName) {
|
|
133
|
+
let topImageName, bottomImageName;
|
|
134
|
+
switch (normalizedDeviceName) {
|
|
135
|
+
case 'iphonex':
|
|
136
|
+
topImageName = 'iphonex.iphonexs.iphone11pro-top';
|
|
137
|
+
bottomImageName = 'iphonex.iphonexs.iphone11pro-bottom';
|
|
138
|
+
break;
|
|
139
|
+
case 'iphonexs':
|
|
140
|
+
topImageName = 'iphonex.iphonexs.iphone11pro-top';
|
|
141
|
+
bottomImageName = 'iphonex.iphonexs.iphone11pro-bottom';
|
|
142
|
+
break;
|
|
143
|
+
case 'iphonexsmax':
|
|
144
|
+
topImageName = 'iphonexsmax-top';
|
|
145
|
+
bottomImageName = 'iphonexsmax-bottom';
|
|
146
|
+
break;
|
|
147
|
+
case 'iphonexr':
|
|
148
|
+
topImageName = 'iphonexr.iphone11-top';
|
|
149
|
+
bottomImageName = 'iphonexr.iphone11-bottom';
|
|
150
|
+
break;
|
|
151
|
+
case 'iphone11':
|
|
152
|
+
topImageName = 'iphonexr.iphone11-top';
|
|
153
|
+
bottomImageName = 'iphonexr.iphone11-bottom';
|
|
154
|
+
break;
|
|
155
|
+
case 'iphone11pro':
|
|
156
|
+
topImageName = 'iphonex.iphonexs.iphone11pro-top';
|
|
157
|
+
bottomImageName = 'iphonex.iphonexs.iphone11pro-bottom';
|
|
158
|
+
break;
|
|
159
|
+
case 'iphone11promax':
|
|
160
|
+
topImageName = 'iphone11promax-top';
|
|
161
|
+
bottomImageName = 'iphone11promax-bottom';
|
|
162
|
+
break;
|
|
163
|
+
case 'iphone12':
|
|
164
|
+
topImageName = 'iphone12.iphone12pro-top';
|
|
165
|
+
bottomImageName = 'iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom';
|
|
166
|
+
break;
|
|
167
|
+
case 'iphone12mini':
|
|
168
|
+
topImageName = 'iphone12mini-top';
|
|
169
|
+
bottomImageName = 'iphone12mini.iphone13mini-bottom';
|
|
170
|
+
break;
|
|
171
|
+
case 'iphone12pro':
|
|
172
|
+
topImageName = 'iphone12.iphone12pro-top';
|
|
173
|
+
bottomImageName = 'iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom';
|
|
174
|
+
break;
|
|
175
|
+
case 'iphone12promax':
|
|
176
|
+
topImageName = 'iphone12promax-top';
|
|
177
|
+
bottomImageName = 'iphone12promax.iphone13promax.iphone14plus-bottom';
|
|
178
|
+
break;
|
|
179
|
+
case 'iphone13':
|
|
180
|
+
topImageName = 'iphone13.iphone13pro.iphone14-top';
|
|
181
|
+
bottomImageName = 'iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom';
|
|
182
|
+
break;
|
|
183
|
+
case 'iphone13mini':
|
|
184
|
+
topImageName = 'iphone13mini-top';
|
|
185
|
+
bottomImageName = 'iphone12mini.iphone13mini-bottom';
|
|
186
|
+
break;
|
|
187
|
+
case 'iphone13pro':
|
|
188
|
+
topImageName = 'iphone13.iphone13pro.iphone14-top';
|
|
189
|
+
bottomImageName = 'iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom';
|
|
190
|
+
break;
|
|
191
|
+
case 'iphone13promax':
|
|
192
|
+
topImageName = 'iphone13promax.iphone14plus-top';
|
|
193
|
+
bottomImageName = 'iphone12promax.iphone13promax.iphone14plus-bottom';
|
|
194
|
+
break;
|
|
195
|
+
case 'iphone14':
|
|
196
|
+
topImageName = 'iphone13.iphone13pro.iphone14-top';
|
|
197
|
+
bottomImageName = 'iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom';
|
|
198
|
+
break;
|
|
199
|
+
case 'iphone14plus':
|
|
200
|
+
topImageName = 'iphone13promax.iphone14plus-top';
|
|
201
|
+
bottomImageName = 'iphone12promax.iphone13promax.iphone14plus-bottom';
|
|
202
|
+
break;
|
|
203
|
+
case 'iphone14pro':
|
|
204
|
+
topImageName = 'iphone14pro-top';
|
|
205
|
+
bottomImageName = 'iphone14pro-bottom';
|
|
206
|
+
break;
|
|
207
|
+
case 'iphone14promax':
|
|
208
|
+
topImageName = 'iphone14promax-top';
|
|
209
|
+
bottomImageName = 'iphone14promax-bottom';
|
|
210
|
+
break;
|
|
211
|
+
case 'iphone15':
|
|
212
|
+
topImageName = 'iphone15-top';
|
|
213
|
+
bottomImageName = 'iphone15-bottom';
|
|
214
|
+
break;
|
|
215
|
+
// iPad
|
|
216
|
+
case 'ipadmini':
|
|
217
|
+
topImageName = 'ipadmini6th-top';
|
|
218
|
+
bottomImageName = 'ipadmini6th-bottom';
|
|
219
|
+
break;
|
|
220
|
+
case 'ipadair':
|
|
221
|
+
topImageName = 'ipadair4th.ipadair5th-top';
|
|
222
|
+
bottomImageName = 'ipadair4th.ipadair5th-bottom';
|
|
223
|
+
break;
|
|
224
|
+
case 'ipadpro11':
|
|
225
|
+
topImageName = 'ipadpro11-top';
|
|
226
|
+
bottomImageName = 'ipadpro11-bottom';
|
|
227
|
+
break;
|
|
228
|
+
case 'ipadpro129':
|
|
229
|
+
topImageName = 'ipadpro129-top';
|
|
230
|
+
bottomImageName = 'ipadpro129-bottom';
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
if (!topImageName || !bottomImageName) {
|
|
234
|
+
throw new Error(`Could not find iOS bezel images for device ${normalizedDeviceName}`);
|
|
235
|
+
}
|
|
236
|
+
return { topImageName, bottomImageName };
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate that the item is an object
|
|
240
|
+
*/
|
|
241
|
+
export function isObject(item) {
|
|
242
|
+
return (typeof item === 'object' && item !== null) || typeof item === 'function';
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Validate if it's storybook
|
|
246
|
+
*/
|
|
247
|
+
export function isStorybook() {
|
|
248
|
+
return process.argv.includes('--storybook');
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Check if we want to update baseline images
|
|
252
|
+
*/
|
|
253
|
+
export function updateVisualBaseline() {
|
|
254
|
+
return process.argv.includes('--update-visual-baseline');
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Log the deprecated root compareOptions (at `ClassOptions` level)
|
|
258
|
+
* and returns non-undefined ones to be added back to the config
|
|
259
|
+
*/
|
|
260
|
+
export function logAllDeprecatedCompareOptions(options) {
|
|
261
|
+
const deprecatedKeys = [
|
|
262
|
+
'blockOutSideBar',
|
|
263
|
+
'blockOutStatusBar',
|
|
264
|
+
'blockOutToolBar',
|
|
265
|
+
'createJsonReportFiles',
|
|
266
|
+
'diffPixelBoundingBoxProximity',
|
|
267
|
+
'ignoreAlpha',
|
|
268
|
+
'ignoreAntialiasing',
|
|
269
|
+
'ignoreColors',
|
|
270
|
+
'ignoreLess',
|
|
271
|
+
'ignoreNothing',
|
|
272
|
+
'rawMisMatchPercentage',
|
|
273
|
+
'returnAllCompareData',
|
|
274
|
+
'saveAboveTolerance',
|
|
275
|
+
'scaleImagesToSameSize',
|
|
276
|
+
];
|
|
277
|
+
const foundDeprecatedKeys = deprecatedKeys.filter((key) => key in options);
|
|
278
|
+
if (foundDeprecatedKeys.length > 0) {
|
|
279
|
+
log.warn('The following root-level compare options are deprecated and should be moved under \'compareOptions\':\n' +
|
|
280
|
+
foundDeprecatedKeys.map((k) => ` - ${k}`).join('\n') + '\nIn the next major version, these options will be removed from the root level and only be available under \'compareOptions\'');
|
|
281
|
+
}
|
|
282
|
+
return foundDeprecatedKeys.reduce((acc, key) => {
|
|
283
|
+
if (options[key] !== undefined) {
|
|
284
|
+
acc[key] = options[key];
|
|
285
|
+
}
|
|
286
|
+
return acc;
|
|
287
|
+
}, {});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Get the mobile screen size, this is different for native and webview
|
|
291
|
+
*/
|
|
292
|
+
export async function getMobileScreenSize({ browserInstance, isIOS, isNativeContext, }) {
|
|
293
|
+
let height = 0, width = 0;
|
|
294
|
+
const isLandscapeByOrientation = (await browserInstance.getOrientation()).toUpperCase() === 'LANDSCAPE';
|
|
295
|
+
try {
|
|
296
|
+
if (isIOS) {
|
|
297
|
+
({ screenSize: { height, width } } = (await browserInstance.execute('mobile: deviceScreenInfo')));
|
|
298
|
+
// It's Android
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const { realDisplaySize } = (await browserInstance.execute('mobile: deviceInfo'));
|
|
302
|
+
if (!realDisplaySize || !/^\d+x\d+$/.test(realDisplaySize)) {
|
|
303
|
+
throw new Error(`Invalid realDisplaySize format. Expected 'widthxheight', got "${realDisplaySize}"`);
|
|
304
|
+
}
|
|
305
|
+
[width, height] = realDisplaySize.split('x').map(Number);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
log.warn('Error getting mobile screen size:\n', error, `\nFalling back to ${isNativeContext ?
|
|
310
|
+
'`getWindowSize()` which might not be as accurate' :
|
|
311
|
+
'window.screen.height and window.screen.width'}`);
|
|
312
|
+
if (isNativeContext) {
|
|
313
|
+
({ height, width } = await browserInstance.getWindowSize());
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
// This is a fallback and not 100% accurate, but we need to have something =)
|
|
317
|
+
({ height, width } = await browserInstance.execute(() => {
|
|
318
|
+
const { height, width } = window.screen;
|
|
319
|
+
return { height, width };
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// There are issues where the landscape mode by orientation is not the same as the landscape mode by value
|
|
324
|
+
// So we need to check and fix this
|
|
325
|
+
const isLandscapeByValue = width > height;
|
|
326
|
+
if (isLandscapeByOrientation !== isLandscapeByValue) {
|
|
327
|
+
[height, width] = [width, height];
|
|
328
|
+
}
|
|
329
|
+
return { height, width };
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Load a base64 HTML page in the browser
|
|
333
|
+
*/
|
|
334
|
+
export async function loadBase64Html({ browserInstance, isIOS }) {
|
|
335
|
+
const htmlContent = `
|
|
336
|
+
<html>
|
|
337
|
+
<head>
|
|
338
|
+
<title>Base64 Page</title>
|
|
339
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
340
|
+
<script>
|
|
341
|
+
document.addEventListener("DOMContentLoaded", function() {
|
|
342
|
+
// Force correct viewport settings
|
|
343
|
+
const meta = document.querySelector("meta[name='viewport']");
|
|
344
|
+
if (!meta) {
|
|
345
|
+
const newMeta = document.createElement("meta");
|
|
346
|
+
newMeta.name = "viewport";
|
|
347
|
+
newMeta.content = "width=device-width, initial-scale=1";
|
|
348
|
+
document.head.appendChild(newMeta);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
</script>
|
|
352
|
+
</head>
|
|
353
|
+
<body>
|
|
354
|
+
<h1>Hello from Base64!</h1>
|
|
355
|
+
<p>This page was loaded without visiting a URL.</p>
|
|
356
|
+
</body>
|
|
357
|
+
</html>`;
|
|
358
|
+
await browserInstance.execute((htmlContent) => {
|
|
359
|
+
const blob = new Blob([htmlContent], { type: 'text/html' });
|
|
360
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
361
|
+
window.location.href = blobUrl;
|
|
362
|
+
}, htmlContent);
|
|
363
|
+
if (isIOS) {
|
|
364
|
+
await browserInstance.execute(checkMetaTag);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Execute a native click
|
|
369
|
+
*/
|
|
370
|
+
export async function executeNativeClick({ browserInstance, isIOS, x, y }) {
|
|
371
|
+
if (isIOS) {
|
|
372
|
+
return browserInstance.execute('mobile: tap', { x, y });
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
// The `clickGesture` is not working on Appium 1, only on Appium 2
|
|
376
|
+
await browserInstance.execute('mobile: clickGesture', { x, y });
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
if (error instanceof Error &&
|
|
380
|
+
/WebDriverError: Unknown mobile command.*?(clickGesture|tap)/i.test(error.message)) {
|
|
381
|
+
log.warn('Error executing `clickGesture`, falling back to `doubleClickGesture`. This likely means you are using Appium 1. Is this intentional?');
|
|
382
|
+
await browserInstance.execute('mobile: doubleClickGesture', { x, y });
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get the mobile viewport position, we determine this by:
|
|
391
|
+
* 1. Loading a base64 HTML page
|
|
392
|
+
* 2. Injecting an overlay on top of the webview with an event listener that stores the click position in the webview
|
|
393
|
+
* 3. Clicking on the overlay in the center of the screen with a native click
|
|
394
|
+
* 4. Getting the data from the overlay and removing it
|
|
395
|
+
* 5. Calculating the position of the viewport based on the click position of the native click vs the overlay
|
|
396
|
+
* 6. Returning the calculated values
|
|
397
|
+
*/
|
|
398
|
+
export async function getMobileViewPortPosition({ browserInstance, initialDeviceRectangles, isAndroid, isIOS, isNativeContext, nativeWebScreenshot, screenHeight, screenWidth, }) {
|
|
399
|
+
if (!isNativeContext && (isIOS || (isAndroid && nativeWebScreenshot))) {
|
|
400
|
+
const currentUrl = await browserInstance.getUrl();
|
|
401
|
+
// 1. Load a base64 HTML page
|
|
402
|
+
await loadBase64Html({ browserInstance, isIOS });
|
|
403
|
+
// 2. Inject an overlay on top of the webview with an event listener that stores the click position in the webview
|
|
404
|
+
await browserInstance.execute(injectWebviewOverlay, isAndroid);
|
|
405
|
+
// 3. Click on the overlay in the center of the screen with a native click
|
|
406
|
+
const nativeClickX = screenWidth / 2;
|
|
407
|
+
const nativeClickY = screenHeight / 2;
|
|
408
|
+
await executeNativeClick({ browserInstance, isIOS, x: nativeClickX, y: nativeClickY });
|
|
409
|
+
// We need to wait a bit here, otherwise the click is not registered
|
|
410
|
+
await waitFor(100);
|
|
411
|
+
// 4a. Get the data from the overlay and remove it
|
|
412
|
+
const { y, x, width, height } = await browserInstance.execute(getMobileWebviewClickAndDimensions, '[data-test="ics-overlay"]');
|
|
413
|
+
// 4.b reset the url
|
|
414
|
+
await browserInstance.url(currentUrl);
|
|
415
|
+
// 5. Calculate the position of the viewport based on the click position of the native click vs the overlay
|
|
416
|
+
const viewportTop = Math.max(0, Math.round(nativeClickY - y));
|
|
417
|
+
const viewportLeft = Math.max(0, Math.round(nativeClickX - x));
|
|
418
|
+
const statusBarAndAddressBarHeight = Math.max(0, Math.round(viewportTop));
|
|
419
|
+
const bottomBarHeight = Math.max(0, Math.round(screenHeight - (viewportTop + height)));
|
|
420
|
+
const leftSidePaddingWidth = Math.max(0, Math.round(viewportLeft));
|
|
421
|
+
const rightSidePaddingWidth = Math.max(0, Math.round(screenWidth - (viewportLeft + width)));
|
|
422
|
+
const deviceRectangles = {
|
|
423
|
+
...initialDeviceRectangles,
|
|
424
|
+
bottomBar: { y: viewportTop + height, x: 0, width: screenWidth, height: bottomBarHeight },
|
|
425
|
+
leftSidePadding: { y: viewportTop, x: 0, width: leftSidePaddingWidth, height: height },
|
|
426
|
+
rightSidePadding: { y: viewportTop, x: viewportLeft + width, width: rightSidePaddingWidth, height: height },
|
|
427
|
+
screenSize: { height: screenHeight, width: screenWidth },
|
|
428
|
+
statusBarAndAddressBar: { y: 0, x: 0, width: screenWidth, height: statusBarAndAddressBarHeight },
|
|
429
|
+
viewport: { y: viewportTop, x: viewportLeft, width: width, height: height },
|
|
430
|
+
};
|
|
431
|
+
return deviceRectangles;
|
|
432
|
+
}
|
|
433
|
+
// No WebView detected, return empty values
|
|
434
|
+
return initialDeviceRectangles;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Get the value of a method or the default value
|
|
438
|
+
*/
|
|
439
|
+
export function getMethodOrWicOption(method, wic, key) {
|
|
440
|
+
return method?.[key] ?? wic[key];
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Determine if the Bidi screenshot can be used
|
|
444
|
+
*/
|
|
445
|
+
export function canUseBidiScreenshot(browserInstance) {
|
|
446
|
+
const { isBidi } = browserInstance;
|
|
447
|
+
const hasBrowsingContextCaptureScreenshot = typeof browserInstance.browsingContextCaptureScreenshot === 'function';
|
|
448
|
+
const hasGetWindowHandle = typeof browserInstance.getWindowHandle === 'function';
|
|
449
|
+
return isBidi && hasBrowsingContextCaptureScreenshot && hasGetWindowHandle;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Helper function to safely check boolean properties with proper defaults
|
|
453
|
+
*/
|
|
454
|
+
export function getBooleanOption(options, key, defaultValue) {
|
|
455
|
+
return Object.prototype.hasOwnProperty.call(options, key) && options[key] !== undefined ? Boolean(options[key]) : defaultValue;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Helper function to create conditional property objects for cleaner spread operations
|
|
459
|
+
*/
|
|
460
|
+
export function createConditionalProperty(condition, key, value) {
|
|
461
|
+
return condition ? { [key]: value } : {};
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Check if resizeDimensions has any non-zero values (indicating it's been changed from default)
|
|
465
|
+
*/
|
|
466
|
+
export function hasResizeDimensions(resizeDimensions) {
|
|
467
|
+
return resizeDimensions && Object.values(resizeDimensions).some(value => value !== 0);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Extracts common variables used across all check methods to reduce duplication
|
|
471
|
+
*/
|
|
472
|
+
export function extractCommonCheckVariables(options) {
|
|
473
|
+
const { folders, instanceData, wicOptions } = options;
|
|
474
|
+
return {
|
|
475
|
+
// Folders
|
|
476
|
+
actualFolder: folders.actualFolder,
|
|
477
|
+
baselineFolder: folders.baselineFolder,
|
|
478
|
+
diffFolder: folders.diffFolder,
|
|
479
|
+
// Instance data
|
|
480
|
+
browserName: instanceData.browserName,
|
|
481
|
+
deviceName: instanceData.deviceName,
|
|
482
|
+
deviceRectangles: instanceData.deviceRectangles,
|
|
483
|
+
isAndroid: instanceData.isAndroid,
|
|
484
|
+
isMobile: instanceData.isMobile,
|
|
485
|
+
isAndroidNativeWebScreenshot: instanceData.nativeWebScreenshot,
|
|
486
|
+
// Optional instance data
|
|
487
|
+
...(instanceData.platformName && { platformName: instanceData.platformName }),
|
|
488
|
+
...(instanceData.isIOS !== undefined && { isIOS: instanceData.isIOS }),
|
|
489
|
+
// WIC options
|
|
490
|
+
autoSaveBaseline: wicOptions.autoSaveBaseline,
|
|
491
|
+
savePerInstance: wicOptions.savePerInstance,
|
|
492
|
+
// Optional WIC options
|
|
493
|
+
...(wicOptions.isHybridApp !== undefined && { isHybridApp: wicOptions.isHybridApp }),
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Builds folder options object used across all check methods to reduce duplication
|
|
498
|
+
*/
|
|
499
|
+
export function buildFolderOptions(options) {
|
|
500
|
+
const { commonCheckVariables } = options;
|
|
501
|
+
return {
|
|
502
|
+
autoSaveBaseline: commonCheckVariables.autoSaveBaseline,
|
|
503
|
+
actualFolder: commonCheckVariables.actualFolder,
|
|
504
|
+
baselineFolder: commonCheckVariables.baselineFolder,
|
|
505
|
+
diffFolder: commonCheckVariables.diffFolder,
|
|
506
|
+
browserName: commonCheckVariables.browserName,
|
|
507
|
+
deviceName: commonCheckVariables.deviceName,
|
|
508
|
+
isMobile: commonCheckVariables.isMobile,
|
|
509
|
+
savePerInstance: commonCheckVariables.savePerInstance,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Builds base execute compare options object used across all check methods to reduce duplication
|
|
514
|
+
*/
|
|
515
|
+
export function buildBaseExecuteCompareOptions(options) {
|
|
516
|
+
const { commonCheckVariables, wicCompareOptions, methodCompareOptions, devicePixelRatio, fileName, isElementScreenshot = false, additionalProperties = {} } = options;
|
|
517
|
+
// For element screenshots, override blockOut options to false
|
|
518
|
+
const processedWicOptions = isElementScreenshot ? {
|
|
519
|
+
...wicCompareOptions,
|
|
520
|
+
blockOutSideBar: false,
|
|
521
|
+
blockOutStatusBar: false,
|
|
522
|
+
blockOutToolBar: false,
|
|
523
|
+
} : wicCompareOptions;
|
|
524
|
+
const baseOptions = {
|
|
525
|
+
compareOptions: {
|
|
526
|
+
wic: processedWicOptions,
|
|
527
|
+
method: methodCompareOptions,
|
|
528
|
+
},
|
|
529
|
+
devicePixelRatio,
|
|
530
|
+
deviceRectangles: commonCheckVariables.deviceRectangles,
|
|
531
|
+
fileName,
|
|
532
|
+
folderOptions: buildFolderOptions({ commonCheckVariables }),
|
|
533
|
+
isAndroid: commonCheckVariables.isAndroid,
|
|
534
|
+
isAndroidNativeWebScreenshot: commonCheckVariables.isAndroidNativeWebScreenshot,
|
|
535
|
+
// Add optional properties from commonCheckVariables if they exist
|
|
536
|
+
...(commonCheckVariables.platformName && { platformName: commonCheckVariables.platformName }),
|
|
537
|
+
...(commonCheckVariables.isIOS !== undefined && { isIOS: commonCheckVariables.isIOS }),
|
|
538
|
+
...(commonCheckVariables.isHybridApp !== undefined && { isHybridApp: commonCheckVariables.isHybridApp }),
|
|
539
|
+
};
|
|
540
|
+
// Add any additional properties
|
|
541
|
+
return {
|
|
542
|
+
...baseOptions,
|
|
543
|
+
...additionalProperties,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Prepare all file paths needed for image comparison
|
|
548
|
+
*/
|
|
549
|
+
export function prepareComparisonFilePaths(options) {
|
|
550
|
+
const { actualFolder, baselineFolder, diffFolder, browserName, deviceName, isMobile, savePerInstance, fileName } = options;
|
|
551
|
+
const createFolderOptions = { browserName, deviceName, isMobile, savePerInstance };
|
|
552
|
+
const actualFolderPath = getAndCreatePath(actualFolder, createFolderOptions);
|
|
553
|
+
const baselineFolderPath = getAndCreatePath(baselineFolder, createFolderOptions);
|
|
554
|
+
const diffFolderPath = getAndCreatePath(diffFolder, createFolderOptions);
|
|
555
|
+
const actualFilePath = join(actualFolderPath, fileName);
|
|
556
|
+
const baselineFilePath = join(baselineFolderPath, fileName);
|
|
557
|
+
const diffFilePath = join(diffFolderPath, fileName);
|
|
558
|
+
return {
|
|
559
|
+
actualFolderPath,
|
|
560
|
+
baselineFolderPath,
|
|
561
|
+
diffFolderPath,
|
|
562
|
+
actualFilePath,
|
|
563
|
+
baselineFilePath,
|
|
564
|
+
diffFilePath
|
|
565
|
+
};
|
|
566
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/helpers/utils.test.ts"],"names":[],"mappings":""}
|