class CapCap::Main
Public Instance Methods
add_headers(headers)
click to toggle source
# File lib/cap_cap.rb, line 84 def add_headers headers page.driver.add_headers headers end
capture(url, output = nil, selector: nil)
click to toggle source
# File lib/cap_cap.rb, line 58 def capture url, output = nil, selector: nil visit url output = Tempfile.open(["capcap", ".png"]).path if output.nil? opt = if selector.nil? then {full: true} else {selector: selector} end save_screenshot output, opt output end
capture_combined(outputs, output = nil)
click to toggle source
# File lib/cap_cap.rb, line 71 def capture_combined outputs, output = nil visit "about:blank" output = Tempfile.open(["capcap", ".png"]).path if output.nil? imgs = outputs.map {|src| %Q|<img src="file://#{src}" />| } html = %Q|<table id="canvas" border=0><tr><td valign=top>#{imgs.join("</td><td valign=top>")}</td></tr></table>| script = %Q|document.body.innerHTML = '#{html}';| evaluate_script script save_screenshot output, selector: "#canvas" output end
invoke_open(path)
click to toggle source
# File lib/cap_cap.rb, line 66 def invoke_open path `open #{path}` sleep 2 end
resize(w, h)
click to toggle source
# File lib/cap_cap.rb, line 88 def resize w, h page.driver.resize w, h end