Sha256: d1e1d1968b1badc3743f1258d4a43188536abb3c47e07a2a69459cfedb302de2

Contents?: true

Size: 790 Bytes

Versions: 20

Compression:

Stored size: 790 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', &:read)[0..3]).to eq png_header
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
watir-7.1.0 spec/watirspec/screenshot_spec.rb
watir-7.0.0 spec/watirspec/screenshot_spec.rb
watir-7.0.0.beta5 spec/watirspec/screenshot_spec.rb
watir-7.0.0.beta4 spec/watirspec/screenshot_spec.rb
watir-7.0.0.beta3 spec/watirspec/screenshot_spec.rb
watir-7.0.0.beta2 spec/watirspec/screenshot_spec.rb
watir-7.0.0.beta1 spec/watirspec/screenshot_spec.rb
watir-6.19.1 spec/watirspec/screenshot_spec.rb
watir-6.19.0 spec/watirspec/screenshot_spec.rb
watir-6.18.0 spec/watirspec/screenshot_spec.rb
watir-6.17.0 spec/watirspec/screenshot_spec.rb
watir-6.16.5 spec/watirspec/screenshot_spec.rb
watir-6.16.4 spec/watirspec/screenshot_spec.rb
watir-6.16.3 spec/watirspec/screenshot_spec.rb
watir-6.16.2 spec/watirspec/screenshot_spec.rb
watir-6.16.1 spec/watirspec/screenshot_spec.rb
watir-6.16.0 spec/watirspec/screenshot_spec.rb
watir-6.15.1 spec/watirspec/screenshot_spec.rb
watir-6.15.0 spec/watirspec/screenshot_spec.rb
watir-6.14.0 spec/watirspec/screenshot_spec.rb