unittests/selectbox_xpath_test.rb in watir-3.0.0.rc2 vs unittests/selectbox_xpath_test.rb in watir-3.0.0.rc3

- old
+ new

@@ -22,56 +22,43 @@ end def test_select_list_getAllContents assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getAllContents } assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] , - browser.select_list(:xpath, "//select[@name='sel1']/").getAllContents) + browser.select_list(:xpath, "//select[@name='sel1']/").options.map(&:text)) end def test_select_list_getSelectedItems assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems } assert_equal( ["Option 3" ] , - browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) + browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text)) assert_equal( ["Option 3" , "Option 6" ] , - browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems) + browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text)) end def test_clearSelection - assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").clearSelection } - browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection - - if Watir::IE.version_parts[0].to_i >= 9 - # ie9 allows you to clear a selected item even if it requires a selection - assert_equal( [] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) - else - # the box sel1 has no ability to have a de-selected item - assert_equal( ["Option 3" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) - end - browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection - assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems) + assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text)) end def test_select_list_select - assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems } + assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").selected_options.map(&:text) } assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select("missing item") } assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) } # the select method keeps any currently selected items - use the clear selectcion method first - browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection browser.select_list(:xpath, "//select[@name='sel1']/").select("Option 1") - assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) + assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text)) - browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection browser.select_list(:xpath, "//select[@name='sel1']/").select(/2/) - assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) + assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text)) browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ ) browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ ) assert_equal( ["Option 2" , "Option 4" ] , - browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems) + browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text)) # these are to test the onchange event # the event shouldnt get fired, as this is the selected item browser.select_list(:xpath, "//select[@name='sel3']/").select( /3/ ) assert_false(browser.text.include?("Pass") ) @@ -87,21 +74,19 @@ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems } assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") } assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) } # the select method keeps any currently selected items - use the clear selectcion method first - browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection browser.select_list(:xpath, "//select[@name='sel1']/").select_value("o1") - assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) + assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text)) - browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/) - assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems) + assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text)) browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ ) browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ ) - assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems) + assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text)) # these are to test the onchange event # the event shouldnt get fired, as this is the selected item browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ ) assert_false(browser.text.include?("Pass") )