@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,37 @@
|
|
|
1
|
+
import type { FullPageScreenshotOptions, FullPageScreenshotNativeMobileOptions, FullPageScreenshotsData, TakeWebElementScreenshot, TakeWebElementScreenshotData } from './screenshots.interfaces.js';
|
|
2
|
+
import type { RectanglesOutput } from './rectangles.interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Take a full page screenshots for desktop / iOS / Android
|
|
5
|
+
*/
|
|
6
|
+
export declare function getMobileFullPageNativeWebScreenshotsData(browserInstance: WebdriverIO.Browser, options: FullPageScreenshotNativeMobileOptions): Promise<FullPageScreenshotsData>;
|
|
7
|
+
/**
|
|
8
|
+
* Take a full page screenshot for Android with Chromedriver
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAndroidChromeDriverFullPageScreenshotsData(browserInstance: WebdriverIO.Browser, options: FullPageScreenshotOptions): Promise<FullPageScreenshotsData>;
|
|
11
|
+
/**
|
|
12
|
+
* Take a full page screenshots
|
|
13
|
+
*/
|
|
14
|
+
export declare function getDesktopFullPageScreenshotsData(browserInstance: WebdriverIO.Browser, options: FullPageScreenshotOptions): Promise<FullPageScreenshotsData>;
|
|
15
|
+
/**
|
|
16
|
+
* Take a screenshot
|
|
17
|
+
*/
|
|
18
|
+
export declare function takeBase64Screenshot(browserInstance: WebdriverIO.Browser): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Take a bidi screenshot
|
|
21
|
+
*/
|
|
22
|
+
export declare function takeBase64BiDiScreenshot({ browserInstance, origin, clip, }: {
|
|
23
|
+
browserInstance: WebdriverIO.Browser;
|
|
24
|
+
origin?: 'viewport' | 'document';
|
|
25
|
+
clip?: RectanglesOutput;
|
|
26
|
+
}): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Log an error for not being able to hide remove elements
|
|
29
|
+
*
|
|
30
|
+
* @TODO: remove the any
|
|
31
|
+
*/
|
|
32
|
+
export declare function logHiddenRemovedError(error: any): void;
|
|
33
|
+
/**
|
|
34
|
+
* Take an element screenshot on the web
|
|
35
|
+
*/
|
|
36
|
+
export declare function takeWebElementScreenshot({ addressBarShadowPadding, browserInstance, devicePixelRatio, deviceRectangles, element, fallback, initialDevicePixelRatio, isEmulated, innerHeight, isAndroid, isAndroidChromeDriverScreenshot, isAndroidNativeWebScreenshot, isIOS, isLandscape, toolBarShadowPadding, }: TakeWebElementScreenshot): Promise<TakeWebElementScreenshotData>;
|
|
37
|
+
//# sourceMappingURL=screenshots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../../src/methods/screenshots.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,yBAAyB,EACzB,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC/B,MAAM,6BAA6B,CAAA;AAGpC,OAAO,KAAK,EAA4B,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAK5F;;GAEG;AACH,wBAAsB,yCAAyC,CAAC,eAAe,EAAE,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,qCAAqC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAwJtL;AAED;;GAEG;AACH,wBAAsB,6CAA6C,CAAC,eAAe,EAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA2F7K;AAED;;GAEG;AACH,wBAAsB,iCAAiC,CAAC,eAAe,EAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAmGjK;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,eAAe,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhG;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,EAC3C,eAAe,EACf,MAAmB,EACnB,IAAI,GACP,EAAE;IACC,eAAe,EAAE,WAAW,CAAC,OAAO,CAAC;IACrC,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,CASlB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,QAa/C;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,EAC3C,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,QAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,WAAW,EACX,SAAS,EACT,+BAA+B,EAC/B,4BAA4B,EAC5B,KAAK,EACL,WAAW,EACX,oBAAoB,GACvB,EAAE,wBAAwB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAgElE"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { DeviceRectangles } from './rectangles.interfaces.js';
|
|
2
|
+
import type { RectanglesOutput } from './rectangles.interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Universal screenshot information that applies to ALL screenshot scenarios.
|
|
5
|
+
* This includes desktop browsers on high-DPI displays, mobile browsers, and native apps.
|
|
6
|
+
*/
|
|
7
|
+
export interface ScreenshotInfo {
|
|
8
|
+
/** The device pixel ratio. */
|
|
9
|
+
devicePixelRatio: number;
|
|
10
|
+
/** The initial device pixel ratio. */
|
|
11
|
+
initialDevicePixelRatio?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Base device information shared across screenshot operations.
|
|
15
|
+
*/
|
|
16
|
+
export interface DeviceInfo {
|
|
17
|
+
/** Whether the instance is an Android device. */
|
|
18
|
+
isAndroid: boolean;
|
|
19
|
+
/** Whether the instance is an iOS device. */
|
|
20
|
+
isIOS: boolean;
|
|
21
|
+
/** Whether it's landscape or not. */
|
|
22
|
+
isLandscape: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Viewport information.
|
|
26
|
+
*/
|
|
27
|
+
export interface ViewportInfo {
|
|
28
|
+
/** The inner height. */
|
|
29
|
+
innerHeight: number;
|
|
30
|
+
/** The inner width. */
|
|
31
|
+
innerWidth?: number;
|
|
32
|
+
/** Height of the screen. */
|
|
33
|
+
screenHeight?: number;
|
|
34
|
+
/** Width of the screen. */
|
|
35
|
+
screenWidth?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Android-specific screenshot options.
|
|
39
|
+
*/
|
|
40
|
+
export interface AndroidScreenshotOptions {
|
|
41
|
+
/** Whether this is an Android native web screenshot. */
|
|
42
|
+
isAndroidNativeWebScreenshot: boolean;
|
|
43
|
+
/** Whether this is an Android ChromeDriver screenshot. */
|
|
44
|
+
isAndroidChromeDriverScreenshot: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* iOS-specific screenshot options.
|
|
48
|
+
*/
|
|
49
|
+
export interface IOSScreenshotOptions {
|
|
50
|
+
/** Whether to add iOS bezel corners. */
|
|
51
|
+
addIOSBezelCorners: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Mobile device information.
|
|
55
|
+
*/
|
|
56
|
+
export interface MobileDeviceInfo extends DeviceInfo {
|
|
57
|
+
/** The device name. */
|
|
58
|
+
deviceName: string;
|
|
59
|
+
/** Whether this is a mobile device. */
|
|
60
|
+
isMobile: boolean;
|
|
61
|
+
/** Whether the device is emulated. */
|
|
62
|
+
isEmulated: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Mobile cropping options for converting full screen to viewport screenshots.
|
|
66
|
+
*/
|
|
67
|
+
export interface MobileCroppingOptions {
|
|
68
|
+
/** The address bar padding for iOS or Android. */
|
|
69
|
+
addressBarShadowPadding: number;
|
|
70
|
+
/** The toolbar padding for iOS or Android. */
|
|
71
|
+
toolBarShadowPadding: number;
|
|
72
|
+
/** The rectangles of the device. */
|
|
73
|
+
deviceRectangles: DeviceRectangles;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Scroll options for full page screenshots.
|
|
77
|
+
*/
|
|
78
|
+
export interface ScrollOptions {
|
|
79
|
+
/** The amount of milliseconds to wait for a new scroll. */
|
|
80
|
+
fullPageScrollTimeout: number;
|
|
81
|
+
/** Elements that need to be hidden after the first scroll for a fullpage scroll. */
|
|
82
|
+
hideAfterFirstScroll: (HTMLElement | HTMLElement[])[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Interface representing data for full page screenshots.
|
|
86
|
+
*/
|
|
87
|
+
export interface FullPageScreenshotsData {
|
|
88
|
+
/** The height of the full page. */
|
|
89
|
+
fullPageHeight: number;
|
|
90
|
+
/** The width of the full page. */
|
|
91
|
+
fullPageWidth: number;
|
|
92
|
+
/** Array of screenshot data. */
|
|
93
|
+
data: ScreenshotData[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Interface representing individual screenshot data.
|
|
97
|
+
*/
|
|
98
|
+
interface ScreenshotData {
|
|
99
|
+
/** The width of the canvas. */
|
|
100
|
+
canvasWidth: number;
|
|
101
|
+
/** The y position on the canvas. */
|
|
102
|
+
canvasYPosition: number;
|
|
103
|
+
/** The height of the image. */
|
|
104
|
+
imageHeight: number;
|
|
105
|
+
/** The width of the image. */
|
|
106
|
+
imageWidth: number;
|
|
107
|
+
/** The x position in the image to start from. */
|
|
108
|
+
imageXPosition: number;
|
|
109
|
+
/** The y position in the image to start from. */
|
|
110
|
+
imageYPosition: number;
|
|
111
|
+
/** The screenshot itself. */
|
|
112
|
+
screenshot: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Base interface for screenshot data results.
|
|
116
|
+
*/
|
|
117
|
+
export interface BaseScreenshotData {
|
|
118
|
+
/** The base64 encoded image. */
|
|
119
|
+
base64Image: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Interface representing data for web screen screenshot result.
|
|
123
|
+
*/
|
|
124
|
+
export interface WebScreenshotData extends BaseScreenshotData {
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Interface representing data for element screenshot result.
|
|
128
|
+
*/
|
|
129
|
+
export interface ElementScreenshotData extends BaseScreenshotData {
|
|
130
|
+
/** Whether this is a web driver element screenshot. */
|
|
131
|
+
isWebDriverElementScreenshot: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Interface representing data for taking a web element screenshot.
|
|
135
|
+
*/
|
|
136
|
+
export interface TakeWebElementScreenshotData extends BaseScreenshotData {
|
|
137
|
+
/** Whether this is a web driver element screenshot. */
|
|
138
|
+
isWebDriverElementScreenshot: boolean;
|
|
139
|
+
/** The rectangles output. */
|
|
140
|
+
rectangles: RectanglesOutput;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Interface representing options for full page screenshot data.
|
|
144
|
+
*/
|
|
145
|
+
export interface FullPageScreenshotDataOptions extends ScreenshotInfo, DeviceInfo, AndroidScreenshotOptions, ViewportInfo, MobileCroppingOptions, ScrollOptions {
|
|
146
|
+
/** Height of the screen. */
|
|
147
|
+
screenHeight: number;
|
|
148
|
+
/** Width of the screen. */
|
|
149
|
+
screenWidth: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Interface representing options for full page screenshot on native mobile.
|
|
153
|
+
*/
|
|
154
|
+
export interface FullPageScreenshotNativeMobileOptions extends ScreenshotInfo, DeviceInfo, ViewportInfo, MobileCroppingOptions, ScrollOptions {
|
|
155
|
+
/** Width of the screen. */
|
|
156
|
+
screenWidth: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Interface representing options for full page screenshot.
|
|
160
|
+
*/
|
|
161
|
+
export interface FullPageScreenshotOptions extends ScreenshotInfo, ViewportInfo, ScrollOptions {
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Interface representing options for taking a web element screenshot.
|
|
165
|
+
*/
|
|
166
|
+
export interface TakeWebElementScreenshot extends ScreenshotInfo, DeviceInfo, AndroidScreenshotOptions, MobileCroppingOptions {
|
|
167
|
+
/** The browser instance. */
|
|
168
|
+
browserInstance: WebdriverIO.Browser;
|
|
169
|
+
/** The element to take a screenshot of. */
|
|
170
|
+
element: any;
|
|
171
|
+
/** Whether to use a fallback method. */
|
|
172
|
+
fallback?: boolean;
|
|
173
|
+
/** Whether the device is emulated. */
|
|
174
|
+
isEmulated: boolean;
|
|
175
|
+
/** The inner height. */
|
|
176
|
+
innerHeight?: number;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Interface representing options for web screen screenshot data.
|
|
180
|
+
*/
|
|
181
|
+
export interface WebScreenshotDataOptions extends ScreenshotInfo, MobileDeviceInfo, AndroidScreenshotOptions, IOSScreenshotOptions {
|
|
182
|
+
/** Whether to enable legacy screenshot method. */
|
|
183
|
+
enableLegacyScreenshotMethod: boolean;
|
|
184
|
+
/** The inner height. */
|
|
185
|
+
innerHeight?: number;
|
|
186
|
+
/** The inner width. */
|
|
187
|
+
innerWidth?: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Interface representing options for element screenshot data.
|
|
191
|
+
*/
|
|
192
|
+
export interface ElementScreenshotDataOptions extends ScreenshotInfo, MobileDeviceInfo, AndroidScreenshotOptions, MobileCroppingOptions {
|
|
193
|
+
/** Whether to automatically scroll the element into view. */
|
|
194
|
+
autoElementScroll: boolean;
|
|
195
|
+
/** The element to take a screenshot of. */
|
|
196
|
+
element: any;
|
|
197
|
+
/** The inner height. */
|
|
198
|
+
innerHeight?: number;
|
|
199
|
+
/** Resize dimensions for the screenshot. */
|
|
200
|
+
resizeDimensions: any;
|
|
201
|
+
}
|
|
202
|
+
export {};
|
|
203
|
+
//# sourceMappingURL=screenshots.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.interfaces.d.ts","sourceRoot":"","sources":["../../src/methods/screenshots.interfaces.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import logger from '@wdio/logger';
|
|
2
|
+
import scrollToPosition from '../clientSideScripts/scrollToPosition.js';
|
|
3
|
+
import getDocumentScrollHeight from '../clientSideScripts/getDocumentScrollHeight.js';
|
|
4
|
+
import { calculateDprData, getBase64ScreenshotSize, waitFor } from '../helpers/utils.js';
|
|
5
|
+
import hideRemoveElements from '../clientSideScripts/hideRemoveElements.js';
|
|
6
|
+
import hideScrollBars from '../clientSideScripts/hideScrollbars.js';
|
|
7
|
+
import { determineElementRectangles } from './rectangles.js';
|
|
8
|
+
const log = logger('@wdio/visual-service:@wdio/image-comparison-core:screenshots');
|
|
9
|
+
/**
|
|
10
|
+
* Take a full page screenshots for desktop / iOS / Android
|
|
11
|
+
*/
|
|
12
|
+
export async function getMobileFullPageNativeWebScreenshotsData(browserInstance, options) {
|
|
13
|
+
const viewportScreenshots = [];
|
|
14
|
+
// The addressBarShadowPadding and toolBarShadowPadding is used because the viewport might have a shadow on the address and the tool bar
|
|
15
|
+
// so the cutout of the viewport needs to be a little bit smaller
|
|
16
|
+
const { addressBarShadowPadding, devicePixelRatio, deviceRectangles: { viewport, bottomBar, homeBar }, fullPageScrollTimeout, hideAfterFirstScroll, isAndroid, isLandscape, toolBarShadowPadding, } = options;
|
|
17
|
+
// The returned data from the deviceRectangles is in real pixels, not CSS pixels, so we need to divide it by the devicePixelRatio
|
|
18
|
+
// but only for Android, because the deviceRectangles are already in CSS pixels for iOS
|
|
19
|
+
const viewportHeight = Math.round(viewport.height / (isAndroid ? devicePixelRatio : 1)) - addressBarShadowPadding - toolBarShadowPadding;
|
|
20
|
+
const hasNoBottomBar = bottomBar.height === 0;
|
|
21
|
+
const hasHomeBar = homeBar.height > 0;
|
|
22
|
+
const effectiveViewportHeight = hasNoBottomBar && hasHomeBar
|
|
23
|
+
? viewportHeight - Math.round(homeBar.height / (isAndroid ? devicePixelRatio : 1))
|
|
24
|
+
: viewportHeight;
|
|
25
|
+
const viewportWidth = Math.round(viewport.width / (isAndroid ? devicePixelRatio : 1));
|
|
26
|
+
const viewportX = Math.round(viewport.x / (isAndroid ? devicePixelRatio : 1));
|
|
27
|
+
const viewportY = Math.round(viewport.y / (isAndroid ? devicePixelRatio : 1));
|
|
28
|
+
// Start with an empty array, during the scroll it will be filled because a page could also have a lazy loading
|
|
29
|
+
const amountOfScrollsArray = [];
|
|
30
|
+
let scrollHeight;
|
|
31
|
+
let isRotated = false;
|
|
32
|
+
for (let i = 0; i <= amountOfScrollsArray.length; i++) {
|
|
33
|
+
// Determine and start scrolling
|
|
34
|
+
const scrollY = effectiveViewportHeight * i;
|
|
35
|
+
if (scrollY < 0) {
|
|
36
|
+
const currentBrowserScrollPosition = await browserInstance.execute(() => window.pageYOffset || document.documentElement.scrollTop);
|
|
37
|
+
log.error('Negative scrollY detected during full page screenshot', {
|
|
38
|
+
iteration: i,
|
|
39
|
+
scrollY,
|
|
40
|
+
effectiveViewportHeight,
|
|
41
|
+
originalViewportHeight: viewportHeight,
|
|
42
|
+
calculatedScrollY: effectiveViewportHeight * i,
|
|
43
|
+
deviceInfo: {
|
|
44
|
+
isAndroid,
|
|
45
|
+
isLandscape,
|
|
46
|
+
devicePixelRatio,
|
|
47
|
+
addressBarShadowPadding,
|
|
48
|
+
toolBarShadowPadding
|
|
49
|
+
},
|
|
50
|
+
deviceRectangles: {
|
|
51
|
+
viewport: options.deviceRectangles.viewport,
|
|
52
|
+
bottomBar: options.deviceRectangles.bottomBar,
|
|
53
|
+
homeBar: options.deviceRectangles.homeBar,
|
|
54
|
+
screenSize: options.deviceRectangles.screenSize
|
|
55
|
+
},
|
|
56
|
+
homeBarAdjustment: {
|
|
57
|
+
hasNoBottomBar,
|
|
58
|
+
hasHomeBar,
|
|
59
|
+
homeBarHeightAdjustment: hasNoBottomBar && hasHomeBar ? Math.round(homeBar.height / (isAndroid ? devicePixelRatio : 1)) : 0
|
|
60
|
+
},
|
|
61
|
+
scrollHeight,
|
|
62
|
+
currentBrowserScrollPosition
|
|
63
|
+
});
|
|
64
|
+
throw new Error(`Negative scroll position detected (scrollY: ${scrollY}) during full page screenshot at iteration ${i}. This indicates an issue with viewport calculations or browser scroll state. Check logs for detailed debug information.`);
|
|
65
|
+
}
|
|
66
|
+
await browserInstance.execute(scrollToPosition, scrollY);
|
|
67
|
+
// Hide scrollbars before taking a screenshot, we don't want them, on the screenshot
|
|
68
|
+
await browserInstance.execute(hideScrollBars, true);
|
|
69
|
+
// Simply wait the amount of time specified for lazy-loading
|
|
70
|
+
await waitFor(fullPageScrollTimeout);
|
|
71
|
+
// Elements that need to be hidden after the first scroll for a fullpage scroll
|
|
72
|
+
if (i === 1 && hideAfterFirstScroll.length > 0) {
|
|
73
|
+
try {
|
|
74
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, true);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
logHiddenRemovedError(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Take the screenshot and determine if it's rotated
|
|
81
|
+
const screenshot = await takeBase64Screenshot(browserInstance);
|
|
82
|
+
isRotated = Boolean(isLandscape && effectiveViewportHeight > viewportWidth);
|
|
83
|
+
// Determine scroll height and check if we need to scroll again
|
|
84
|
+
scrollHeight = await browserInstance.execute(getDocumentScrollHeight);
|
|
85
|
+
if (scrollHeight && (scrollY + effectiveViewportHeight < scrollHeight)) {
|
|
86
|
+
amountOfScrollsArray.push(amountOfScrollsArray.length);
|
|
87
|
+
}
|
|
88
|
+
const remainingContent = scrollHeight ? scrollHeight - scrollY : 0;
|
|
89
|
+
const imageHeight = amountOfScrollsArray.length === i && scrollHeight && remainingContent > 0
|
|
90
|
+
? remainingContent
|
|
91
|
+
: effectiveViewportHeight;
|
|
92
|
+
if (amountOfScrollsArray.length === i && remainingContent <= 0) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
// The starting position for cropping could be different for the last image
|
|
96
|
+
// The cropping always needs to start at status and address bar height and the address bar shadow padding
|
|
97
|
+
const imageYPosition = (amountOfScrollsArray.length === i ? effectiveViewportHeight - imageHeight : 0) + viewportY + addressBarShadowPadding;
|
|
98
|
+
// Store all the screenshot data in the screenshot object
|
|
99
|
+
viewportScreenshots.push({
|
|
100
|
+
...calculateDprData({
|
|
101
|
+
canvasWidth: isRotated ? effectiveViewportHeight : viewportWidth,
|
|
102
|
+
canvasYPosition: scrollY,
|
|
103
|
+
imageHeight: imageHeight,
|
|
104
|
+
imageWidth: isRotated ? effectiveViewportHeight : viewportWidth,
|
|
105
|
+
imageXPosition: viewportX,
|
|
106
|
+
imageYPosition: imageYPosition,
|
|
107
|
+
}, devicePixelRatio),
|
|
108
|
+
screenshot,
|
|
109
|
+
});
|
|
110
|
+
// Show scrollbars again
|
|
111
|
+
await browserInstance.execute(hideScrollBars, false);
|
|
112
|
+
}
|
|
113
|
+
// Put back the hidden elements to visible
|
|
114
|
+
if (hideAfterFirstScroll.length > 0) {
|
|
115
|
+
try {
|
|
116
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, false);
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
logHiddenRemovedError(e);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!scrollHeight) {
|
|
123
|
+
throw new Error('Couldn\'t determine scroll height or screenshot size');
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
...calculateDprData({
|
|
127
|
+
fullPageHeight: scrollHeight - addressBarShadowPadding - toolBarShadowPadding,
|
|
128
|
+
fullPageWidth: isRotated ? effectiveViewportHeight : viewportWidth,
|
|
129
|
+
}, devicePixelRatio),
|
|
130
|
+
data: viewportScreenshots,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Take a full page screenshot for Android with Chromedriver
|
|
135
|
+
*/
|
|
136
|
+
export async function getAndroidChromeDriverFullPageScreenshotsData(browserInstance, options) {
|
|
137
|
+
const viewportScreenshots = [];
|
|
138
|
+
const { devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight } = options;
|
|
139
|
+
// Start with an empty array, during the scroll it will be filled because a page could also have a lazy loading
|
|
140
|
+
const amountOfScrollsArray = [];
|
|
141
|
+
let scrollHeight;
|
|
142
|
+
let screenshotSize;
|
|
143
|
+
for (let i = 0; i <= amountOfScrollsArray.length; i++) {
|
|
144
|
+
// Determine and start scrolling
|
|
145
|
+
const scrollY = innerHeight * i;
|
|
146
|
+
await browserInstance.execute(scrollToPosition, scrollY);
|
|
147
|
+
// Hide scrollbars before taking a screenshot, we don't want them, on the screenshot
|
|
148
|
+
await browserInstance.execute(hideScrollBars, true);
|
|
149
|
+
// Simply wait the amount of time specified for lazy-loading
|
|
150
|
+
await waitFor(fullPageScrollTimeout);
|
|
151
|
+
// Elements that need to be hidden after the first scroll for a fullpage scroll
|
|
152
|
+
if (i === 1 && hideAfterFirstScroll.length > 0) {
|
|
153
|
+
try {
|
|
154
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, true);
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
logHiddenRemovedError(e);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Take the screenshot
|
|
161
|
+
const screenshot = await takeBase64Screenshot(browserInstance);
|
|
162
|
+
screenshotSize = getBase64ScreenshotSize(screenshot, devicePixelRatio);
|
|
163
|
+
// Determine scroll height and check if we need to scroll again
|
|
164
|
+
scrollHeight = await browserInstance.execute(getDocumentScrollHeight);
|
|
165
|
+
if (scrollHeight && (scrollY + innerHeight < scrollHeight)) {
|
|
166
|
+
amountOfScrollsArray.push(amountOfScrollsArray.length);
|
|
167
|
+
}
|
|
168
|
+
// There is no else
|
|
169
|
+
// The height of the image of the last 1 could be different
|
|
170
|
+
const imageHeight = amountOfScrollsArray.length === i && scrollHeight
|
|
171
|
+
? scrollHeight - innerHeight * viewportScreenshots.length
|
|
172
|
+
: innerHeight;
|
|
173
|
+
// The starting position for cropping could be different for the last image (0 means no cropping)
|
|
174
|
+
const imageYPosition = amountOfScrollsArray.length === i && amountOfScrollsArray.length !== 0 ? innerHeight - imageHeight : 0;
|
|
175
|
+
// Store all the screenshot data in the screenshot object
|
|
176
|
+
viewportScreenshots.push({
|
|
177
|
+
...calculateDprData({
|
|
178
|
+
canvasWidth: screenshotSize.width,
|
|
179
|
+
canvasYPosition: scrollY,
|
|
180
|
+
imageHeight: imageHeight,
|
|
181
|
+
imageWidth: screenshotSize.width,
|
|
182
|
+
imageXPosition: 0,
|
|
183
|
+
imageYPosition: imageYPosition,
|
|
184
|
+
}, devicePixelRatio),
|
|
185
|
+
screenshot,
|
|
186
|
+
});
|
|
187
|
+
// Show the scrollbars again
|
|
188
|
+
await browserInstance.execute(hideScrollBars, false);
|
|
189
|
+
}
|
|
190
|
+
// Put back the hidden elements to visible
|
|
191
|
+
if (hideAfterFirstScroll.length > 0) {
|
|
192
|
+
try {
|
|
193
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, false);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
logHiddenRemovedError(e);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!scrollHeight || !screenshotSize) {
|
|
200
|
+
throw new Error('Couldn\'t determine scroll height or screenshot size');
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
...calculateDprData({
|
|
204
|
+
fullPageHeight: scrollHeight,
|
|
205
|
+
fullPageWidth: screenshotSize.width,
|
|
206
|
+
}, devicePixelRatio),
|
|
207
|
+
data: viewportScreenshots,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Take a full page screenshots
|
|
212
|
+
*/
|
|
213
|
+
export async function getDesktopFullPageScreenshotsData(browserInstance, options) {
|
|
214
|
+
const viewportScreenshots = [];
|
|
215
|
+
const { devicePixelRatio, fullPageScrollTimeout, hideAfterFirstScroll, innerHeight } = options;
|
|
216
|
+
let actualInnerHeight = innerHeight;
|
|
217
|
+
// Start with an empty array, during the scroll it will be filled because a page could also have a lazy loading
|
|
218
|
+
const amountOfScrollsArray = [];
|
|
219
|
+
let scrollHeight;
|
|
220
|
+
let screenshotSize;
|
|
221
|
+
for (let i = 0; i <= amountOfScrollsArray.length; i++) {
|
|
222
|
+
// Determine and start scrolling
|
|
223
|
+
const scrollY = actualInnerHeight * i;
|
|
224
|
+
await browserInstance.execute(scrollToPosition, scrollY);
|
|
225
|
+
// Simply wait the amount of time specified for lazy-loading
|
|
226
|
+
await waitFor(fullPageScrollTimeout);
|
|
227
|
+
// Elements that need to be hidden after the first scroll for a fullpage scroll
|
|
228
|
+
if (i === 1 && hideAfterFirstScroll.length > 0) {
|
|
229
|
+
try {
|
|
230
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, true);
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
logHiddenRemovedError(e);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Take the screenshot
|
|
237
|
+
const screenshot = await takeBase64Screenshot(browserInstance);
|
|
238
|
+
screenshotSize = getBase64ScreenshotSize(screenshot, devicePixelRatio);
|
|
239
|
+
// The actual screenshot size might be slightly different than the inner height
|
|
240
|
+
// In that case, use the screenshot size instead of the innerHeight
|
|
241
|
+
if (i === 0 && screenshotSize.height !== actualInnerHeight) {
|
|
242
|
+
if (Math.round(screenshotSize.height) === actualInnerHeight) {
|
|
243
|
+
actualInnerHeight = screenshotSize.height;
|
|
244
|
+
}
|
|
245
|
+
// No else, because some drivers take a full page screenshot, e.g. some versions of FireFox,
|
|
246
|
+
// and SafariDriver for Safari 11
|
|
247
|
+
}
|
|
248
|
+
// Determine scroll height and check if we need to scroll again
|
|
249
|
+
scrollHeight = await browserInstance.execute(getDocumentScrollHeight);
|
|
250
|
+
if (scrollHeight && (scrollY + actualInnerHeight < scrollHeight) && screenshotSize.height === actualInnerHeight) {
|
|
251
|
+
amountOfScrollsArray.push(amountOfScrollsArray.length);
|
|
252
|
+
}
|
|
253
|
+
// There is no else, Lazy load and large screenshots,
|
|
254
|
+
// like with older drivers such as FF <= 47 and IE11, will not work
|
|
255
|
+
// The height of the image of the last 1 could be different
|
|
256
|
+
const imageHeight = scrollHeight && amountOfScrollsArray.length === i
|
|
257
|
+
? scrollHeight - actualInnerHeight * viewportScreenshots.length
|
|
258
|
+
: screenshotSize.height;
|
|
259
|
+
// The starting position for cropping could be different for the last image (0 means no cropping)
|
|
260
|
+
const imageYPosition = amountOfScrollsArray.length === i && amountOfScrollsArray.length !== 0
|
|
261
|
+
? actualInnerHeight - imageHeight
|
|
262
|
+
: 0;
|
|
263
|
+
// Store all the screenshot data in the screenshot object
|
|
264
|
+
viewportScreenshots.push({
|
|
265
|
+
...calculateDprData({
|
|
266
|
+
canvasWidth: screenshotSize.width,
|
|
267
|
+
canvasYPosition: scrollY,
|
|
268
|
+
imageHeight: imageHeight,
|
|
269
|
+
imageWidth: screenshotSize.width,
|
|
270
|
+
imageXPosition: 0,
|
|
271
|
+
imageYPosition: imageYPosition,
|
|
272
|
+
}, devicePixelRatio),
|
|
273
|
+
screenshot,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
// Put back the hidden elements to visible
|
|
277
|
+
if (hideAfterFirstScroll.length > 0) {
|
|
278
|
+
try {
|
|
279
|
+
await browserInstance.execute(hideRemoveElements, { hide: hideAfterFirstScroll, remove: [] }, false);
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
logHiddenRemovedError(e);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!scrollHeight || !screenshotSize) {
|
|
286
|
+
throw new Error('Couldn\'t determine scroll height or screenshot size');
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
...calculateDprData({
|
|
290
|
+
fullPageHeight: scrollHeight,
|
|
291
|
+
fullPageWidth: screenshotSize.width,
|
|
292
|
+
}, devicePixelRatio),
|
|
293
|
+
data: viewportScreenshots,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Take a screenshot
|
|
298
|
+
*/
|
|
299
|
+
export async function takeBase64Screenshot(browserInstance) {
|
|
300
|
+
return browserInstance.takeScreenshot();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Take a bidi screenshot
|
|
304
|
+
*/
|
|
305
|
+
export async function takeBase64BiDiScreenshot({ browserInstance, origin = 'viewport', clip, }) {
|
|
306
|
+
log.info('Taking a BiDi screenshot');
|
|
307
|
+
const contextID = await browserInstance.getWindowHandle();
|
|
308
|
+
return (await browserInstance.browsingContextCaptureScreenshot({
|
|
309
|
+
context: contextID,
|
|
310
|
+
origin,
|
|
311
|
+
...(clip ? { clip: { ...clip, type: 'box' } } : {})
|
|
312
|
+
})).data;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Log an error for not being able to hide remove elements
|
|
316
|
+
*
|
|
317
|
+
* @TODO: remove the any
|
|
318
|
+
*/
|
|
319
|
+
export function logHiddenRemovedError(error) {
|
|
320
|
+
log.warn('\x1b[33m%s\x1b[0m', `
|
|
321
|
+
#####################################################################################
|
|
322
|
+
WARNING:
|
|
323
|
+
(One of) the elements that needed to be hidden or removed could not be found on the
|
|
324
|
+
page and caused this error
|
|
325
|
+
Error: ${error}
|
|
326
|
+
We made sure the test didn't break.
|
|
327
|
+
#####################################################################################
|
|
328
|
+
`);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Take an element screenshot on the web
|
|
332
|
+
*/
|
|
333
|
+
export async function takeWebElementScreenshot({ addressBarShadowPadding, browserInstance, devicePixelRatio, deviceRectangles, element, fallback = false, initialDevicePixelRatio, isEmulated, innerHeight, isAndroid, isAndroidChromeDriverScreenshot, isAndroidNativeWebScreenshot, isIOS, isLandscape, toolBarShadowPadding, }) {
|
|
334
|
+
if (fallback) {
|
|
335
|
+
const base64Image = await takeBase64Screenshot(browserInstance);
|
|
336
|
+
const elementRectangleOptions = {
|
|
337
|
+
/**
|
|
338
|
+
* ToDo: handle NaA case
|
|
339
|
+
*/
|
|
340
|
+
devicePixelRatio: devicePixelRatio,
|
|
341
|
+
deviceRectangles,
|
|
342
|
+
initialDevicePixelRatio: initialDevicePixelRatio || 1,
|
|
343
|
+
innerHeight: innerHeight || NaN,
|
|
344
|
+
isEmulated,
|
|
345
|
+
isAndroidNativeWebScreenshot,
|
|
346
|
+
isAndroid,
|
|
347
|
+
isIOS,
|
|
348
|
+
};
|
|
349
|
+
const rectangles = await determineElementRectangles({
|
|
350
|
+
browserInstance,
|
|
351
|
+
base64Image,
|
|
352
|
+
element,
|
|
353
|
+
options: elementRectangleOptions,
|
|
354
|
+
});
|
|
355
|
+
return {
|
|
356
|
+
base64Image,
|
|
357
|
+
isWebDriverElementScreenshot: false,
|
|
358
|
+
rectangles,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
const base64Image = await browserInstance.takeElementScreenshot((await element).elementId);
|
|
363
|
+
const { height, width } = getBase64ScreenshotSize(base64Image);
|
|
364
|
+
const rectangles = { x: 0, y: 0, width, height };
|
|
365
|
+
if (rectangles.width === 0 || rectangles.height === 0) {
|
|
366
|
+
throw new Error('The element has no width or height.');
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
base64Image,
|
|
370
|
+
isWebDriverElementScreenshot: true,
|
|
371
|
+
rectangles,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
catch (_e) {
|
|
375
|
+
log.warn('The element screenshot failed, falling back to cutting the full device/viewport screenshot:', _e);
|
|
376
|
+
return takeWebElementScreenshot({
|
|
377
|
+
addressBarShadowPadding,
|
|
378
|
+
browserInstance,
|
|
379
|
+
devicePixelRatio,
|
|
380
|
+
deviceRectangles,
|
|
381
|
+
element,
|
|
382
|
+
fallback: true,
|
|
383
|
+
initialDevicePixelRatio,
|
|
384
|
+
isEmulated,
|
|
385
|
+
innerHeight,
|
|
386
|
+
isAndroid,
|
|
387
|
+
isAndroidChromeDriverScreenshot,
|
|
388
|
+
isAndroidNativeWebScreenshot,
|
|
389
|
+
isIOS,
|
|
390
|
+
isLandscape,
|
|
391
|
+
toolBarShadowPadding,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.test.d.ts","sourceRoot":"","sources":["../../src/methods/screenshots.test.ts"],"names":[],"mappings":""}
|