Class: Watirmark::Screenshot::Current
- Defined in:
- lib/watirmark/screenshot.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#screenheight ⇒ Object
Returns the value of attribute screenheight.
-
#screenwidth ⇒ Object
Returns the value of attribute screenwidth.
Instance Method Summary collapse
- #get_screen_size ⇒ Object
-
#initialize(snapshotwidth = Watirmark::Configuration.instance.snapshotwidth) ⇒ Current
constructor
A new instance of Current.
- #md5 ⇒ Object
- #revert_window_size ⇒ Object
- #take_screen_shot(snapshotwidth) ⇒ Object
- #update_window_size(width) ⇒ Object
Constructor Details
#initialize(snapshotwidth = Watirmark::Configuration.instance.snapshotwidth) ⇒ Current
Returns a new instance of Current.
75 76 77 78 79 80 |
# File 'lib/watirmark/screenshot.rb', line 75 def initialize(snapshotwidth=Watirmark::Configuration.instance.snapshotwidth) get_screen_size FileUtils.mkdir_p('reports/screenshots') take_screen_shot(snapshotwidth) revert_window_size end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
73 74 75 |
# File 'lib/watirmark/screenshot.rb', line 73 def filename @filename end |
#screenheight ⇒ Object
Returns the value of attribute screenheight.
73 74 75 |
# File 'lib/watirmark/screenshot.rb', line 73 def screenheight @screenheight end |
#screenwidth ⇒ Object
Returns the value of attribute screenwidth.
73 74 75 |
# File 'lib/watirmark/screenshot.rb', line 73 def screenwidth @screenwidth end |
Instance Method Details
#get_screen_size ⇒ Object
96 97 98 99 100 |
# File 'lib/watirmark/screenshot.rb', line 96 def get_screen_size size = Page.browser.window.size @screenwidth = size.width @screenheight = size.height end |
#md5 ⇒ Object
88 89 90 |
# File 'lib/watirmark/screenshot.rb', line 88 def md5 Digest::MD5.hexdigest(File.read(@filename)) end |
#revert_window_size ⇒ Object
102 103 104 |
# File 'lib/watirmark/screenshot.rb', line 102 def revert_window_size Page.browser.window.resize_to(@screenwidth, @screenheight) end |
#take_screen_shot(snapshotwidth) ⇒ Object
82 83 84 85 86 |
# File 'lib/watirmark/screenshot.rb', line 82 def take_screen_shot(snapshotwidth) update_window_size(snapshotwidth) @filename = "reports/screenshots/#{UUID.new.generate(:compact)}.png" Page.browser.screenshot.save @filename end |
#update_window_size(width) ⇒ Object
92 93 94 |
# File 'lib/watirmark/screenshot.rb', line 92 def update_window_size(width) Page.browser.window.resize_to(width, Watirmark::Configuration.instance.snapshotheight) end |