-
-
Save adammw/9200791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'RMagick' | |
require 'capybara' | |
require 'launchy' | |
module Capybara::Recording | |
def start_recording | |
system "rm -f tmp/*" | |
end | |
def save_recording | |
anim = Magick::ImageList.new(*Dir.glob('tmp/*png')) | |
anim.delay = 200 | |
anim.write("tmp/animated.gif") | |
File.open("tmp/animated.html", "w") do |f| | |
f.puts "<img src='animated.gif'>" | |
end | |
end | |
def open_recording | |
Launchy.open("file:///#{Dir.pwd}/tmp/animated.html") | |
end | |
def _save_screenshot | |
save_screenshot "tmp/capybara-#{Time.now.to_f}.png" | |
end | |
(Capybara::Session::DSL_METHODS - [:save_screenshot]).each do |method| | |
define_method method do |*args| | |
super(*args) | |
_save_screenshot | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara' | |
require 'capybara/poltergeist' | |
require 'capybara-recording' | |
Capybara.current_driver = :poltergeist | |
include Capybara::DSL | |
include Capybara::Recording | |
record '/tmp/filename.gif' do | |
visit 'http://www.google.com/' | |
fill_in 'q', with: 'NYC' | |
click_button 'Google Search' | |
click_link "New York City - Wikipedia, the free encyclopedia" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment