module WDA::Screenshot
Public Instance Methods
screenshot(path, scale = 100)
click to toggle source
Take a screenshot and save to the given path. Format: png.
Example: screenshot '/screenshot_folder/screenshot.png'
@param path [String] the full path to save the png @return screenshot result [Hash]
# 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