Module: QAT::Web::Browser::HTMLDump
- Extended by:
- HTMLDump
- Includes:
- Logger
- Included in:
- HTMLDump
- Defined in:
- lib/qat/web/browser/html_dump.rb
Overview
Module to handle browser HTML dumps.
Instance Method Summary collapse
-
#html_dump_path ⇒ String
Default HTML dump path.
-
#html_dump_path=(path) ⇒ Object
Set new default HTML dump path.
-
#take_html_dump(page = Capybara.current_session, path = html_dump_path) ⇒ String/NilClass
Function to take a browser HTML dump.
Instance Method Details
#html_dump_path ⇒ String
Default HTML dump path. Can be set with #html_dump_path=.
33 34 35 |
# File 'lib/qat/web/browser/html_dump.rb', line 33 def html_dump_path @html_dump_path || ::File.join('public', "browser_#{Time.new.strftime("%H%M%S%L")}.html") end |
#html_dump_path=(path) ⇒ Object
Set new default HTML dump path.
40 41 42 |
# File 'lib/qat/web/browser/html_dump.rb', line 40 def html_dump_path=(path) @html_dump_path = path end |
#take_html_dump(page = Capybara.current_session, path = html_dump_path) ⇒ String/NilClass
Function to take a browser HTML dump. Will handle the usage of driver that don’t support HTML dumps.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/qat/web/browser/html_dump.rb', line 19 def take_html_dump(page=Capybara.current_session, path=html_dump_path) log.info { "Saving HTML dump to #{path}" } raise ArgumentError.new "File #{path} already exists! Choose another filename" if ::File.exists? path path = page.save_page path log.info { "HTML dump available" } ::File.basename(path) rescue Capybara::NotSupportedByDriverError log.warn { "Driver #{page.mode} does not support HTML dumps!" } return nil end |