Sha256: e08bcc706af6ffdad6680a0032eb355d1aff6111dbde62dc358cea7d49137513

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 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_table
    goto_page "table1.html"
    assert_equal( "Header", browser.th(:css , ".sample th").text )
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
watir-classic-3.0.0 unittests/css_selector_test.rb
watir-3.0.0.rc3 unittests/css_selector_test.rb