Skip to main content

Automating WebApplication Screenshot Capture

I recently contributed some introduction to the Gerrit Project. This included some screenshots and understandably the project maintainers are concerned about the overhead of keeping these screenshots up to date. So just for my own interest I've started looking in to how to automate the generation of these screenshots. This is not a working solution yet, just a collection of the ideas I'm playing with.

This first thing I started looking at was how I could automatically create a screenshots of the browser. After a bit of googling these seem to be two broad techniques. There are a few tools that given a URL will generate an image. Khtml2png and webkit2png seem to be good examples of these tools. While these are fine tools I really want to be able to capture pictures of the application as I modify it, so they don't quite serve my purpose.

The second technique seems rather more promising, starting a headless X Server using xvfb, starting firefox in it and then creating an image of this virtual screen using the ImageMagick's import tool. This is really much simpler than it sounds, it looks something like this:

$ Xvfb :2 -screen 0 800x600x24 & -- Start the virtual frame buffer
$ DISPLAY=:2 icewm & -- Start ice window manager so we get chrome
$ DISPLAY=:2 firefox &
$ DISPLAY=:2 import -window root snapshot.png

Simple enough really, I think it's quite a neat trick myself. Of course it could be any X server, I'm using Xvfb to make it completely standalone, but it also works with Xephyr or Xvnc if you want to interact with the applications you've started. Jordan Sissel has even written ephemeral-x, a script which finds a free display number and starts Xvfb for this.

Next, attempts to automate the browser session so I can actually take the screenshots I need.


Popular posts from this blog

2017 Donations

Each year around Christmas I make a set of donations to causes and organisations that I want to support. I do this all at once, because I find I'm a lot more deliberate about what causes I support and the amount I want to donate than I am donating on impulse throughout the year.

I adopted this approach couple of years back after I read a tweet from Simon Lyall. Following his lead I've decided to blog my donations this year on the theory that it may encourage others in a similarly privileged position to do likewise.

I'm always rather uncomfortable discussing financial matters, so I'm going to avoid dollar amounts and just talk about groups of charities. Everyone's situation is different anyway so I don't believe dollar amounts really help the goal anyway.

Category 1: "Humanitarian Causes"

I use humanitarian loosely, my general preference is to support organisations working locally. I use GiveWell for supporting work overseas.

I split about 75% of my ov…

Planning, Estimating and Monitoring a Dev Project - Before Planning

Estimating and Planning and monitoring day to day development is a lot of what's involved in the job of a team leader. This is the approach I take to this, I don't claim to have created any of this, rather it's just the collection of agile methods and tools that I find useful. This is what I do for sprint planning every 2 to 3 weeks. When doing ball-park planning for a longer period I follow the same basic process but at a less granular level with corresponding drop in accuracy.

Before Planning There are a couple of questions that really need to be answered pre-planning. This is the side of planning that's often not visible to the juniors in the team. It's the bit that gets forgotten about and contributes to that wonderful "I don't know what my manager does, but when they're away it all goes bad" feeling in so many well run development teams.
The two questions you need to answer are How much time do you have?What are you trying to do? How Much Time D…

What is the first thing you do in the morning?

What is the first thing you do at work once you log into your computer? No really think about it, is it the same thing you were doing a year ago. I can almost track my career by the changes in what I do first thing in the morning.

When I was a junior developer, bright eyed and bushy tailed I checked my email first thing. It was a bit of a novelty to receive professional email and it made me feel a bit like an adult. Email seemed like the corporate information channel, so I thought as a responsible professional I should clear my email first thing and check it regularly during the day. The thing is though I didn't really get that much email as a junior.

As I started to become more senior I started to get more email. I also started to get more interruptions during the day. The morning started to be that really nice period where nobody talked to me. So I started to code first thing. Email could wait till I was being interrupted anyway. So my morning routine became code until I was int…