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_filename ⇒ Object
-
#html_dump_path ⇒ String
Default HTML dump path.
-
#html_dump_path=(path) ⇒ Object
Set new default HTML dump path.
-
#read_html_dump(page, dump_path) ⇒ Object
Helper for reading file, in cucumber 6 this could be reverted to path directly.
-
#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_filename ⇒ Object
46 47 48 |
# File 'lib/qat/web/browser/html_dump.rb', line 46 def html_dump_filename File.basename(@html_dump_path) end |
#html_dump_path ⇒ String
Default HTML dump path. Can be set with #html_dump_path=.
42 43 44 |
# File 'lib/qat/web/browser/html_dump.rb', line 42 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.
53 54 55 |
# File 'lib/qat/web/browser/html_dump.rb', line 53 def html_dump_path=(path) @html_dump_path = path end |
#read_html_dump(page, dump_path) ⇒ Object
Helper for reading file, in cucumber 6 this could be reverted to path directly
32 33 34 35 36 |
# File 'lib/qat/web/browser/html_dump.rb', line 32 def read_html_dump page, dump_path file = page.save_page dump_path dump_path_read = File.open file dump_path_read.read 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) raise ArgumentError.new "File #{path} already exists! Choose another filename" if ::File.exist? path log.info { "Saving HTML dump to #{path}" } path = read_html_dump page ,path log.info { "HTML dump available" } path rescue Capybara::NotSupportedByDriverError log.warn { "Driver #{page.mode} does not support HTML dumps!" } return nil end |