Module: WDA::Screenshot
- Included in:
- WDA
- Defined in:
- lib/wda_lib/screenshot.rb
Instance Method Summary collapse
-
#screenshot(path, scale = 100) ⇒ Object
Take a screenshot and save to the given path.
Instance Method Details
#screenshot(path, scale = 100) ⇒ Object
Take a screenshot and save to the given path. Format: png.
Example: screenshot ‘/screenshot_folder/screenshot.png’
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wda_lib/screenshot.rb', line 15 def screenshot(path, scale = 100) path.include?('.png')? path : path += '.png' response = get(@base_url + '/screenshot?scale=' + scale) begin File.open(path, 'wb') {|f| f.write Base64.decode64(response['value']) } rescue IOError => e raise "Fail to save to #{path}, error: #{e}" end p "Screenshot is saved to #{path}" return { sessionId: response['sessionId'], status: response['status'] } end |