BackgroundWhen I develop a web widget in work, I used to hate checking design with my eye.
So, I developed image_match to check it without my eye.
I’ll introduce it here.
- Linux 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
OverviewThe gem provides following 4 functions currently:
- To check whether the web page’s image is same as prepared image or not.
- To check whether a part of the web page’s image is same as prepared image(template) or not.
- To check whether a part of the web page’s image is seems to be close with prepared image(template) or not.
- To check whether a part of the web page’s image is same as prepared image(template) or not(ignoring size difference).
- Prepare expecting image
- Write test code with this gem
1. Prepare expecting imageI prepared following logo image.
2. Write test code with this gem
├── Gemfile ├── google-logo.jpg └── main.rb 0 directories, 3 files
GemfileI’ll use “capybara” and “poltergeist” to take screen shot.
If you use selenium rc, you can take screen shot with many type of browsers.
source 'https://rubygems.org' gem 'capybara' gem 'poltergeist' gem 'image_match'
Highlighted parts are related this gem.
Only 3 lines including ‘require’ and ‘include’!
Note that when prepared image’s size is different from logo image of screen shot, some times this script’s output is “Nothing…”.
If you meet the situation, please arrange the prepared image’s size or use “match_template_ignore_size”.
What!? Oh, I see. Today is a Japanese person’s aniversary. So today’s google logo is following.$ bundle install --path=.bundle $ bundle exec ruby main.rb Nothing...
OKay. I’ll try again another day. Following is another day’s result.
Yes! I thing most of you will use “complete_match_template” or “match_template_ignore_size”. I’ll do my best to eliminate checking web page desing with one’s eyes.$ bundle exec ruby main.rb Find!