import beforeScreenshot from '../helpers/beforeScreenshot' ; import afterScreenshot from '../helpers/afterScreenshot' ; import { getBase64FullPageScreenshotsData } from '../methods/screenshots' ; import { makeFullPageBase64Image } from '../methods/images' ; import { ScreenshotOutput } from '../helpers/afterScreenshot.interfaces' ; import { Methods } from '../methods/methods.interface' ; import { InstanceData } from '../methods/instanceData.interfaces' ; import { Folders } from '../base.interface' ; import { SaveFullPageOptions } from './fullPage.interfaces' ; import { BeforeScreenshotOptions , BeforeScreenshotResult } from '../helpers/beforeScreenshot.interface' ; import { FullPageScreenshotDataOptions , FullPageScreenshotsData } from '../methods/screenshots.interfaces' ; /**
 * Saves an image of the full page
 */ export default async function saveFullPageScreen ( methods , instanceData , folders , tag , saveFullPageOptions ) { const { addressBarShadowPadding , autoSaveBaseline , formatImageName , isHybridApp , logLevel , savePerInstance , toolBarShadowPadding , } = saveFullPageOptions . wic ; const disableCSSAnimation = 'disableCSSAnimation' in saveFullPageOptions . method ? saveFullPageOptions . method . disableCSSAnimation : saveFullPageOptions . wic . disableCSSAnimation ; const hideScrollBars = 'hideScrollBars' in saveFullPageOptions . method ? saveFullPageOptions . method . hideScrollBars : saveFullPageOptions . wic . hideScrollBars ; const fullPageScrollTimeout = 'fullPageScrollTimeout' in saveFullPageOptions . method ? saveFullPageOptions . method . fullPageScrollTimeout : saveFullPageOptions . wic . fullPageScrollTimeout ; const hideElements = saveFullPageOptions . method . hideElements || [ ] ; const removeElements = saveFullPageOptions . method . removeElements || [ ] ; const hideAfterFirstScroll = saveFullPageOptions . method . hideAfterFirstScroll || [ ] ; const beforeOptions = { instanceData , addressBarShadowPadding , disableCSSAnimation , hideElements , logLevel , noScrollBars : hideScrollBars , removeElements , toolBarShadowPadding , } ; const enrichedInstanceData = await beforeScreenshot ( methods . executor , beforeOptions , true ) ; const fullPageScreenshotOptions = { addressBarShadowPadding : enrichedInstanceData . addressBarShadowPadding , devicePixelRatio : enrichedInstanceData . dimensions . window . devicePixelRatio , fullPageScrollTimeout , hideAfterFirstScroll , innerHeight : enrichedInstanceData . dimensions . window . innerHeight , isAndroid : enrichedInstanceData . isAndroid , isAndroidChromeDriverScreenshot : enrichedInstanceData . isAndroidChromeDriverScreenshot , isAndroidNativeWebScreenshot : enrichedInstanceData . isAndroidNativeWebScreenshot , isHybridApp , isIos : enrichedInstanceData . isIos , logLevel : logLevel , toolBarShadowPadding : enrichedInstanceData . toolBarShadowPadding , } ; const screenshotsData = await getBase64FullPageScreenshotsData ( methods . screenShot , methods . executor , fullPageScreenshotOptions ) ; const fullPageBase64Image = await makeFullPageBase64Image ( screenshotsData ) ; const afterOptions = { actualFolder : folders . actualFolder , base64Image : fullPageBase64Image , disableCSSAnimation , hideElements , hideScrollBars , filePath : { autoSaveBaseline , browserName : enrichedInstanceData . browserName , deviceName : enrichedInstanceData . deviceName , isMobile : enrichedInstanceData . isMobile , savePerInstance , } , fileName : { browserName : enrichedInstanceData . browserName , browserVersion : enrichedInstanceData . browserVersion , deviceName : enrichedInstanceData . deviceName , devicePixelRatio : enrichedInstanceData . dimensions . window . devicePixelRatio , formatImageName , isMobile : enrichedInstanceData . isMobile , isTestInBrowser : enrichedInstanceData . isTestInBrowser , logName : enrichedInstanceData . logName , name : enrichedInstanceData . name , outerHeight : enrichedInstanceData . dimensions . window . outerHeight , outerWidth : enrichedInstanceData . dimensions . window . outerWidth , platformName : enrichedInstanceData . platformName , platformVersion : enrichedInstanceData . platformVersion , screenHeight : enrichedInstanceData . dimensions . window . screenHeight , screenWidth : enrichedInstanceData . dimensions . window . screenWidth , tag , } , logLevel , platformName : instanceData . platformName , removeElements , } ; return afterScreenshot ( methods . executor , afterOptions ) ; }