22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/crocodile.rb', line 22
def self.snap(host, url, dest, options, &block)
start if options[:start]
browser = Selenium::Client::Driver.new(
:host => HOST || options[:host],
:port => PORT || options[:port],
:timeout_in_second => TIMEOUT || options[:timeout],
:browser => "*firefox",
:url => host)
browser.start_new_browser_session
browser.open url
browser.get_eval "window.resizeTo(#{options[:width]},#{options[:height]});" if (options[:width] && options[:height])
yield browser if block
browser.capture_entire_page_screenshot File.join(File.expand_path('.'), dest), ''
browser.close_current_browser_session
ensure
stop if options[:stop]
end
|