Sha256: 2f5ed3aebe30f7bbbdb3d8e39ea1fcbdd317d910105e71516c01676f18f8d5f4

Contents?: true

Size: 1.57 KB

Versions: 10

Compression:

Stored size: 1.57 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.execute_script('one = document.getElementById("one");')
      window.execute_script('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

10 entries across 10 versions & 1 rubygems

Version Path
operawatir-0.4.3.pre1-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.2-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre7-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre6-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre5-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre4-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre3-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre2-jruby spec/watir3/clipboard_spec.rb
operawatir-0.4.1.pre1-jruby spec/watir3/clipboard_spec.rb