# feature tests for Forms $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED require 'unittests/setup' class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms1 def setup uses_page "forms2.html" end def test_form_exists assert(browser.form(:name, "test2").exists?) assert_false(browser.form(:name, "missing").exists?) assert(browser.form("test2").exists?) assert_false(browser.form("missing").exists?) assert(browser.form(:index, 1).exists?) assert_false(browser.form(:index, 88).exists?) assert(browser.form(:method, "get").exists?) assert_false(browser.form(:method, "missing").exists?) assert(browser.form(:id, 'f2').exists?) assert_false(browser.form(:id, 'missing').exists?) assert(browser.form(:action, "pass.html").exists?) assert_false(browser.form(:action, "missing").exists?) end def test_multiple_attribute assert_true(browser.form(:name => 'test2', :id => 'f2').exists?) assert_true(browser.form(:name => 'test2', :method => 'get', :action => 'pass2.html')) end def test_button_in_form assert(browser.form(:name, "test2").button(:caption, "Submit").exists?) end def test_form_sub_element assert_equal('Click Me', browser.form(:index, 1).button(:name, 'b1').value) end # The following tests form bug 2261 tag_method :test_form_outer_html, :fails_on_firefox def test_form_outer_html expected = "\r\n
" actual = browser.form(:name, 'test2').html actual.sub!('style=""','') # ie9 adds in a style tag so just strip it out # ignore attributes order by sorting them sorted_expected, sorted_actual = [expected, actual].map! do |html| html.strip.downcase.scan(%r{}).flatten. map {|part| part.split(" ").sort.join(" ")}.join(">