Class: Headless

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_patch.rb,
lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_patch.rb

Overview

Until github.com/leonid-shevtsov/headless/pull/106 is released in stable version

Defined Under Namespace

Classes: VideoRecorder

Instance Method Summary collapse

Instance Method Details

#take_screenshot(file_path, options = {}) ⇒ void

This method returns an undefined value.

Fix incorrect taking of screenshots

Parameters:

  • file_path (String)

    Path to store screenshot

  • options (Hash) (defaults to: {})

    Different options



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_patch.rb', line 7

def take_screenshot(file_path, options={})
  using = options.fetch(:using, :imagemagick)
  case using
  when :imagemagick
    CliUtil.ensure_application_exists!('import', "imagemagick is not found on your system. Please install it using sudo apt-get install imagemagick")
    system "#{CliUtil.path_to('import')} -display :#{display} -window root #{file_path}"
  when :xwd
    CliUtil.ensure_application_exists!('xwd', "xwd is not found on your system. Please install it using sudo apt-get install X11-apps")
    system "#{CliUtil.path_to('xwd')} -display localhost:#{display} -silent -root -out #{file_path}"
  when :graphicsmagick, :gm
    CliUtil.ensure_application_exists!('gm', "graphicsmagick is not found on your system. Please install it.")
    system "#{CliUtil.path_to('gm')} import -display localhost:#{display} -window root #{file_path}"
  else
    raise Headless::Exception.new('Unknown :using option value')
  end
end