Are you missing a part of your screenshot from the test script?

Sivakumar GanesanSivakumar GanesanJanuary 13, 20211 min read
416 views

Article content

If you are an automation engineer, taking screenshots and managing them might play a major role in your framework. Especially if you are performing visual tests and comparing UI with tools like Applitools, screenshots become even more important. But, are you missing a part of your screenshot from the test script and wondering what could have caused this?

missing a part of screenshotWhere does the rest of the screen go?

It is one of the common issues that engineers face when they change the Windows scaling. By default, based on the screen resolution supported Windows 10 recommends setting the scaling to 125% or even 150%. But when you don't handle the viewport settings to accommodate this change in your test code, you will end up with a partial screenshot.

How to fix this?

It is a simple fix. Simply add the required scaling that matches your system settings. You can find it either from the Windows display settings or by running window.devicePixelRatio; in the browser console.

//Before Fix
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(1000))
.takeScreenshot(driver);

missing part of screenshotPartial Screenshot + Missing portion

//After Fix - Includes scaling of 125%
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(**ShootingStrategies.scaling(1.25f)** , 1000))
.takeScreenshot(driver);

Full screenshot login formFull Screenshot

Viola! There's your full screenshot.


If you found this interesting, you can find more such articles here on quality assurance, test automation, tools, and processes. Don't forget to like and share this post with friends and community. If you have a question, connect with me through the contact form. Thank you!

You may also like