firewatir 1.6.2 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/LICENSE +32 -0
  2. data/lib/firewatir.rb +40 -50
  3. data/lib/firewatir/container.rb +491 -534
  4. data/lib/firewatir/document.rb +239 -0
  5. data/lib/firewatir/element.rb +1365 -0
  6. data/lib/firewatir/element_collections.rb +314 -0
  7. data/lib/firewatir/elements/button.rb +15 -0
  8. data/lib/firewatir/elements/file_field.rb +29 -0
  9. data/lib/firewatir/elements/form.rb +40 -0
  10. data/lib/firewatir/elements/frame.rb +55 -0
  11. data/lib/firewatir/elements/hidden.rb +56 -0
  12. data/lib/firewatir/elements/image.rb +139 -0
  13. data/lib/firewatir/elements/input_element.rb +44 -0
  14. data/lib/firewatir/elements/link.rb +76 -0
  15. data/lib/firewatir/elements/non_control_element.rb +53 -0
  16. data/lib/firewatir/elements/non_control_elements.rb +108 -0
  17. data/lib/firewatir/elements/not_used.rb +278 -0
  18. data/lib/firewatir/elements/option.rb +131 -0
  19. data/lib/firewatir/elements/radio_check_common.rb +163 -0
  20. data/lib/firewatir/elements/select_list.rb +188 -0
  21. data/lib/firewatir/elements/table.rb +218 -0
  22. data/lib/firewatir/elements/table_cell.rb +54 -0
  23. data/lib/firewatir/elements/table_row.rb +100 -0
  24. data/lib/firewatir/elements/text_field.rb +218 -0
  25. data/lib/firewatir/exceptions.rb +10 -10
  26. data/lib/firewatir/firefox.rb +1040 -1127
  27. data/lib/firewatir/jssh_socket.rb +101 -0
  28. data/lib/firewatir/version.rb +5 -5
  29. data/unittests/attach_to_new_window_test.rb +49 -42
  30. data/unittests/bug_fixes_test.rb +195 -198
  31. data/unittests/buttons_xpath_test.rb +88 -88
  32. data/unittests/checkbox_test.rb +158 -155
  33. data/unittests/checkbox_xpath_test.rb +107 -107
  34. data/unittests/div_test.rb +275 -276
  35. data/unittests/filefield_test.rb +49 -45
  36. data/unittests/filefield_xpath_test.rb +35 -35
  37. data/unittests/form_test.rb +296 -308
  38. data/unittests/frame_test.rb +159 -152
  39. data/unittests/hidden_test.rb +85 -85
  40. data/unittests/hidden_xpath_test.rb +72 -72
  41. data/unittests/html/blankpage.html +11 -11
  42. data/unittests/html/buttons1.html +61 -61
  43. data/unittests/html/cssTest.html +42 -42
  44. data/unittests/html/div.html +72 -72
  45. data/unittests/html/fileupload.html +45 -45
  46. data/unittests/html/formTest1.html +38 -38
  47. data/unittests/html/forms2.html +45 -45
  48. data/unittests/html/frame_buttons.html +3 -3
  49. data/unittests/html/iframeTest.html +14 -14
  50. data/unittests/html/iframeTest1.html +13 -13
  51. data/unittests/html/iframeTest2.html +5 -5
  52. data/unittests/html/links1.html +42 -42
  53. data/unittests/html/nestedFrames.html +6 -6
  54. data/unittests/html/new_browser.html +1 -0
  55. data/unittests/html/new_browser_popup.html +8 -0
  56. data/unittests/html/pass.html +9 -9
  57. data/unittests/html/pre.html +27 -27
  58. data/unittests/html/redirect.html +10 -10
  59. data/unittests/html/redirect1.html +8 -8
  60. data/unittests/html/redirect2.html +8 -8
  61. data/unittests/html/redirect3.html +8 -8
  62. data/unittests/html/simple_table_columns.html +74 -74
  63. data/unittests/html/table1.html +165 -165
  64. data/unittests/html/textfields1.html +62 -62
  65. data/unittests/images_test.rb +198 -205
  66. data/unittests/images_xpath_test.rb +118 -119
  67. data/unittests/javascript_test.rb +75 -75
  68. data/unittests/links_test.rb +231 -232
  69. data/unittests/links_xpath_test.rb +79 -79
  70. data/unittests/mozilla_all_tests.rb +7 -7
  71. data/unittests/pre_test.rb +75 -76
  72. data/unittests/radios_xpath_test.rb +101 -101
  73. data/unittests/redirect_test.rb +41 -41
  74. data/unittests/selectbox_test.rb +142 -142
  75. data/unittests/selectbox_xpath_test.rb +129 -129
  76. data/unittests/setup.rb +29 -30
  77. data/unittests/table_test.rb +385 -373
  78. data/unittests/table_xpath_test.rb +185 -185
  79. data/unittests/textfields_test.rb +234 -233
  80. data/unittests/textfields_xpath_test.rb +113 -113
  81. metadata +33 -11
  82. data/lib/firewatir/MozillaBaseElement.rb +0 -1863
  83. data/lib/firewatir/htmlelements.rb +0 -1911
  84. data/unittests/iostring.rb +0 -30
  85. data/unittests/iostring_test.rb +0 -48
