I observed anna’s target web site http://www.adm.com/ and found that the pages are very difficult to take clean full page screenshot. See the following movie, especially look at the timeframe 10-15secs
You will find some graphics are moving along you scroll down the page. This moving graphics makes it very difficult to take “stable screenshots”.
Let me step back and explain how a full page screenshot is composed. See the following figure:
The screenshooter library (Shutterbug and AShot) can create a full page screenshot which is generated out of a set of partial screenshots of the viewport. The library start taking a viewport screenshot at the top, scroll down to the next view port and take a viewport screenshot, … scroll and shoot, scroll and shoot, … until it reaches to the bottom of the page.
Now let me assume that the target page has any slowly moving graphics that moves as you scrool the view port downward. The library has to wait long enough until the moving graphics settles. So, how long of milliseconds Shutterbug waits as default? ---- just 100 milliseconds as the source tells
The moving graphics at https://www.adm.com is moving so gracefully (slowly) that it is quite likely that when the shutterbug scrolls down the viewport into the portion where the graphics is located, it would find the graphics is still moving for some pixels per 100 milliseconds. The resulting screenshot image will be unstable. Therefore the library is likely to produce a “diff” like this:
Here the different pixels are painted in red. But I am only interested in the diff caused by the unexpected problems. I am not interested in the diff caused by the known factors (moving graphics). How to avoid the boring diffs?
There is a trick. The Shutterbug allows users to specify how long milliseconds it should wait after each scroll operations before taking the partial viewport screenshots. Quote from selenium-shutterbug/src/main/java/com/assertthat/selenium_shutterbug/core/Shutterbug.java at master · assertthat/selenium-shutterbug · GitHub
/**
* To be used when screenshotting the page
* and need to scroll while making screenshots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param capture Capture type
* @param betweenScrollTimeout Timeout to wait between each scrolling operation
* @param useDevicePixelRatio whether to account for device pixel ratio
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, Capture capture,
int betweenScrollTimeout, boolean useDevicePixelRatio) {
...
If user specify a longer value to betweenScrollTimeout, for example 2000, the gracefully moving graphis will get settled, and the screenshot image will become stable. You will get less magnitude of pixel differences.
Now, I would tell you a unfortunate news. Katalon’s WebUI.takeFullPageScreenshotAsCheckout() does not allow you to specify a longer value of the betweenScrollTimeout. See the source
Therefore, if you use this keyword, you will always find the screenshot of https://www.adm.com/ page is reported “different” due to the moving graphics.
A quick work-around: you can call the Shutterbug API directly from your Test Case script. you do not have to use WebUI.* keywords.