TestingBot Blog

TestingBot provides a cloud of browsers to run Automated, Live and Visual browser testing.

< Back to Blog Overview

Taking screenshots with Selenium


As mentioned before on this blog, we use a homemade utility to take screenshots of browser windows. Our tool, built in C#, will take a screenshot of any browser window on Windows.

We use the PrintWindow function available in Windows to take a screenshot. You can find our code on GitHub: https://github.com/testingbot/Selenium-Screenshots

The way it works is: we changed some Selenium code to capture the PID (Process ID) of the browser that is being used by using Java's JNA library. We pass this PID to our tool, which uses the PID to correctly identify the unique browser window. We then get its Hwnd and use PrintWindow to capture the contents of the window.

By releasing this code as open source, we thought it would possibly help others. Let us know what you think!

< Back to Blog Overview

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required