firewatir 1.6.2 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
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,88 +1,88 @@
1
- # feature tests for Buttons
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_Buttons_XPath < Test::Unit::TestCase
8
-
9
-
10
- def setup
11
- goto_page("buttons1.html")
12
- end
13
-
14
- def test_properties
15
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").id }
16
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").name }
17
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").disabled }
18
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").type }
19
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").value }
20
-
21
- assert_equal("b1" , browser.button(:xpath, "//input[@id='b2']").name )
22
- assert_equal("b2" , browser.button(:xpath, "//input[@id='b2']").id )
23
- assert_equal("button" , browser.button(:xpath, "//input[@id='b2']").type )
24
- end
25
-
26
- def test_button_using_default
27
- # since most of the time, a button will be accessed based on its caption, there is a default way of accessing it....
28
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
29
-
30
- browser.button(:xpath, "//input[@value='Click Me']").click
31
- assert(browser.text.include?("PASS") )
32
- end
33
-
34
- def test_Button_click_only
35
- browser.button(:xpath, "//input[@value='Click Me']").click
36
- assert(browser.text.include?("PASS") )
37
- end
38
-
39
- def test_button_click
40
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
41
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@id='MissingId']").click }
42
-
43
- assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { browser.button(:xpath, "//input[@value='Disabled Button']").click }
44
-
45
- browser.button(:xpath, "//input[@value='Click Me']").click
46
- assert(browser.text.include?("PASS") )
47
- end
48
-
49
- def test_Button_Exists
50
- assert(browser.button(:xpath, "//input[@value='Click Me']").exists?)
51
- assert(browser.button(:xpath, "//input[@value='Submit']").exists?)
52
- assert(browser.button(:xpath, "//input[@name='b1']").exists?)
53
- assert(browser.button(:xpath, "//input[@id='b2']").exists?)
54
-
55
- assert_false(browser.button(:xpath, "//input[@value='Missing Caption']").exists?)
56
- assert_false(browser.button(:xpath, "//input[@name='missingname']").exists?)
57
- assert_false(browser.button(:xpath, "//input[@id='missingid']").exists?)
58
- end
59
-
60
- tag_method :test_element_by_xpath_class, :fails_on_ie
61
- def test_element_by_xpath_class
62
- element = browser.element_by_xpath("//input[@value='Click Me']")
63
- assert_class element, 'Button'
64
- element = browser.element_by_xpath("//input[@value='Submit']")
65
- assert_class element, 'Button'
66
- element = browser.element_by_xpath("//input[@name='b1']")
67
- assert_class element, 'Button'
68
- element = browser.element_by_xpath("//input[@id='b2']")
69
- assert_class element, 'Button'
70
- # TODO: If object is not there this should return null
71
- #element = browser.element_by_xpath("//input[@value='Missing Caption']")
72
- #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
73
- #element = browser.element_by_xpath("//input[@name='missingname']")
74
- #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
75
- #element = browser.element_by_xpath("//input[@id='missingid']")
76
- #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
77
- end
78
-
79
- def test_Button_Enabled
80
- assert(browser.button(:xpath, "//input[@value='Click Me']").enabled?)
81
- assert_false(browser.button(:xpath, "//input[@value='Disabled Button']").enabled?)
82
- assert_false(browser.button(:xpath, "//input[@name='b4']").enabled?)
83
- assert_false(browser.button(:xpath, "//input[@id='b5']").enabled?)
84
-
85
- assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").enabled? }
86
- end
87
- end
88
-
1
+ # feature tests for Buttons
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_Buttons_XPath < Test::Unit::TestCase
8
+
9
+
10
+ def setup
11
+ goto_page("buttons1.html")
12
+ end
13
+
14
+ def test_properties
15
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").id }
16
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").name }
17
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").disabled }
18
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").type }
19
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").value }
20
+
21
+ assert_equal("b1" , browser.button(:xpath, "//input[@id='b2']").name )
22
+ assert_equal("b2" , browser.button(:xpath, "//input[@id='b2']").id )
23
+ assert_equal("button" , browser.button(:xpath, "//input[@id='b2']").type )
24
+ end
25
+
26
+ def test_button_using_default
27
+ # since most of the time, a button will be accessed based on its caption, there is a default way of accessing it....
28
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
29
+
30
+ browser.button(:xpath, "//input[@value='Click Me']").click
31
+ assert(browser.text.include?("PASS") )
32
+ end
33
+
34
+ def test_Button_click_only
35
+ browser.button(:xpath, "//input[@value='Click Me']").click
36
+ assert(browser.text.include?("PASS") )
37
+ end
38
+
39
+ def test_button_click
40
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
41
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@id='MissingId']").click }
42
+
43
+ assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { browser.button(:xpath, "//input[@value='Disabled Button']").click }
44
+
45
+ browser.button(:xpath, "//input[@value='Click Me']").click
46
+ assert(browser.text.include?("PASS") )
47
+ end
48
+
49
+ def test_Button_Exists
50
+ assert(browser.button(:xpath, "//input[@value='Click Me']").exists?)
51
+ assert(browser.button(:xpath, "//input[@value='Submit']").exists?)
52
+ assert(browser.button(:xpath, "//input[@name='b1']").exists?)
53
+ assert(browser.button(:xpath, "//input[@id='b2']").exists?)
54
+
55
+ assert_false(browser.button(:xpath, "//input[@value='Missing Caption']").exists?)
56
+ assert_false(browser.button(:xpath, "//input[@name='missingname']").exists?)
57
+ assert_false(browser.button(:xpath, "//input[@id='missingid']").exists?)
58
+ end
59
+
60
+ tag_method :test_element_by_xpath_class, :fails_on_ie
61
+ def test_element_by_xpath_class
62
+ element = browser.element_by_xpath("//input[@value='Click Me']")
63
+ assert_class element, 'Button'
64
+ element = browser.element_by_xpath("//input[@value='Submit']")
65
+ assert_class element, 'Button'
66
+ element = browser.element_by_xpath("//input[@name='b1']")
67
+ assert_class element, 'Button'
68
+ element = browser.element_by_xpath("//input[@id='b2']")
69
+ assert_class element, 'Button'
70
+ # TODO: If object is not there this should return null
71
+ #element = browser.element_by_xpath("//input[@value='Missing Caption']")
72
+ #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
73
+ #element = browser.element_by_xpath("//input[@name='missingname']")
74
+ #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
75
+ #element = browser.element_by_xpath("//input[@id='missingid']")
76
+ #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
77
+ end
78
+
79
+ def test_Button_Enabled
80
+ assert(browser.button(:xpath, "//input[@value='Click Me']").enabled?)
81
+ assert_false(browser.button(:xpath, "//input[@value='Disabled Button']").enabled?)
82
+ assert_false(browser.button(:xpath, "//input[@name='b4']").enabled?)
83
+ assert_false(browser.button(:xpath, "//input[@id='b5']").enabled?)
84
+
85
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").enabled? }
86
+ end
87
+ end
88
+
@@ -1,155 +1,158 @@
1
- # feature tests for Check 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_CheckBox < Test::Unit::TestCase
8
-
9
-
10
- def setup()
11
- goto_page("checkboxes1.html")
12
- end
13
-
14
- def test_checkbox_properties
15
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").id }
16
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").name }
17
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").disabled }
18
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").type }
19
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").value }
20
-
21
- assert_equal("box1" , browser.checkbox(:index, 1).name )
22
- assert_class(browser.checkbox(:index,1), 'Checkbox')
23
-
24
- assert_equal("" , browser.checkbox(:index, 1).id )
25
- assert_equal("checkbox" , browser.checkbox(:index, 1).type )
26
- assert_equal("on" , browser.checkbox(:index, 1).value )
27
- assert_equal(false , browser.checkbox(:index, 1).disabled )
28
-
29
- assert_equal("check_box_style" , browser.checkbox(:name, "box1").class_name)
30
- assert_equal("" , browser.checkbox(:name, "box2").class_name)
31
-
32
- assert_equal("1" , browser.checkbox(:name,"box4").value )
33
- assert_equal("3" , browser.checkbox(:name,"box4" , 3).value )
34
- assert_equal("checkbox" , browser.checkbox(:name,"box4" , 3).type )
35
- assert_equal(false , browser.checkbox(:name,"box4" , 3).disabled )
36
- assert_equal("" , browser.checkbox(:name,"box4" , 3).id )
37
-
38
- assert_equal("box4-value5" , browser.checkbox(:name,"box4" , 5).title)
39
- assert_equal("" , browser.checkbox(:name,"box4" , 4).title)
40
- end
41
-
42
- def test_onClick
43
- assert_false(browser.button(:value , "foo").enabled?)
44
- browser.checkbox(:name, "box5").set
45
- assert(browser.button(:value , "foo").enabled?)
46
-
47
- browser.checkbox(:name, "box5").clear
48
- assert_false(browser.button(:value , "foo").enabled?)
49
-
50
- browser.checkbox(:name, "box5").clear
51
- assert_false(browser.button(:value , "foo").enabled?)
52
- end
53
-
54
- def test_CheckBox_Exists
55
- assert(browser.checkbox(:name, "box1").exists?)
56
- assert_false(browser.checkbox(:name, "missing").exists?)
57
-
58
- assert(browser.checkbox(:name, "box4" , 1).exists?)
59
- assert_false(browser.checkbox(:name, "box4" , 22).exists?)
60
- end
61
-
62
- #def test_checkbox_Enabled
63
- # assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").enabled? }
64
- # assert_raises(UnknownObjectException) { browser.checkbox(:id, "noName").enabled? }
65
- # assert_raises(UnknownObjectException) { browser.checkbox(:name, "box4" , 6).enabled? }
66
- #
67
- # assert(browser.checkbox(:name, "box1").enabled?)
68
- # assert_false(browser.checkbox(:name, "box2").enabled?)
69
- #
70
- # assert(browser.checkbox(:name, "box4", 4).enabled?)
71
- # assert_false(browser.checkbox(:name, "box4" , 5 ).enabled?)
72
- #end
73
-
74
- def test_checkbox_isSet
75
- assert_raises(UnknownObjectException ) { browser.checkbox(:name, "noName").isSet? }
76
-
77
- assert_false(browser.checkbox(:name, "box1").isSet?)
78
- assert_false(browser.checkbox(:name, "box2").isSet?)
79
- assert(browser.checkbox(:name, "box3").isSet?)
80
-
81
- assert_false(browser.checkbox(:name, "box4" , 2 ).isSet?)
82
- assert(browser.checkbox(:name, "box4" , 1 ).isSet?)
83
- end
84
-
85
- def test_checkbox_clear
86
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").clear }
87
- browser.checkbox(:name, "box1").clear
88
- assert_false(browser.checkbox(:name, "box1").isSet?)
89
-
90
- assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").clear }
91
- assert_false(browser.checkbox(:name, "box2").isSet?)
92
-
93
- browser.checkbox(:name, "box3").clear
94
- assert_false(browser.checkbox(:name, "box3").isSet?)
95
-
96
- browser.checkbox(:name, "box4" , 1).clear
97
- assert_false(browser.checkbox(:name, "box4" , 1).isSet?)
98
- end
99
-
100
- def test_checkbox_getState
101
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").getState }
102
- assert_equal( false , browser.checkbox(:name, "box1").getState )
103
- assert_equal( true , browser.checkbox(:name, "box3").getState)
104
-
105
- # checkboxes that have the same name but different values
106
- assert_equal( false , browser.checkbox(:name, "box4" , 2).getState )
107
- assert_equal( true , browser.checkbox(:name, "box4" , 1).getState)
108
- end
109
-
110
- def test_checkbox_set
111
- assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").set }
112
- browser.checkbox(:name, "box1").set
113
- assert(browser.checkbox(:name, "box1").isSet?)
114
-
115
- assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").set }
116
-
117
- browser.checkbox(:name, "box3").set
118
- assert(browser.checkbox(:name, "box3").isSet?)
119
-
120
- # checkboxes that have the same name but different values
121
- browser.checkbox(:name, "box4" , 3).set
122
- assert(browser.checkbox(:name, "box4" , 3).isSet?)
123
-
124
- # test set using the optinal true/false
125
- # assumes the checkbox is already checked
126
- browser.checkbox(:name, "box1").set( false )
127
- assert_false(browser.checkbox(:name, "box1").isSet?)
128
-
129
- browser.checkbox(:name, "box1").set( true )
130
- assert(browser.checkbox(:name, "box1").isSet?)
131
-
132
-
133
-
134
-
135
- end
136
-
137
- def test_checkbox_iterator
138
-
139
- assert_equal(11, browser.checkboxes.length)
140
- assert_equal("box1" , browser.checkboxes[1].name )
141
-
142
- index=1
143
- browser.checkboxes.each do |c|
144
- assert_equal( browser.checkbox(:index, index).name , c.name )
145
- assert_equal( browser.checkbox(:index, index).id, c.id )
146
- assert_equal( browser.checkbox(:index, index).value, c.value )
147
- assert_equal( browser.checkbox(:index, index).isSet?, c.isSet? )
148
- index+=1
149
- end
150
- assert_equal(index-1, browser.checkboxes.length)
151
-
152
- end
153
-
154
-
155
- end
1
+ # feature tests for Check 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_CheckBox < Test::Unit::TestCase
8
+
9
+
10
+ def setup()
11
+ goto_page("checkboxes1.html")
12
+ end
13
+
14
+ def test_checkbox_properties
15
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").id }
16
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").name }
17
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").disabled }
18
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").type }
19
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").value }
20
+
21
+ assert_equal("box1" , browser.checkbox(:index, 1).name )
22
+ assert_class(browser.checkbox(:index,1), 'Checkbox')
23
+
24
+ assert_equal("" , browser.checkbox(:index, 1).id )
25
+ assert_equal("checkbox" , browser.checkbox(:index, 1).type )
26
+ assert_equal("on" , browser.checkbox(:index, 1).value )
27
+ assert_equal(false , browser.checkbox(:index, 1).disabled )
28
+
29
+ assert_equal("check_box_style" , browser.checkbox(:name, "box1").class_name)
30
+ assert_equal("" , browser.checkbox(:name, "box2").class_name)
31
+
32
+ assert_equal("1" , browser.checkbox(:name,"box4").value )
33
+ assert_equal("3" , browser.checkbox(:name,"box4" , 3).value )
34
+ assert_equal("checkbox" , browser.checkbox(:name,"box4" , 3).type )
35
+ assert_equal(false , browser.checkbox(:name,"box4" , 3).disabled )
36
+ assert_equal("" , browser.checkbox(:name,"box4" , 3).id )
37
+
38
+ assert_equal("box4-value5" , browser.checkbox(:name,"box4" , 5).title)
39
+ assert_equal("" , browser.checkbox(:name,"box4" , 4).title)
40
+ end
41
+
42
+ def test_onClick
43
+ assert_false(browser.button(:value , "foo").enabled?)
44
+ browser.checkbox(:name, "box5").set
45
+ assert(browser.button(:value , "foo").enabled?)
46
+
47
+ browser.checkbox(:name, "box5").clear
48
+ assert_false(browser.button(:value , "foo").enabled?)
49
+
50
+ browser.checkbox(:name, "box5").clear
51
+ assert_false(browser.button(:value , "foo").enabled?)
52
+ end
53
+
54
+ def test_CheckBox_Exists
55
+ assert(browser.checkbox(:name, "box1").exists?)
56
+ assert_false(browser.checkbox(:name, "missing").exists?)
57
+
58
+ assert(browser.checkbox(:name, "box4" , 1).exists?)
59
+ assert_false(browser.checkbox(:name, "box4" , 22).exists?)
60
+
61
+ assert(browser.checkbox(:name, "box4" , /[0-9]/).exists?)
62
+ assert_false(browser.checkbox(:name, "box4" , /\d\d\d/).exists?)
63
+ end
64
+
65
+ #def test_checkbox_Enabled
66
+ # assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").enabled? }
67
+ # assert_raises(UnknownObjectException) { browser.checkbox(:id, "noName").enabled? }
68
+ # assert_raises(UnknownObjectException) { browser.checkbox(:name, "box4" , 6).enabled? }
69
+ #
70
+ # assert(browser.checkbox(:name, "box1").enabled?)
71
+ # assert_false(browser.checkbox(:name, "box2").enabled?)
72
+ #
73
+ # assert(browser.checkbox(:name, "box4", 4).enabled?)
74
+ # assert_false(browser.checkbox(:name, "box4" , 5 ).enabled?)
75
+ #end
76
+
77
+ def test_checkbox_isSet
78
+ assert_raises(UnknownObjectException ) { browser.checkbox(:name, "noName").isSet? }
79
+
80
+ assert_false(browser.checkbox(:name, "box1").isSet?)
81
+ assert_false(browser.checkbox(:name, "box2").isSet?)
82
+ assert(browser.checkbox(:name, "box3").isSet?)
83
+
84
+ assert_false(browser.checkbox(:name, "box4" , 2 ).isSet?)
85
+ assert(browser.checkbox(:name, "box4" , 1 ).isSet?)
86
+ end
87
+
88
+ def test_checkbox_clear
89
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").clear }
90
+ browser.checkbox(:name, "box1").clear
91
+ assert_false(browser.checkbox(:name, "box1").isSet?)
92
+
93
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").clear }
94
+ assert_false(browser.checkbox(:name, "box2").isSet?)
95
+
96
+ browser.checkbox(:name, "box3").clear
97
+ assert_false(browser.checkbox(:name, "box3").isSet?)
98
+
99
+ browser.checkbox(:name, "box4" , 1).clear
100
+ assert_false(browser.checkbox(:name, "box4" , 1).isSet?)
101
+ end
102
+
103
+ def test_checkbox_getState
104
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").getState }
105
+ assert_equal( false , browser.checkbox(:name, "box1").getState )
106
+ assert_equal( true , browser.checkbox(:name, "box3").getState)
107
+
108
+ # checkboxes that have the same name but different values
109
+ assert_equal( false , browser.checkbox(:name, "box4" , 2).getState )
110
+ assert_equal( true , browser.checkbox(:name, "box4" , 1).getState)
111
+ end
112
+
113
+ def test_checkbox_set
114
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").set }
115
+ browser.checkbox(:name, "box1").set
116
+ assert(browser.checkbox(:name, "box1").isSet?)
117
+
118
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").set }
119
+
120
+ browser.checkbox(:name, "box3").set
121
+ assert(browser.checkbox(:name, "box3").isSet?)
122
+
123
+ # checkboxes that have the same name but different values
124
+ browser.checkbox(:name, "box4" , 3).set
125
+ assert(browser.checkbox(:name, "box4" , 3).isSet?)
126
+
127
+ # test set using the optinal true/false
128
+ # assumes the checkbox is already checked
129
+ browser.checkbox(:name, "box1").set( false )
130
+ assert_false(browser.checkbox(:name, "box1").isSet?)
131
+
132
+ browser.checkbox(:name, "box1").set( true )
133
+ assert(browser.checkbox(:name, "box1").isSet?)
134
+
135
+
136
+
137
+
138
+ end
139
+
140
+ def test_checkbox_iterator
141
+
142
+ assert_equal(11, browser.checkboxes.length)
143
+ assert_equal("box1" , browser.checkboxes[1].name )
144
+
145
+ index=1
146
+ browser.checkboxes.each do |c|
147
+ assert_equal( browser.checkbox(:index, index).name , c.name )
148
+ assert_equal( browser.checkbox(:index, index).id, c.id )
149
+ assert_equal( browser.checkbox(:index, index).value, c.value )
150
+ assert_equal( browser.checkbox(:index, index).isSet?, c.isSet? )
151
+ index+=1
152
+ end
153
+ assert_equal(index-1, browser.checkboxes.length)
154
+
155
+ end
156
+
157
+
158
+ end