Class | Selenium::RSpec::Reporting::SystemCapture |
In: |
lib/selenium/rspec/reporting/system_capture.rb
|
Parent: | Object |
# 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
# 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
# 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
# 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
# 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