31 lines
809 B
Ruby
31 lines
809 B
Ruby
module Snapshot
|
|
|
|
SS_PATH = 'snapshots.html'
|
|
|
|
def set_up_snapshot(filepath = SS_PATH)
|
|
@size = [1280, 720] #arbitrary
|
|
@file = File.new(filepath, "w+")
|
|
@file.puts "<HTML><BODY BGCOLOR=grey>"
|
|
@file.puts "<H1>Snapshot #{ENV["BUILD_NUMBER"]} - #{@size[0]}x#{@size[1]}</H1>"
|
|
end
|
|
|
|
def snapshot_example
|
|
page.driver.resize(@size[0], @size[1])
|
|
@file.puts "<H3>Example name: #{get_description}</H3><BR><BR>"
|
|
end
|
|
|
|
def snap!(title = get_description)
|
|
base64 = page.driver.render_base64(:png)
|
|
@file.puts '<H3>' + title + '</H3>'
|
|
@file.puts '<img alt="' + title +'" src="data:image/png;base64,' + base64 + '" />'
|
|
@file.puts '<BR><BR><BR>'
|
|
end
|
|
|
|
def tear_down_snapshot
|
|
@file.puts "</BODY></HTML>"
|
|
@file.close()
|
|
end
|
|
|
|
end
|
|
|