Sha256: 5f88da7aee1f9a7cd504e6fcf5c4cf11e3d5a6334e4345f9f754fb18d86e7553

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

# feature tests for element and the elements collection

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
require 'unittests/setup'

class TC_Elements < Test::Unit::TestCase
  include Watir::Exception
  
  def setup
    uses_page "div.html"
  end
  
  def test_element
    assert_raises(UnknownObjectException) { browser.element(:id, "div77").click }
    assert_raises(UnknownObjectException) { browser.element(:title, "div77").click }
    assert_equal 'div2', browser.element(:class, 'blueText').id  
    assert_equal 'blueText', browser.element(:id, /div2/).class_name
    assert_equal Watir::HTMLElement, browser.element(:id, 'div2').class
  end
  
  def test_element_iterator
    assert_equal 3, browser.elements(:class, 'blueText').length
    assert_equal 3, browser.elements(:class, 'blueText').size
    assert_equal("span2", browser.elements(:class, 'blueText')[2].id)
    
    index = 0
    browser.elements(:id, /div/).each do |s|
      assert_equal(browser.div(:index,index).name, s.name)
      assert_equal(browser.div(:index,index).id, s.id)
      assert_equal(browser.div(:index,index).class_name , s.class_name)
      index += 1
    end
    assert_equal(index, browser.elements(:id, /div/).length)
  end
  
  def test_element_enumerable
    match = browser.elements(:class, 'blueText').detect {|d| d.html =~ /SPAN/}
    assert_equal('span2', match.id)
  end
  
  def test_objects_in_element
    assert browser.element(:id, 'buttons1').button(:index,0).exists? 
    assert !browser.element(:id, 'buttons1').button(:index,2).exists? 
    assert browser.element(:id, 'buttons1').button(:name,'b1').exists? 
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
watir-3.0.0.rc2 unittests/element_test.rb
watir-3.0.0.rc1 unittests/element_test.rb
watir-2.0.4 unittests/element_test.rb
watir-2.0.3 unittests/element_test.rb
watir-2.0.2 unittests/element_test.rb
watir-2.0.2.rc1 unittests/element_test.rb
watir-2.0.1 unittests/element_test.rb
watir-2.0.0 unittests/element_test.rb
watir-2.0.0.rc3 unittests/element_test.rb
watir-2.0.0.rc2 unittests/element_test.rb