Class | Selenium::RSpec::Reporting::SystemCapture
In: | lib/selenium/rspec/reporting/system_capture.rb
Parent: | Object

### Methods

capture_html_snapshot capture_page_screenshot capture_system_screenshot capture_system_state new retrieve_remote_control_logs

### Public Class methods

new(selenium_driver, example, file_path_strategy)

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 7
     7:         def initialize(selenium_driver, example, file_path_strategy)
     8:           @selenium_driver = selenium_driver
     9:           @example = example
    10:           @file_path_strategy = file_path_strategy
    11:         end

### Public Instance methods

capture_html_snapshot()

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 39
    39:         def capture_html_snapshot
    40:           # Skipping HTML Snapshot retrieval, if there is no current Selenium session
    41:           return  unless @selenium_driver.session_started?
    42:
    43:           html = @selenium_driver.get_html_source
    44:           File.open(@file_path_strategy.file_path_for_html_capture(@example), "w") { |f| f.write html }
    45:         end

capture_page_screenshot()

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 55
    55:         def capture_page_screenshot
    56:           return unless @selenium_driver.chrome_backend? && @selenium_driver.session_started?
    57:
    58:           encodedImage = @selenium_driver.capture_entire_page_screenshot_to_string("")
    59:           pngImage = Base64.decode64(encodedImage)
    60:           File.open(@file_path_strategy.file_path_for_page_screenshot(@example), "wb") { |f| f.write pngImage }
    61:         end

capture_system_screenshot()

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 47
    47:         def capture_system_screenshot
    48:           @selenium_driver.window_maximize if @selenium_driver.session_started?
    49:
    50:           encodedImage = @selenium_driver.capture_screenshot_to_string
    51:           pngImage = Base64.decode64(encodedImage)
    52:           File.open(@file_path_strategy.file_path_for_system_screenshot(@example), "wb") { |f| f.write pngImage }
    53:         end

capture_system_state()

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 13
    13:         def capture_system_state
    14:           # Selenium RC seems to 'freeze' every so often when calling
    15:           # getHTMLSource, especially when DeepTest timeout is low, I need to investigate...
    16:           # Set deeptest :timeout_in_seconds => 30 to see it happen
    17:           begin
    18:             retrieve_remote_control_logs
    19:           rescue Exception => e
    20:             STDERR.puts "WARNING: Could not retrieve remote control logs: #{e}"
    21:           end
    22:           begin
    23:             capture_html_snapshot
    24:           rescue Exception => e
    25:             STDERR.puts "WARNING: Could not capture HTML snapshot: #{e}"
    26:           end
    27:           begin
    28:             capture_page_screenshot
    29:           rescue Exception => e
    30:             STDERR.puts "WARNING: Could not capture page screenshot: #{e}"
    31:           end
    32:           begin
    33:             capture_system_screenshot
    34:           rescue Exception => e
    35:             STDERR.puts "WARNING: Could not capture system screenshot: #{e}"
    36:           end
    37:         end

retrieve_remote_control_logs()

[Source]

        # File lib/selenium/rspec/reporting/system_capture.rb, line 63
    63:         def retrieve_remote_control_logs
    64:           logs = @selenium_driver.retrieve_last_remote_control_logs
    65:           File.open(@file_path_strategy.file_path_for_remote_control_logs(@example), "w") { |f| f.write logs }
    66:         end

[Validate]