@@ -1,41 +1,41 @@
1
- # feature tests for Javascript redirect
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Redirect < Test::Unit::TestCase
8
-
9
- def setup
10
- goto_page("redirect.html")
11
- end
12
-
13
- def goto_multiple_redirect
14
- goto_page("redirect1.html")
15
- end
16
-
17
- tag_method :test_single_redirect, :fails_on_ie
18
- def test_single_redirect
19
- assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
20
- assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
21
-
22
- assert(browser.text_field(:name, "text1").verify_contains("0") )
23
- browser.div(:id , "div3").click
24
- assert(browser.text_field(:name, "text1").verify_contains("1") )
25
- browser.div(:id , "div4").click
26
- assert(browser.text_field(:name, "text1").verify_contains("0") )
27
- end
28
-
29
- tag_method :test_multiple_redirect, :fails_on_ie
30
- def test_multiple_redirect
31
- goto_multiple_redirect()
32
- assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
33
- assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
34
-
35
- assert(browser.text_field(:name, "text1").verify_contains("0") )
36
- browser.div(:id , "div3").click
37
- assert(browser.text_field(:name, "text1").verify_contains("1") )
38
- browser.div(:id , "div4").click
39
- assert(browser.text_field(:name, "text1").verify_contains("0") )
40
- end
41
- end
1
+ # feature tests for Javascript redirect
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_Redirect < Test::Unit::TestCase
8
+
9
+ def setup
10
+ goto_page("redirect.html")
11
+ end
12
+
13
+ def goto_multiple_redirect
14
+ goto_page("redirect1.html")
15
+ end
16
+
17
+ tag_method :test_single_redirect, :fails_on_ie
18
+ def test_single_redirect
19
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
20
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
21
+
22
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
23
+ browser.div(:id , "div3").click
24
+ assert(browser.text_field(:name, "text1").verify_contains("1") )
25
+ browser.div(:id , "div4").click
26
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
27
+ end
28
+
29
+ tag_method :test_multiple_redirect, :fails_on_ie
30
+ def test_multiple_redirect
31
+ goto_multiple_redirect()
32
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
33
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
34
+
35
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
36
+ browser.div(:id , "div3").click
37
+ assert(browser.text_field(:name, "text1").verify_contains("1") )
38
+ browser.div(:id , "div4").click
39
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
40
+ end
41
+ end
@@ -1,142 +1,142 @@
1
- # feature tests for Select Boxes
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_SelectList < Test::Unit::TestCase
8
-
9
-
10
- def setup()
11
- goto_page("selectboxes1.html")
12
- end
13
-
14
- def test_textBox_Exists
15
- assert(browser.select_list(:name, "sel1").exists?)
16
- assert_false(browser.select_list(:name, "missing").exists?)
17
- assert_false(browser.select_list(:id, "missing").exists?)
18
- end
19
-
20
- def test_select_list_enabled
21
- assert(browser.select_list(:name, "sel1").enabled?)
22
- assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
23
- end
24
-
25
- def test_select_list_getAllContents
26
- assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getAllContents }
27
- assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
28
- browser.select_list(:name, "sel1").getAllContents)
29
- end
30
-
31
- def test_Option_text_select
32
- assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
33
- assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
34
- assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
35
-
36
- # the select method keeps any currently selected items - use the clear selection method first
37
- browser.select_list( :name , "sel1").clearSelection
38
- browser.select_list( :name , "sel1").option(:text, "Option 1").select
39
- assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
40
- end
41
-
42
-
43
- tag_method :test_option_class_name, :fails_on_ie
44
- def test_option_class_name
45
-
46
- # the option object doesnt inherit from element, so this doesnt work
47
- assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
48
- assert_equal("option_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
49
- assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
50
-
51
- end
52
-
53
- def test_selectBox_select_using_value
54
- assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getSelectedItems }
55
- assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value("missing item") }
56
- assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value(/missing/) }
57
-
58
- # the select method keeps any currently selected items - use the clear selectcion method first
59
- browser.select_list( :name , "sel1").clearSelection
60
- browser.select_list( :name , "sel1").select_value("o1")
61
- assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
62
-
63
- browser.select_list( :name , "sel1").clearSelection
64
- browser.select_list( :name , "sel1").select_value(/2/)
65
- assert_equal( ["Option 2" ] , browser.select_list(:name, "sel1").getSelectedItems)
66
-
67
- browser.select_list( :name , "sel2").clearSelection
68
- browser.select_list( :name , "sel2").select_value(/4/)
69
- browser.select_list( :name , "sel2").select_value(/2/)
70
- assert_equal( ["Option 2" , "Option 4" ] ,
71
- browser.select_list(:name, "sel2").getSelectedItems)
72
-
73
- # these are to test the onchange event
74
- # the event shouldnt get fired, as this is the selected item
75
- browser.select_list( :name , "sel3").select_value( /3/ )
76
- assert_false(browser.text.include?("Pass") )
77
- end
78
-
79
- def test_select_list_select_using_value2
80
- # the event should get fired
81
- browser.select_list( :name , "sel3").select_value( /2/ )
82
- assert(browser.text.include?("PASS") )
83
- end
84
-
85
- def test_select_list_properties
86
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
87
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
88
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
89
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
90
- assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
91
-
92
- assert_equal("o3" , browser.select_list(:index, 1).value)
93
- assert_equal("sel1" , browser.select_list(:index, 1).name )
94
- assert_equal("" , browser.select_list(:index, 1).id )
95
- assert_equal("select-one", browser.select_list(:index, 1).type )
96
- assert_equal("select-multiple", browser.select_list(:index, 2).type )
97
-
98
- browser.select_list(:index,1).select(/1/)
99
- assert_equal("o1" , browser.select_list(:index, 1).value)
100
-
101
- assert_false( browser.select_list(:index, 1).disabled )
102
- assert( browser.select_list(:index, 4).disabled )
103
- assert( browser.select_list(:id, 'selectbox_4').disabled )
104
- end
105
-
106
- def test_select_list_iterator
107
- assert_equal(5, browser.select_lists.length)
108
- assert_equal("o3" , browser.select_lists[1].value)
109
- assert_equal("sel1" , browser.select_lists[1].name )
110
- assert_equal("select-one", browser.select_lists[1].type )
111
- assert_equal("select-multiple" , browser.select_lists[2].type )
112
-
113
- index=1
114
- browser.select_lists.each do |l|
115
- assert_equal( browser.select_list(:index, index).name , l.name )
116
- assert_equal( browser.select_list(:index, index).id , l.id )
117
- assert_equal( browser.select_list(:index, index).type , l.type )
118
- assert_equal( browser.select_list(:index, index).value , l.value )
119
- index+=1
120
- end
121
- assert_equal( index-1, browser.select_lists.length)
122
- # Bug Fix 25
123
- browser.select_lists.each { |list| puts list.getAllContents() }
124
- end
125
- end
126
-
127
- class TC_Select_Options < Test::Unit::TestCase
128
- tags :fails_on_ie
129
-
130
- def setup()
131
- goto_page("select_tealeaf.html")
132
- end
133
-
134
- def test_options_text
135
- browser.select_list(:name, 'op_numhits').option(:text, '>=').select
136
- assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
137
- assert_equal( [">=" ] , browser.select_list(:name, "op_numhits").getSelectedItems)
138
- assert_equal( "=" , browser.select_list(:name, "op_numhits")[1].text)
139
- assert_equal( "0" , browser.select_list(:name, "op_numhits")[1].value)
140
- end
141
- end
142
-
1
+ # feature tests for Select Boxes
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_SelectList < Test::Unit::TestCase
8
+
9
+
10
+ def setup()
11
+ goto_page("selectboxes1.html")
12
+ end
13
+
14
+ def test_textBox_Exists
15
+ assert(browser.select_list(:name, "sel1").exists?)
16
+ assert_false(browser.select_list(:name, "missing").exists?)
17
+ assert_false(browser.select_list(:id, "missing").exists?)
18
+ end
19
+
20
+ def test_select_list_enabled
21
+ assert(browser.select_list(:name, "sel1").enabled?)
22
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
23
+ end
24
+
25
+ def test_select_list_getAllContents
26
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getAllContents }
27
+ assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
28
+ browser.select_list(:name, "sel1").getAllContents)
29
+ end
30
+
31
+ def test_Option_text_select
32
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
33
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
34
+ assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
35
+
36
+ # the select method keeps any currently selected items - use the clear selection method first
37
+ browser.select_list( :name , "sel1").clearSelection
38
+ browser.select_list( :name , "sel1").option(:text, "Option 1").select
39
+ assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
40
+ end
41
+
42
+
43
+ tag_method :test_option_class_name, :fails_on_ie
44
+ def test_option_class_name
45
+
46
+ # the option object doesnt inherit from element, so this doesnt work
47
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
48
+ assert_equal("option_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
49
+ assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
50
+
51
+ end
52
+
53
+ def test_selectBox_select_using_value
54
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getSelectedItems }
55
+ assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value("missing item") }
56
+ assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value(/missing/) }
57
+
58
+ # the select method keeps any currently selected items - use the clear selectcion method first
59
+ browser.select_list( :name , "sel1").clearSelection
60
+ browser.select_list( :name , "sel1").select_value("o1")
61
+ assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
62
+
63
+ browser.select_list( :name , "sel1").clearSelection
64
+ browser.select_list( :name , "sel1").select_value(/2/)
65
+ assert_equal( ["Option 2" ] , browser.select_list(:name, "sel1").getSelectedItems)
66
+
67
+ browser.select_list( :name , "sel2").clearSelection
68
+ browser.select_list( :name , "sel2").select_value(/4/)
69
+ browser.select_list( :name , "sel2").select_value(/2/)
70
+ assert_equal( ["Option 2" , "Option 4" ] ,
71
+ browser.select_list(:name, "sel2").getSelectedItems)
72
+
73
+ # these are to test the onchange event
74
+ # the event shouldnt get fired, as this is the selected item
75
+ browser.select_list( :name , "sel3").select_value( /3/ )
76
+ assert_false(browser.text.include?("Pass") )
77
+ end
78
+
79
+ def test_select_list_select_using_value2
80
+ # the event should get fired
81
+ browser.select_list( :name , "sel3").select_value( /2/ )
82
+ assert(browser.text.include?("PASS") )
83
+ end
84
+
85
+ def test_select_list_properties
86
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
87
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
88
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
89
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
90
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
91
+
92
+ assert_equal("o3" , browser.select_list(:index, 1).value)
93
+ assert_equal("sel1" , browser.select_list(:index, 1).name )
94
+ assert_equal("" , browser.select_list(:index, 1).id )
95
+ assert_equal("select-one", browser.select_list(:index, 1).type )
96
+ assert_equal("select-multiple", browser.select_list(:index, 2).type )
97
+
98
+ browser.select_list(:index,1).select(/1/)
99
+ assert_equal("o1" , browser.select_list(:index, 1).value)
100
+
101
+ assert_false( browser.select_list(:index, 1).disabled )
102
+ assert( browser.select_list(:index, 4).disabled )
103
+ assert( browser.select_list(:id, 'selectbox_4').disabled )
104
+ end
105
+
106
+ def test_select_list_iterator
107
+ assert_equal(5, browser.select_lists.length)
108
+ assert_equal("o3" , browser.select_lists[1].value)
109
+ assert_equal("sel1" , browser.select_lists[1].name )
110
+ assert_equal("select-one", browser.select_lists[1].type )
111
+ assert_equal("select-multiple" , browser.select_lists[2].type )
112
+
113
+ index=1
114
+ browser.select_lists.each do |l|
115
+ assert_equal( browser.select_list(:index, index).name , l.name )
116
+ assert_equal( browser.select_list(:index, index).id , l.id )
117
+ assert_equal( browser.select_list(:index, index).type , l.type )
118
+ assert_equal( browser.select_list(:index, index).value , l.value )
119
+ index+=1
120
+ end
121
+ assert_equal( index-1, browser.select_lists.length)
122
+ # Bug Fix 25
123
+ browser.select_lists.each { |list| puts list.getAllContents() }
124
+ end
125
+ end
126
+
127
+ class TC_Select_Options < Test::Unit::TestCase
128
+ tags :fails_on_ie
129
+
130
+ def setup()
131
+ goto_page("select_tealeaf.html")
132
+ end
133
+
134
+ def test_options_text
135
+ browser.select_list(:name, 'op_numhits').option(:text, '>=').select
136
+ assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
137
+ assert_equal( [">=" ] , browser.select_list(:name, "op_numhits").getSelectedItems)
138
+ assert_equal( "=" , browser.select_list(:name, "op_numhits")[1].text)
139
+ assert_equal( "0" , browser.select_list(:name, "op_numhits")[1].value)
140
+ end
141
+ end
142
+
@@ -1,129 +1,129 @@
1
- # feature tests for Select Boxes
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Selectbox_XPath < Test::Unit::TestCase
8
-
9
-
10
- def setup()
11
- goto_page("selectboxes1.html")
12
- end
13
-
14
- def test_textBox_Exists
15
- assert(browser.select_list(:xpath, "//select[@name='sel1']").exists?)
16
- assert_false(browser.select_list(:xpath, "//select[@name='missing']").exists?)
17
- assert_false(browser.select_list(:xpath, "//select[@id='missing']").exists?)
18
- end
19
-
20
- tag_method :test_element_by_xpath_class, :fails_on_ie
21
- def test_element_by_xpath_class
22
- element = browser.element_by_xpath("//select[@name='sel1']")
23
- assert_class(element, 'SelectList')
24
- # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
25
- # TODO: If element is not present, this should return null
26
- #element = browser.element_by_xpath("//select[@name='missing']")
27
- #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
28
- # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
29
- # TODO: If element is not present, this should return null
30
- #element = browser.element_by_xpath("//select[@id='missing']")
31
- #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
32
- end
33
-
34
- def test_select_list_enabled
35
- assert(browser.select_list(:xpath, "//select[@name='sel1']").enabled?)
36
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").enabled? }
37
- end
38
-
39
- def test_select_list_getAllContents
40
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getAllContents }
41
- assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
42
- browser.select_list(:xpath, "//select[@name='sel1']").getAllContents)
43
- end
44
-
45
- def test_select_list_getSelectedItems
46
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
47
- assert_equal( ["Option 3" ] ,
48
- browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
49
- assert_equal( ["Option 3" , "Option 6" ] ,
50
- browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
51
- end
52
-
53
- tag_method :test_clearSelection, :fails_on_ie
54
- def test_clearSelection
55
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").clearSelection }
56
- browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
57
-
58
- # the box sel1 has no ability to have a de-selected item
59
- # By default Option 1 will be selected
60
- assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
61
-
62
- browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
63
- assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
64
- end
65
-
66
- def test_select_list_select
67
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
68
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select("missing item") }
69
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select(/missing/) }
70
-
71
- # the select method keeps any currently selected items - use the clear selectcion method first
72
- browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
73
- browser.select_list(:xpath, "//select[@name='sel1']").select("Option 1")
74
- assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
75
-
76
- browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
77
- browser.select_list(:xpath, "//select[@name='sel1']").select(/2/)
78
- assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
79
-
80
- browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
81
- browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
82
- browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
83
- assert_equal( ["Option 2" , "Option 4" ] ,
84
- browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
85
-
86
- # these are to test the onchange event
87
- # the event shouldnt get fired, as this is the selected item
88
- browser.select_list(:xpath, "//select[@name='sel3']").select( /3/ )
89
- assert_false(browser.text.include?("Pass") )
90
- end
91
-
92
- def test_select_list_select2
93
- # the event should get fired
94
- browser.select_list(:xpath, "//select[@name='sel3']").select( /2/ )
95
- assert(browser.text.include?("PASS") )
96
- end
97
-
98
- def test_select_list_select_using_value
99
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
100
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value("missing item") }
101
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value(/missing/) }
102
-
103
- # the select method keeps any currently selected items - use the clear selectcion method first
104
- browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
105
- browser.select_list(:xpath, "//select[@name='sel1']").select_value("o1")
106
- assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
107
-
108
- browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
109
- browser.select_list(:xpath, "//select[@name='sel1']").select_value(/2/)
110
- assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
111
-
112
- browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
113
- browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
114
- browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
115
- assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
116
-
117
- # these are to test the onchange event
118
- # the event shouldnt get fired, as this is the selected item
119
- browser.select_list(:xpath, "//select[@name='sel3']").select_value( /3/ )
120
- assert_false(browser.text.include?("Pass") )
121
- end
122
-
123
- def test_select_list_select_using_value2
124
- # the event should get fired
125
- browser.select_list(:xpath, "//select[@name='sel3']").select_value( /2/ )
126
- assert(browser.text.include?("PASS") )
127
- end
128
-
129
- end
1
+ # feature tests for Select Boxes
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
+ require 'unittests/setup'
6
+
7
+ class TC_Selectbox_XPath < Test::Unit::TestCase
8
+
9
+
10
+ def setup()
11
+ goto_page("selectboxes1.html")
12
+ end
13
+
14
+ def test_textBox_Exists
15
+ assert(browser.select_list(:xpath, "//select[@name='sel1']").exists?)
16
+ assert_false(browser.select_list(:xpath, "//select[@name='missing']").exists?)
17
+ assert_false(browser.select_list(:xpath, "//select[@id='missing']").exists?)
18
+ end
19
+
20
+ tag_method :test_element_by_xpath_class, :fails_on_ie
21
+ def test_element_by_xpath_class
22
+ element = browser.element_by_xpath("//select[@name='sel1']")
23
+ assert_class(element, 'SelectList')
24
+ # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
25
+ # TODO: If element is not present, this should return null
26
+ #element = browser.element_by_xpath("//select[@name='missing']")
27
+ #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
28
+ # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
29
+ # TODO: If element is not present, this should return null
30
+ #element = browser.element_by_xpath("//select[@id='missing']")
31
+ #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
32
+ end
33
+
34
+ def test_select_list_enabled
35
+ assert(browser.select_list(:xpath, "//select[@name='sel1']").enabled?)
36
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").enabled? }
37
+ end
38
+
39
+ def test_select_list_getAllContents
40
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getAllContents }
41
+ assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
42
+ browser.select_list(:xpath, "//select[@name='sel1']").getAllContents)
43
+ end
44
+
45
+ def test_select_list_getSelectedItems
46
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
47
+ assert_equal( ["Option 3" ] ,
48
+ browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
49
+ assert_equal( ["Option 3" , "Option 6" ] ,
50
+ browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
51
+ end
52
+
53
+ tag_method :test_clearSelection, :fails_on_ie
54
+ def test_clearSelection
55
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").clearSelection }
56
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
57
+
58
+ # the box sel1 has no ability to have a de-selected item
59
+ # By default Option 1 will be selected
60
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
61
+
62
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
63
+ assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
64
+ end
65
+
66
+ def test_select_list_select
67
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
68
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select("missing item") }
69
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select(/missing/) }
70
+
71
+ # the select method keeps any currently selected items - use the clear selectcion method first
72
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
73
+ browser.select_list(:xpath, "//select[@name='sel1']").select("Option 1")
74
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
75
+
76
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
77
+ browser.select_list(:xpath, "//select[@name='sel1']").select(/2/)
78
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
79
+
80
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
81
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
82
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
83
+ assert_equal( ["Option 2" , "Option 4" ] ,
84
+ browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
85
+
86
+ # these are to test the onchange event
87
+ # the event shouldnt get fired, as this is the selected item
88
+ browser.select_list(:xpath, "//select[@name='sel3']").select( /3/ )
89
+ assert_false(browser.text.include?("Pass") )
90
+ end
91
+
92
+ def test_select_list_select2
93
+ # the event should get fired
94
+ browser.select_list(:xpath, "//select[@name='sel3']").select( /2/ )
95
+ assert(browser.text.include?("PASS") )
96
+ end
97
+
98
+ def test_select_list_select_using_value
99
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
100
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value("missing item") }
101
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value(/missing/) }
102
+
103
+ # the select method keeps any currently selected items - use the clear selectcion method first
104
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
105
+ browser.select_list(:xpath, "//select[@name='sel1']").select_value("o1")
106
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
107
+
108
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
109
+ browser.select_list(:xpath, "//select[@name='sel1']").select_value(/2/)
110
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
111
+
112
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
113
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
114
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
115
+ assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
116
+
117
+ # these are to test the onchange event
118
+ # the event shouldnt get fired, as this is the selected item
119
+ browser.select_list(:xpath, "//select[@name='sel3']").select_value( /3/ )
120
+ assert_false(browser.text.include?("Pass") )
121
+ end
122
+
123
+ def test_select_list_select_using_value2
124
+ # the event should get fired
125
+ browser.select_list(:xpath, "//select[@name='sel3']").select_value( /2/ )
126
+ assert(browser.text.include?("PASS") )
127
+ end
128
+
129
+ end