Module: OnlyofficeWebdriverWrapper::HeadlessVideoRecorder

Included in:
HeadlessHelper
Defined in:
lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_video_recorder.rb

Overview

Methods to record video

Instance Method Summary collapse

Instance Method Details

#recorded_video_fileString

Returns uniq file path to recorded file.

Returns:

  • (String)

    uniq file path to recorded file



7
8
9
10
11
12
13
14
15
# File 'lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_video_recorder.rb', line 7

def recorded_video_file
  return @recorded_video_file if @recorded_video_file

  file_pattern = 'onlyoffice_webdriver_wrapper_video_file'
  temp_file = Tempfile.new([file_pattern, '.mp4'])
  @recorded_video_file = temp_file.path
  temp_file.unlink
  @recorded_video_file
end

#start_capturenil

Returns start capture of file.

Returns:

  • (nil)

    start capture of file



18
19
20
21
22
23
# File 'lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_video_recorder.rb', line 18

def start_capture
  headless_instance.video.start_capture if record_video
rescue Headless::Exception => e
  OnlyofficeLoggerHelper.log("Cannot start video capture: #{e}")
  @record_video = false
end

#stop_capturenil

Returns stop capture of file.

Returns:

  • (nil)

    stop capture of file



26
27
28
29
30
31
32
33
34
# File 'lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_video_recorder.rb', line 26

def stop_capture
  return unless record_video

  headless_instance.video.stop_and_save(recorded_video_file)
  OnlyofficeLoggerHelper.log("Video is saved to #{recorded_video_file}")
rescue Headless::Exception => e
  OnlyofficeLoggerHelper.log("Saving recorded video failed: #{e}")
  @record_video = false
end