Module: Selenium::WebDriver::DriverExtensions::PrintsPage

Defined in:
lib/selenium/webdriver/common/driver_extensions/prints_page.rb

Instance Method Summary collapse

Instance Method Details

Return a Base64 encoded Print Page as a string



50
51
52
53
54
55
# File 'lib/selenium/webdriver/common/driver_extensions/prints_page.rb', line 50

def print_page(**options)
  options[:pageRanges] = Array(options.delete(:page_ranges)) || []
  options[:shrinkToFit] = options.delete(:shrink_to_fit) { true }

  @bridge.print_page(options)
end

#save_print_page(path, **options) ⇒ Object

Save a page as a PDF to the given path

Examples:

Save Printed Page

driver.save_print_page('../printed_page.pdf')

Parameters:

  • path (String)

    to where the pdf should be saved



35
36
37
38
39
40
# File 'lib/selenium/webdriver/common/driver_extensions/prints_page.rb', line 35

def save_print_page(path, **options)
  File.open(path, 'wb') do |file|
    content = Base64.decode64 print_page(**options)
    file << content
  end
end