Features
< Back to Blog Overview

Screenshots with Selenium

2011-12-24
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews

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!

TestingBot Logo

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.

Other Articles

blank

TestingBot updates

2011-12-23

It's been a busy week on TestingBot, here's what we did this week: Updated our grid from Selenium 2.15 to 2.16, the changelog reads:

Read more
blank

Today we're examining the captureNetworkTraffic selenium command, a little known gem in Selenium's command list. Selenium offers a feature, captu...

Read more
blank

We have just finished optimizing the video recording in our Selenium grid. Implementing this was harder than we thought, so here are some tips on h...

Read more
blank

After some more optimisations in our code and infrastructure we've now reached the point where the average simple test takes 9 seconds. Compared ...

Read more
blank

We've just finished upgrading our Selenium grid (the hub and all its RC nodes) to Selenium v2.15.0 This upgrade should provide improved stability.

Read more
blank

Selenium is the industry standard for automatically testing websites in browsers. A selenium test is a set of instructions that will be sent to a b...

Read more