module Capybara::Apparition::Browser::Render

Constants

PAPER_SIZES

Attributes

zoom_factor[W]

Public Instance Methods

paper_size=(size) click to toggle source
# File lib/capybara/apparition/browser/render.rb, line 19
def paper_size=(size)
  @paper_size = if size.is_a? Hash
    size
  else
    PAPER_SIZES.fetch(size) do
      raise_errors ArgumentError, "Unknwon paper size: #{size}"
    end
  end
end
render(path, options = {}) click to toggle source
# File lib/capybara/apparition/browser/render.rb, line 6
def render(path, options = {})
  check_render_options!(options, path)
  img_data = current_page.render(options)
  File.open(path, 'wb') { |f| f.write(Base64.decode64(img_data)) }
end
render_base64(options = {}) click to toggle source
# File lib/capybara/apparition/browser/render.rb, line 12
def render_base64(options = {})
  check_render_options!(options)
  current_page.render(options)
end

Private Instance Methods

check_render_options!(options, path = nil) click to toggle source
# File lib/capybara/apparition/browser/render.rb, line 31
def check_render_options!(options, path = nil)
  options[:format] ||= File.extname(path).downcase[1..-1] if path
  options[:format] = :jpeg if options[:format].to_s == 'jpg'
  options[:full] = !!options[:full]
  return unless options[:full] && options.key?(:selector)

  warn "Ignoring :selector in #render since :full => true was given at #{caller(1..1)}"
  options.delete(:selector)
end