Sha256: 840a56e1f6ebaf410350299e76f5fbcd2f5c2f33898fadf5f72586476ae5d7e7

Contents?: true

Size: 799 Bytes

Versions: 38

Compression:

Stored size: 799 Bytes

Contents

require "base64"
require "watirspec_helper"

describe "Watir::Screenshot" do
  let(:png_header) { "\211PNG".force_encoding('ASCII-8BIT') }

  describe '#png' do
    it 'gets png representation of screenshot' do
      expect(browser.screenshot.png[0..3]).to eq png_header
    end
  end

  describe '#base64' do
    it 'gets base64 representation of screenshot' do
      image = browser.screenshot.base64
      expect(Base64.decode64(image)[0..3]).to eq png_header
    end
  end

  describe '#save' do
    it 'saves screenshot to given file' do
      path = "#{Dir.tmpdir}/test#{Time.now.to_i}.png"
      expect(File).to_not exist(path)
      browser.screenshot.save(path)
      expect(File).to exist(path)
      expect(File.open(path, "rb") { |io| io.read }[0..3]).to eq png_header
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
watir-6.13.0 spec/watirspec/screenshot_spec.rb
watir-6.12.0 spec/watirspec/screenshot_spec.rb
watir-6.11.0 spec/watirspec/screenshot_spec.rb
watir-6.11.0.beta2 spec/watirspec/screenshot_spec.rb
watir-6.11.0.beta1 spec/watirspec/screenshot_spec.rb
watir-6.10.3 spec/watirspec/screenshot_spec.rb
watir-6.10.2 spec/watirspec/screenshot_spec.rb
watir-6.10.0 spec/watirspec/screenshot_spec.rb
watir-6.9.1 spec/watirspec/screenshot_spec.rb
watir-6.9.0 spec/watirspec/screenshot_spec.rb
watir-6.8.4 spec/watirspec/screenshot_spec.rb
watir-6.8.3 spec/watirspec/screenshot_spec.rb
watir-6.8.2 spec/watirspec/screenshot_spec.rb
watir-6.8.1 spec/watirspec/screenshot_spec.rb
watir-6.8.0 spec/watirspec/screenshot_spec.rb
watir-6.7.3 spec/watirspec/screenshot_spec.rb
watir-6.7.2 spec/watirspec/screenshot_spec.rb
watir-6.7.1 spec/watirspec/screenshot_spec.rb
watir-6.7.0 spec/watirspec/screenshot_spec.rb
watir-6.6.3 spec/watirspec/screenshot_spec.rb