Nilal
Captures images of a particular web element and assert it against the expected image, and all you have to learn extra, is a single assert statement. Thus making it the simplest yet powerful visual regression testing tools.
Example
# In your capybara test
# Asserting a graph in page
find('.trend_chart').should match_image expected_report_image
# Assert layout/CSS Styling
find('.analysis_table').should match_image expected_table_image
Key Benefits
There are lot of tools out there to do visual regression, then why a yet another one.
- Seamlessly integrates with your existing regression test suite. No need to set up a seperate suite
- Just the image of the element under validation is captured and asserted, unlike other tools where the full page captured. This brings in a sea of advantages.
- Avoid test failures, due to change in elements unrelated to the test
- Reduced test run time, since we need not process a large image of the whole page.
- Avoid updating expected reference image when there is a change unrelated to test
- Test runs in a real browser (Firefox supported now, Chrome & IE in progress), providing a real time feedback, rather than virtual headless browsers
- Unlike other toos, there is no need of any external dependencies like pdiff or ImageMagic. Chunky_Png is used here.
Usage
#Gemfile
gem 'nilal'
###Cucumber
# In env.rb
require 'nilal'
World(Nilal::Capybara)
firefox_profile = Selenium::WebDriver::Firefox::Profile.new
firefox_profile.add_extension File.join(Gem::Specification.find_by_name("nilal").gem_dir,"/lib/nilal/nilal.xpi")
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => firefox_profile)
end
Generating expected reference image
- Create a folder under 'feature' called 'images'.
- First time, run your test without the reference image, test would fail, yet image of the expected element would be captured in 'tmp/capybara' folder.
- Copy the image into your 'feature/images' folder. Commit it as part of your test source code.
- Done. Now your tests will run, anywhere your code is available.
##ToDo
- Java Api - for assertion
- .net Api - for assertion
- Chrome extension to capture image
- IE extension to capture image