Sha256: 0c0220fa3d6be3b44c8aff935ba49327c9ea78a3e735788d03d8867ee56aaec7
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'fileutils' require 'selenium/webdriver' module Janus class Screenshot attr_accessor :test, :image def self.capture(test, options = {}) driver = Selenium::WebDriver.for(:remote, { url: "http://#{options[:username]}:#{options[:access_key]}@ondemand.saucelabs.com/wd/hub", desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome }) driver.get(test.url) Screenshot.new(test: test, image: driver.screenshot_as(:png)) end def self.load(test, options = {}) path = File.join(options[:path], "#{test.name}.janus", 'screenshot.png') image = IO.read(path, mode: 'rb') Screenshot.new(test: test, image: image) end def initialize(parameters = {}) @test = parameters[:test] @image = parameters[:image] end def save(path) directory = File.join(path, "#{test.name}.janus") FileUtils.mkpath(directory) unless Dir.exists?(directory) IO.write(File.join(directory, 'screenshot.png'), @image, mode: 'wb') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
janus-cli-0.1.0 | lib/janus/screenshot.rb |