16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/crabfarm/modes/recorder/memento.rb', line 16
def start(_target, _replay=false)
return puts "Must provide a recording target" unless _target.is_a? String
target_path = memento_path _target
return puts "Memento file does not exist: #{target_path}" if _replay and not File.exist? target_path
start_crabtrap _replay, target_path
begin
driver = build_driver Crabfarm.config.recorder_driver
return puts "Invalid recorder_driver name '#{Crabfarm.config.recorder_driver}'" if driver.nil?
begin
puts "Press Ctrl-C or close browser to stop #{_replay ? 'playback' : 'capturing'}."
loop do
driver.window_handle
sleep 1.0
end
rescue Exception => e
puts e
puts e.backtrace
end
puts "Releasing crawling context".color(:green)
driver.quit rescue nil
ensure
crabtrap.stop
end
end
|