Sha256: bb33a11ee4c7e3fd621439a43e0ac615d1abaa374d285c4741176657984f3bd0

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path('../watirspec_helper', __FILE__)

# These tests use the clipboard gem.  On GNU/Linux, this gem requires
# the xclip package to be installed.  On Windows and Mac, it should
# work out of the box.
require 'clipboard'

describe 'Browser' do

  before :each do
    Clipboard.clear
    browser.url = fixture('input_fields_value.html')
    window.find_by_id('one').click
    browser.select_all
  end

  describe '#select_all' do
    it 'selects the value of an input field' do
      window.eval_js('one = document.getElementById("one");')
      window.eval_js('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
    end
  end

  describe '#copy' do
    it 'copies a string to the keyboard' do
      browser.copy
      Clipboard.paste.should == 'foobar'
    end

    it 'leaves the copied string alone' do
      browser.copy
      window.find_by_id('one').value.should == 'foobar'
    end
  end

  describe '#cut' do
    it 'copies a string to the keyboard' do
      browser.cut
      Clipboard.paste.should == 'foobar'
    end

    it 'removes the cut string' do
      browser.cut
      window.find_by_id('one').value.should == ''
    end
  end

  describe '#paste' do
    it 'pastes a copied string' do
      browser.copy
      window.find_by_id('two').click
      browser.paste
      window.find_by_id('two').value.should == 'foobar'
    end

    it 'pastes a cut string' do
      browser.cut
      window.find_by_id('two').click
      browser.paste
      window.find_by_id('two').value.should == 'foobar'
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
operawatir-0.4-jruby spec/new_watirspec/clipboard_spec.rb
operawatir-0.3.7.pre2-jruby spec/new_watirspec/clipboard_spec.rb
operawatir-0.3.7.pre1-jruby spec/new_watirspec/clipboard_spec.rb