Sha256: fbb3cce8ddbe597f2b1b5578aa4c63dc18d9cdbb0ecb8a1f41d334377b21a694

Contents?: true

Size: 1.74 KB

Versions: 3

Compression:

Stored size: 1.74 KB

Contents

# Feature tests for CSS selectors.
#
# Only shallow testing is needed since the selectors are immediately 
# converted to xpath and the other xpath tests will provide coverage 
# for the returned objects. This test more or less only verifies that the 
# respective classes have implemented the css selector as a query option.
#

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

class TC_CSS_Selector < Test::Unit::TestCase
  include Watir::Exception

  # Same test as TC_Divs_XPath::test_divs but using css selectors instead
  def test_matching_queries
    goto_page "div.html"

    assert_raises(UnknownObjectException) {browser.div(:css , "div[id='div77']").click }
    assert_raises(UnknownObjectException) {browser.div(:css , "div[title='div77']").click }

    assert(browser.text_field(:css, "input[name='text1']").verify_contains("0") )  
    browser.div(:css , "div[id='div3']").click
    assert(browser.text_field(:css, "input[ name = 'text1' ]").verify_contains("1") )  
    browser.div(:css , "div[id = div4]").click
    assert(browser.text_field(:css, "input[name=text1]").verify_contains("0") )  
  end

  def test_form
    goto_page "forms2.html"
    assert(browser.form(:css, "#f2").action =~ /pass2.html$/)
    assert_equal(browser.button(:css, "form #b2").value, "Click Me")
  end

  def test_image
    goto_page "div.html"
    assert_equal( "circle", browser.image(:css, "*[id ^= 'circ']").id )
  end

  def test_link
    goto_page "links1.html"
    assert_equal( "link_name", browser.link(:css, "*[name *= ink_nam]").name )
  end

  def test_table
    goto_page "table1.html"
    assert_equal( "Header", browser.cell(:css , ".sample th").text )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-3.0.0.rc2 unittests/css_selector_test.rb
watir-3.0.0.rc1 unittests/css_selector_test.rb
watir-2.0.4 unittests/css_selector_test.rb