Class: OperaWatir::Screenshot
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#reply ⇒ Object
Returns the value of attribute reply.
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Is the screenshot blank?.
-
#initialize(parent) ⇒ Screenshot
constructor
A new instance of Screenshot.
-
#md5 ⇒ String
Lets you get a MD5 sum of the screen.
-
#png ⇒ String
Returns the raw byte string of the screenshot in PNG format.
-
#save(filename) ⇒ String
Saves screenshot to specified location.
Constructor Details
#initialize(parent) ⇒ Screenshot
Returns a new instance of Screenshot.
5 6 7 8 |
# File 'lib/operawatir/screenshot.rb', line 5 def initialize(parent) self.browser = parent.browser self.reply = driver.saveScreenshot(2, [].to_java(:string)) end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
3 4 5 |
# File 'lib/operawatir/screenshot.rb', line 3 def browser @browser end |
#reply ⇒ Object
Returns the value of attribute reply.
3 4 5 |
# File 'lib/operawatir/screenshot.rb', line 3 def reply @reply end |
Instance Method Details
#blank? ⇒ Boolean
Is the screenshot blank?
22 23 24 |
# File 'lib/operawatir/screenshot.rb', line 22 def blank? reply.isBlank end |
#md5 ⇒ String
Lets you get a MD5 sum of the screen.
36 37 38 |
# File 'lib/operawatir/screenshot.rb', line 36 def md5 reply.getMd5 end |
#png ⇒ String
Returns the raw byte string of the screenshot in PNG format.
29 30 31 |
# File 'lib/operawatir/screenshot.rb', line 29 def png String.from_java_bytes reply.getPng end |
#save(filename) ⇒ String
Saves screenshot to specified location.
14 15 16 17 |
# File 'lib/operawatir/screenshot.rb', line 14 def save(filename) File.open(filename, 'w') { |f| f.write png } File. filename end |