5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ruby_webshot.rb', line 5
def self.call(url_to_shot, args = {})
return nil if url_to_shot.nil?
initialize
options = args
file_name = options[:file_name] || "#{Time.now.strftime("%d-%m-%Y-%H%M%S")}.png"
p file_name
save_file_path = options[:save_file_path] ? "#{options[:save_file_path]}/#{file_name}" : "#{Dir.pwd}/#{file_name}"
p save_file_path
width = options[:width] || 860
height = options[:height] || 860
@driver.navigate.to url_to_shot
@driver.manage.window.resize_to(width, height)
@driver.save_screenshot save_file_path
finalize
end
|