Sha256: 44f5be99c73b8b085261d0a02b07c8d1bad4bb3212ea1cfd9a604b29c1e8c570

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

# feature tests for attaching to existing IE windows
# revision: $Revision: 1230 $

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') if $0 == __FILE__
require 'unittests/setup'

class TC_ExistingWindow< Test::Unit::TestCase
  include Watir

  def setup
    $ie.goto($htmlRoot + 'buttons1.html')
  end
  def teardown
    IE.reset_attach_timeout
  end

  def test_find_window
    ie = IE.find(:title, 'Test page for buttons')
    assert_equal("Test page for buttons", ie.title)
  end
  
  def test_find_window_misses
    ie = IE.find(:title, 'no such window')
    assert_nil ie
  end

  def test_missing_window
    IE.attach_timeout = 0.1
    assert_raises(NoMatchingWindowFoundException) { IE.attach(:title, "missing") }
    assert_raises(NoMatchingWindowFoundException) { IE.attach(:title, /missing/) }
    assert_raises(NoMatchingWindowFoundException) { IE.attach(:url, "missing") }
    assert_raises(NoMatchingWindowFoundException) { IE.attach(:url, /missing/) }
  end    
  
  def test_existing_window
    ie3 = nil
    ie3 = IE.attach(:title , /buttons/i)
    assert_equal("Test page for buttons", ie3.title)
    ie3 = nil
    
    ie3 = IE.attach(:title , "Test page for buttons")
    assert_equal("Test page for buttons", ie3.title)
    ie3 = nil
    
    ie3 = IE.attach(:url, /buttons1.html/)
    assert_equal("Test page for buttons", ie3.title)
    ie3 = nil
    
    #hard to test :url with explicit text
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-1.5.2 unittests/windows/attach_to_existing_window_test.rb
watir-1.5.3 unittests/windows/attach_to_existing_window_test.rb
watir-1.5.4 unittests/windows/attach_to_existing_window_test.rb