Module: BrowserShooter::Commands::Screenshots

Defined in:
lib/browser_shooter/commands/screenshots.rb

Instance Method Summary collapse

Instance Method Details

#shot(sufix = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/browser_shooter/commands/screenshots.rb', line 5

def shot( sufix = nil )
  sufix     = BrowserShooter::Utils.timestamp unless sufix
  shot_path = "#{output_path}/shots/#{sufix}.png"

  BrowserShooter::Logger.log "shooting in '#{shot_path}'"

  FileUtils.mkdir_p( File.dirname( shot_path ) )
  driver.save_screenshot( shot_path )

  return shot_path
end

#shot_system(sufix = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/browser_shooter/commands/screenshots.rb', line 17

def shot_system( sufix = nil )
  sufix     = BrowserShooter::Utils.timestamp unless sufix
  shot_path = "#{output_path}/shots/#{sufix}.png"

  BrowserShooter::Logger.log "shooting system in '#{shot_path}'"

  FileUtils.mkdir_p( File.dirname( shot_path ) )

  command = "VBoxManage controlvm '#{browser.vm}' screenshotpng '#{shot_path}'"
  success = Kernel.system( command )

  if( !success )
    raise SystemCallError, "Shoot system command [#{command}] returns error: '#{$?}'"
  end

  return shot_path
end