Selenium offers the ability to take a screen shot of the state of the running test. It enables you to compare the screen of what you have just ran with the one previously ran.

The code that captures the screen shot looks like this:

WebDriver augmentedDriver = new Augmenter().augment(driver);
File screenshot1 = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);

Image comparison compares 2 image’s:

  • Number of bands, width, and height
  • Pixels by pixels
In my iPhone application tests, I have used this mechanism. The code can be found inĀ code