Please note that this project is not actively maintained. Consider using diffux_ci instead.

Gem Version Build Status Code Climate Coverage

Core services used by diffux/diffux.


Command-line tools

diffux-core comes with a couple of useful command-line tools.


Take a snapshot of a URL and save as a PNG image.


Take a snapshot of http://www.google.com in a 1200 pixel wide window and save as "google.png":

diffux-snapshot --url http://www.google.com \
                --outfile google.png -- \
                --width 1200

Take a snapshot of http://www.google.com in a 320 pixel wide window, use a custom user-agent header, and save as "google-mobile.png":

diffux-snapshot --url http://www.google.com \
                --outfile google-mobile.png -- \
                --width 320 \
                --useragent "c3p0 (Netscape compatible)"

You can limit the area that the snapshot image is taken for by providing a cropselector option:

diffux-snapshot --url http://www.yahoo.com \
                --outfile yahoo.png -- \
                --cropselector ".searchwrapper"

In this example, if no element is found with a searchwrapper class on the page, the crop selector will be ignored and the snapshot will contain the entire page.

If more than one element matches the crop selector, only the first one will be included in the snapshot image.


Compare two snapshots (or any images for that matter) and outputs a diff if the two images are different.


Compare a previously snapshotted google.com image with a new version:

diffux-compare --before-image google1.png \
               --after-image google2.png

If a diff is detected, a diff.png file is saved in the current folder. This file is a side-by-side line-up of the before and after image with a diff representation in the middle. The script will also exit with a non-zero exit code.

If there is no diff between the before and after image, the program will silently exit with no output. The exit code in this case is zero.

You can override the output file if you want to:

diffux-compare --before-image google1.png \
               --after-image google2.png \
               --outfile diff.png

Here's an example of a diff.png output from diffux-compare:

Example of a Diffux diff