unittests/form_test.rb in watir-1.9.0 vs unittests/form_test.rb in watir-1.9.1.rc1

- old
+ new

@@ -22,11 +22,11 @@ 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(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?) @@ -45,14 +45,16 @@ def test_form_outer_html expected = "\r\n<FORM id=f2 name=test2 action=pass2.html method=get><BR><INPUT type=submit value=Submit> </FORM>" actual = browser.form(:name, 'test2').html actual.sub!('style=""','') # ie9 adds in a style tag so just strip it out - + #ie9 also has som additional formatting so remove that too + actual.gsub!('"','') + actual.gsub!(/\n/,'') # ignore attributes order by sorting them sorted_expected, sorted_actual = [expected, actual].map! do |html| - html.strip.downcase.scan(%r{<form (.*)><br><(.*)> </form>}).flatten. + html.strip.downcase.scan(%r{<form (.*)><br><(.*)>\s*</form>}).flatten. map {|part| part.split(" ").sort.join(" ")}.join("><br><") end assert_not_equal("", sorted_expected) assert_not_equal("", sorted_actual) assert_equal(sorted_expected, sorted_actual) @@ -74,38 +76,41 @@ end def test_forms_collection forms = browser.forms assert_equal(4, forms.length) - assert_equal('pass.html', forms.first.action) + assert(forms.first.action =~ /pass.html$/) assert_equal('test2', forms.last.name) end end class TC_Form_Display < Test::Unit::TestCase include CaptureIOHelper def test_showforms goto_page "forms2.html" actual = capture_stdout { browser.showForms } - assert_equal(<<END_OF_MESSAGE, actual) + expected = <<END_OF_MESSAGE There are 4 forms -Form name: - id: +Form name: + id: method: get action: pass.html Form name: test2 id: f2 method: get action: pass2.html Form name: test3 - id: + id: method: get action: pass2.html Form name: test2 - id: + id: method: get action: pass2.html END_OF_MESSAGE + actual.gsub!(/(action: )file:.*\/(.*)$/,'\\1\\2') if actual =~ /file:/ + actual.gsub!(/\s+\n/,"\n") + assert_equal(expected, actual) end end class TC_Forms3 < Test::Unit::TestCase def setup