Return content of image as base64-encoded png
Add this line to your application's Gemfile:
gem 'watir-get-image-content'
And then execute:
$ bundle
Or install it yourself as:
$ gem install watir-get-image-content
require 'watir-webdriver'
require 'watir-get-image-content'
browser = Watir::Browser.new
browser.goto 'http://for_example.com/page_with_images'
browser.image(:index, 1).to_png_base64
browser.image(:alt, 'Alt text').to_png_base64
browser.image(:index, 1).to_jpg_base64
browser.image(:alt, 'Alt text').to_jpg_base64
File.write('png.png', browser.image(:index, 1).to_png)
File.write('jpg.jpg', browser.image(:index, 1).to_jpg)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request