celerity 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +8 -11
  3. data/Rakefile +5 -3
  4. data/benchmark/bm_2000_spans.rb +48 -0
  5. data/benchmark/bm_digg.rb +26 -0
  6. data/benchmark/bm_google_images.rb +36 -0
  7. data/benchmark/bm_input_locator.rb +69 -0
  8. data/benchmark/loader.rb +9 -0
  9. data/lib/celerity.rb +3 -1
  10. data/lib/celerity/container.rb +23 -171
  11. data/lib/celerity/disabled_element.rb +1 -1
  12. data/lib/celerity/element.rb +78 -47
  13. data/lib/celerity/element_collections.rb +16 -32
  14. data/lib/celerity/element_locator.rb +135 -0
  15. data/lib/celerity/elements/button.rb +15 -0
  16. data/lib/celerity/elements/file_field.rb +1 -1
  17. data/lib/celerity/elements/form.rb +2 -1
  18. data/lib/celerity/elements/frame.rb +18 -21
  19. data/lib/celerity/elements/image.rb +2 -8
  20. data/lib/celerity/elements/label.rb +1 -3
  21. data/lib/celerity/elements/link.rb +1 -1
  22. data/lib/celerity/elements/option.rb +16 -0
  23. data/lib/celerity/elements/radio_check.rb +18 -7
  24. data/lib/celerity/elements/select_list.rb +1 -17
  25. data/lib/celerity/elements/table.rb +4 -4
  26. data/lib/celerity/elements/table_body.rb +6 -8
  27. data/lib/celerity/elements/table_cell.rb +3 -14
  28. data/lib/celerity/elements/table_row.rb +4 -10
  29. data/lib/celerity/elements/text_field.rb +16 -4
  30. data/lib/celerity/extra/method_generator.rb +144 -0
  31. data/lib/celerity/identifier.rb +10 -0
  32. data/lib/celerity/ie.rb +28 -13
  33. data/lib/celerity/input_element.rb +0 -4
  34. data/lib/celerity/non_control_elements.rb +12 -12
  35. data/lib/celerity/version.rb +1 -1
  36. data/spec/area_spec.rb +41 -41
  37. data/spec/areas_spec.rb +11 -11
  38. data/spec/button_spec.rb +73 -68
  39. data/spec/buttons_spec.rb +10 -10
  40. data/spec/checkbox_spec.rb +102 -96
  41. data/spec/checkboxes_spec.rb +10 -10
  42. data/spec/div_spec.rb +78 -73
  43. data/spec/divs_spec.rb +10 -10
  44. data/spec/element_spec.rb +20 -11
  45. data/spec/filefield_spec.rb +36 -41
  46. data/spec/filefields_spec.rb +10 -10
  47. data/spec/form_spec.rb +29 -29
  48. data/spec/forms_spec.rb +11 -11
  49. data/spec/frame_spec.rb +54 -49
  50. data/spec/hidden_spec.rb +43 -43
  51. data/spec/hiddens_spec.rb +10 -10
  52. data/spec/html/2000_spans.html +2009 -0
  53. data/spec/html/forms_with_input_elements.html +15 -9
  54. data/spec/html/non_control_elements.html +4 -2
  55. data/spec/ie_spec.rb +82 -48
  56. data/spec/image_spec.rb +83 -100
  57. data/spec/images_spec.rb +10 -10
  58. data/spec/label_spec.rb +29 -29
  59. data/spec/labels_spec.rb +10 -10
  60. data/spec/li_spec.rb +41 -41
  61. data/spec/link_spec.rb +65 -59
  62. data/spec/links_spec.rb +11 -11
  63. data/spec/lis_spec.rb +10 -10
  64. data/spec/map_spec.rb +30 -30
  65. data/spec/maps_spec.rb +10 -10
  66. data/spec/p_spec.rb +49 -49
  67. data/spec/pre_spec.rb +41 -41
  68. data/spec/pres_spec.rb +10 -10
  69. data/spec/ps_spec.rb +10 -10
  70. data/spec/radio_spec.rb +104 -97
  71. data/spec/radios_spec.rb +11 -11
  72. data/spec/select_list_spec.rb +118 -106
  73. data/spec/select_lists_spec.rb +15 -15
  74. data/spec/span_spec.rb +54 -54
  75. data/spec/spans_spec.rb +11 -11
  76. data/spec/spec.opts +1 -1
  77. data/spec/spec_helper.rb +23 -3
  78. data/spec/table_bodies.rb +8 -8
  79. data/spec/table_bodies_spec.rb +9 -9
  80. data/spec/table_body_spec.rb +28 -27
  81. data/spec/table_cell_spec.rb +25 -25
  82. data/spec/table_cells_spec.rb +16 -16
  83. data/spec/table_row_spec.rb +16 -16
  84. data/spec/table_rows_spec.rb +12 -12
  85. data/spec/table_spec.rb +36 -36
  86. data/spec/tables_spec.rb +12 -12
  87. data/spec/text_field_spec.rb +111 -92
  88. data/spec/text_fields_spec.rb +13 -13
  89. data/tasks/benchmark.rake +3 -0
  90. data/tasks/rspec.rake +2 -2
  91. data/tasks/testserver.rake +15 -0
  92. metadata +58 -46
  93. data/tasks/simple_ci.rake +0 -94
data/spec/buttons_spec.rb CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Buttons" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
13
 
14
14
  describe "#length" do
15
15
  it "should return the number of buttons" do
16
- @ie.buttons.length.should == 7
16
+ @browser.buttons.length.should == 7
17
17
  end
18
18
  end
19
19
 
20
20
  describe "#[]" do
21
21
  it "should return the button at the given index" do
22
- @ie.buttons[1].title.should == "Submit the form"
22
+ @browser.buttons[1].title.should == "Submit the form"
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#each" do
27
27
  it "should iterate through buttons correctly" do
28
- @ie.buttons.each_with_index do |b, index|
29
- b.name.should == @ie.button(:index, index+1).name
30
- b.id.should == @ie.button(:index, index+1).id
31
- b.value.should == @ie.button(:index, index+1).value
28
+ @browser.buttons.each_with_index do |b, index|
29
+ b.name.should == @browser.button(:index, index+1).name
30
+ b.id.should == @browser.button(:index, index+1).id
31
+ b.value.should == @browser.button(:index, index+1).value
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
36
  after :all do
37
- @ie.close
37
+ @browser.close
38
38
  end
39
39
 
40
40
  end
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Checkbox" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
13
 
14
14
 
@@ -16,59 +16,59 @@ describe "Checkbox" do
16
16
 
17
17
  describe "#exists?" do
18
18
  it "should return true if the checkbox button exists" do
19
- @ie.checkbox(:id, "new_user_interests_books").should exist
20
- @ie.checkbox(:id, /new_user_interests_books/).should exist
21
- @ie.checkbox(:name, "new_user_interests").should exist
22
- @ie.checkbox(:name, /new_user_interests/).should exist
23
- @ie.checkbox(:value, "books").should exist
24
- @ie.checkbox(:value, /books/).should exist
19
+ @browser.checkbox(:id, "new_user_interests_books").should exist
20
+ @browser.checkbox(:id, /new_user_interests_books/).should exist
21
+ @browser.checkbox(:name, "new_user_interests").should exist
22
+ @browser.checkbox(:name, /new_user_interests/).should exist
23
+ @browser.checkbox(:value, "books").should exist
24
+ @browser.checkbox(:value, /books/).should exist
25
25
  # unsure what :text is supposed to represent here
26
- # @ie.checkbox(:text, "books").should exist
27
- # @ie.checkbox(:text, /books/).should exist
28
- @ie.checkbox(:class, "fun").should exist
29
- @ie.checkbox(:class, /fun/).should exist
30
- @ie.checkbox(:index, 1).should exist
31
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
26
+ # @browser.checkbox(:text, "books").should exist
27
+ # @browser.checkbox(:text, /books/).should exist
28
+ @browser.checkbox(:class, "fun").should exist
29
+ @browser.checkbox(:class, /fun/).should exist
30
+ @browser.checkbox(:index, 1).should exist
31
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
32
32
  end
33
33
 
34
34
  it "should return true if the checkbox button exists (search by name and value)" do
35
- @ie.checkbox(:name, "new_user_interests", 'cars').should exist
36
- @ie.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
35
+ @browser.checkbox(:name, "new_user_interests", 'cars').should exist
36
+ @browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
37
37
  end
38
38
 
39
39
  it "should return false if the checkbox button does not exist" do
40
- @ie.checkbox(:id, "no_such_id").should_not exist
41
- @ie.checkbox(:id, /no_such_id/).should_not exist
42
- @ie.checkbox(:name, "no_such_name").should_not exist
43
- @ie.checkbox(:name, /no_such_name/).should_not exist
44
- @ie.checkbox(:value, "no_such_value").should_not exist
45
- @ie.checkbox(:value, /no_such_value/).should_not exist
46
- @ie.checkbox(:text, "no_such_text").should_not exist
47
- @ie.checkbox(:text, /no_such_text/).should_not exist
48
- @ie.checkbox(:class, "no_such_class").should_not exist
49
- @ie.checkbox(:class, /no_such_class/).should_not exist
50
- @ie.checkbox(:index, 1337).should_not exist
51
- @ie.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
40
+ @browser.checkbox(:id, "no_such_id").should_not exist
41
+ @browser.checkbox(:id, /no_such_id/).should_not exist
42
+ @browser.checkbox(:name, "no_such_name").should_not exist
43
+ @browser.checkbox(:name, /no_such_name/).should_not exist
44
+ @browser.checkbox(:value, "no_such_value").should_not exist
45
+ @browser.checkbox(:value, /no_such_value/).should_not exist
46
+ @browser.checkbox(:text, "no_such_text").should_not exist
47
+ @browser.checkbox(:text, /no_such_text/).should_not exist
48
+ @browser.checkbox(:class, "no_such_class").should_not exist
49
+ @browser.checkbox(:class, /no_such_class/).should_not exist
50
+ @browser.checkbox(:index, 1337).should_not exist
51
+ @browser.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
52
52
  end
53
53
 
54
54
  it "should return false if the checkbox button does not exist (search by name and value)" do
55
- @ie.checkbox(:name, "new_user_interests", 'no_such_value').should_not exist
56
- @ie.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
57
- @ie.checkbox(:name, "no_such_name", 'cars').should_not exist
58
- @ie.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
55
+ @browser.checkbox(:name, "new_user_interests", 'no_such_value').should_not exist
56
+ @browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
57
+ @browser.checkbox(:name, "no_such_name", 'cars').should_not exist
58
+ @browser.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
59
59
  end
60
60
 
61
61
  it "should return true for checkboxs with a string value" do
62
- @ie.checkbox(:name, 'new_user_interests', 'books').should exist
63
- @ie.checkbox(:name, 'new_user_interests', 'cars').should exist
62
+ @browser.checkbox(:name, 'new_user_interests', 'books').should exist
63
+ @browser.checkbox(:name, 'new_user_interests', 'cars').should exist
64
64
  end
65
65
 
66
- it "should raise ArgumentError when what argument is invalid" do
67
- lambda { @ie.checkbox(:id, 3.14).exists? }.should raise_error(ArgumentError)
66
+ it "should raise ArgumentError when 'what' argument is invalid" do
67
+ lambda { @browser.checkbox(:id, 3.14).exists? }.should raise_error(ArgumentError)
68
68
  end
69
69
 
70
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
71
- lambda { @ie.checkbox(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
70
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
71
+ lambda { @browser.checkbox(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
72
72
  end
73
73
  end
74
74
 
@@ -77,67 +77,67 @@ describe "Checkbox" do
77
77
 
78
78
  describe "#class_name" do
79
79
  it "should return the class name if the checkbox exists and has an attribute" do
80
- @ie.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
80
+ @browser.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
81
81
  end
82
82
  it "should return an emptry string if the checkbox exists and the attribute doesn't" do
83
- @ie.checkbox(:id, "new_user_interests_books").class_name.should == ""
83
+ @browser.checkbox(:id, "new_user_interests_books").class_name.should == ""
84
84
  end
85
85
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
86
- lambda { @ie.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
86
+ lambda { @browser.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
87
87
  end
88
88
  end
89
89
 
90
90
  describe "#id" do
91
91
  it "should return the id attribute if the checkbox exists and has an attribute" do
92
- @ie.checkbox(:index, 1).id.should == "new_user_interests_books"
92
+ @browser.checkbox(:index, 1).id.should == "new_user_interests_books"
93
93
  end
94
94
  it "should return an emptry string if the checkbox exists and the attribute doesn't" do
95
- @ie.checkbox(:index, 2).id.should == ""
95
+ @browser.checkbox(:index, 2).id.should == ""
96
96
  end
97
97
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
98
- lambda { @ie.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
98
+ lambda { @browser.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
99
99
  end
100
100
  end
101
101
 
102
102
  describe "#name" do
103
103
  it "should return the name attribute if the checkbox exists" do
104
- @ie.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
104
+ @browser.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
105
105
  end
106
106
  it "should return an empty string if the checkbox exists and the attribute doesn't" do
107
- @ie.checkbox(:id, 'new_user_interests_food').name.should == ""
107
+ @browser.checkbox(:id, 'new_user_interests_food').name.should == ""
108
108
  end
109
109
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
110
- lambda { @ie.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
110
+ lambda { @browser.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
111
111
  end
112
112
  end
113
113
 
114
114
  describe "#title" do
115
115
  it "should return the title attribute if the checkbox exists" do
116
- @ie.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
116
+ @browser.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
117
117
  end
118
118
  it "should return an emptry string if the checkbox exists and the attribute doesn't" do
119
- @ie.checkbox(:id, "new_user_interests_books").title.should == ""
119
+ @browser.checkbox(:id, "new_user_interests_books").title.should == ""
120
120
  end
121
121
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
122
- lambda { @ie.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
122
+ lambda { @browser.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
123
123
  end
124
124
  end
125
125
 
126
126
  describe "#type" do
127
127
  it "should return the type attribute if the checkbox exists" do
128
- @ie.checkbox(:index, 1).type.should == "checkbox"
128
+ @browser.checkbox(:index, 1).type.should == "checkbox"
129
129
  end
130
130
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
131
- lambda { @ie.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
131
+ lambda { @browser.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
132
132
  end
133
133
  end
134
134
 
135
135
  describe "#value" do
136
136
  it "should return the value attribute if the checkbox exists" do
137
- @ie.checkbox(:id, 'new_user_interests_books').value.should == 'books'
137
+ @browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
138
138
  end
139
139
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
140
- lambda { @ie.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
140
+ lambda { @browser.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
141
141
  end
142
142
  end
143
143
 
@@ -146,28 +146,28 @@ describe "Checkbox" do
146
146
 
147
147
  describe "#enabled?" do
148
148
  it "should return true if the checkbox button is enabled" do
149
- @ie.checkbox(:id, "new_user_interests_books").should be_enabled
150
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
149
+ @browser.checkbox(:id, "new_user_interests_books").should be_enabled
150
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
151
151
  end
152
152
  it "should return false if the checkbox button is disabled" do
153
- @ie.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
154
- @ie.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
153
+ @browser.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
154
+ @browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
155
155
  end
156
156
  it "should raise UnknownObjectException if the checkbox button doesn't exist" do
157
- lambda { @ie.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
158
- lambda { @ie.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
157
+ lambda { @browser.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
158
+ lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
159
159
  end
160
160
  end
161
161
 
162
162
  describe "#disabled?" do
163
163
  it "should return true if the checkbox is disabled" do
164
- @ie.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
164
+ @browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
165
165
  end
166
166
  it "should return false if the checkbox is enabled" do
167
- @ie.checkbox(:id, 'new_user_interests_books').should_not be_disabled
167
+ @browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
168
168
  end
169
169
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
170
- lambda { @ie.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
170
+ lambda { @browser.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
171
171
  end
172
172
  end
173
173
 
@@ -176,43 +176,49 @@ describe "Checkbox" do
176
176
 
177
177
  describe "#clear" do
178
178
  it "should raise ObjectDisabledException if the checkbox is disabled" do
179
- @ie.checkbox(:id, "new_user_interests_dentistry").should_not be_set
180
- lambda { @ie.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
181
- lambda { @ie.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
179
+ @browser.checkbox(:id, "new_user_interests_dentistry").should_not be_set
180
+ lambda { @browser.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
181
+ lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
182
182
  end
183
183
  it "should clear the checkbox button if it is set" do
184
- @ie.checkbox(:id, "new_user_interests_books").clear
185
- @ie.checkbox(:id, "new_user_interests_books").should_not be_set
184
+ @browser.checkbox(:id, "new_user_interests_books").clear
185
+ @browser.checkbox(:id, "new_user_interests_books").should_not be_set
186
186
  end
187
187
  it "should clear the checkbox button when found by :xpath" do
188
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
189
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
188
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
189
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
190
190
  end
191
191
  it "should raise UnknownObjectException if the checkbox button doesn't exist" do
192
- lambda { @ie.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
193
- lambda { @ie.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
192
+ lambda { @browser.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
193
+ lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
194
194
  end
195
195
  end
196
196
 
197
197
  describe "#set" do
198
198
  it "should set the checkbox button" do
199
- @ie.checkbox(:id, "new_user_interests_cars").set
200
- @ie.checkbox(:id, "new_user_interests_cars").should be_set
199
+ @browser.checkbox(:id, "new_user_interests_cars").set
200
+ @browser.checkbox(:id, "new_user_interests_cars").should be_set
201
201
  end
202
202
  it "should set the checkbox button when found by :xpath" do
203
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
204
- @ie.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
203
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
204
+ @browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
205
205
  end
206
206
 
207
- it "should fire the onclick event"
207
+ it "should fire the onclick event" do
208
+ @browser.button(:id, "disabled_button").should be_disabled
209
+ @browser.checkbox(:id, "toggle_button_checkbox").set
210
+ @browser.button(:id, "disabled_button").should_not be_disabled
211
+ @browser.checkbox(:id, "toggle_button_checkbox").clear
212
+ @browser.button(:id, "disabled_button").should be_disabled
213
+ end
208
214
 
209
215
  it "should raise UnknownObjectException if the checkbox button doesn't exist" do
210
- lambda { @ie.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
211
- lambda { @ie.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
216
+ lambda { @browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
217
+ lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
212
218
  end
213
219
  it "should raise ObjectDisabledException if the checkbox is disabled" do
214
- lambda { @ie.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
215
- lambda { @ie.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
220
+ lambda { @browser.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
221
+ lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
216
222
  end
217
223
  end
218
224
 
@@ -221,39 +227,39 @@ describe "Checkbox" do
221
227
 
222
228
  describe '#set?' do
223
229
  it "should return true if the checkbox button is set" do
224
- @ie.checkbox(:id, "new_user_interests_books").should be_set
230
+ @browser.checkbox(:id, "new_user_interests_books").should be_set
225
231
  end
226
232
  it "should return false if the checkbox button unset" do
227
- @ie.checkbox(:id, "new_user_interests_cars").should_not be_set
233
+ @browser.checkbox(:id, "new_user_interests_cars").should_not be_set
228
234
  end
229
235
  it "should return the state for checkboxs with string values" do
230
- @ie.checkbox(:name, "new_user_interests", 'cars').should_not be_set
231
- @ie.checkbox(:name, "new_user_interests", 'cars').set
232
- @ie.checkbox(:name, "new_user_interests", 'cars').should be_set
233
- @ie.checkbox(:name, "new_user_interests", 'cars').clear
234
- @ie.checkbox(:name, "new_user_interests", 'cars').should_not be_set
236
+ @browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
237
+ @browser.checkbox(:name, "new_user_interests", 'cars').set
238
+ @browser.checkbox(:name, "new_user_interests", 'cars').should be_set
239
+ @browser.checkbox(:name, "new_user_interests", 'cars').clear
240
+ @browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
235
241
  end
236
242
  it "should raise UnknownObjectException if the checkbox button doesn't exist" do
237
- lambda { @ie.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
238
- lambda { @ie.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
243
+ lambda { @browser.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
244
+ lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
239
245
  end
240
246
  end
241
247
 
242
248
  describe "#get_state" do
243
249
  it "should return true if the checkbox is set" do
244
- @ie.checkbox(:id, "new_user_interests_books").get_state.should be_true
250
+ @browser.checkbox(:id, "new_user_interests_books").get_state.should be_true
245
251
  end
246
252
  it "should return false if the checkbox is unset" do
247
- @ie.checkbox(:id, "new_user_interests_cars").get_state.should be_false
253
+ @browser.checkbox(:id, "new_user_interests_cars").get_state.should be_false
248
254
  end
249
255
  it "should raise UnknownObjectException if the checkbox doesn't exist" do
250
- lambda { @ie.checkbox(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
251
- lambda { @ie.checkbox(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
256
+ lambda { @browser.checkbox(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
257
+ lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
252
258
  end
253
259
  end
254
260
 
255
261
  after :all do
256
- @ie.close
262
+ @browser.close
257
263
  end
258
264
  end
259
265
 
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "CheckBoxes" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
10
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
11
  end
12
12
 
13
13
  describe "#length" do
14
14
  it "should return the number of checkboxes" do
15
- @ie.checkboxes.length.should == 6
15
+ @browser.checkboxes.length.should == 7
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#[]" do
20
20
  it "should return the checkbox at the given index" do
21
- @ie.checkboxes[1].id.should == "new_user_interests_books"
21
+ @browser.checkboxes[1].id.should == "new_user_interests_books"
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#each" do
26
26
  it "should iterate through checkboxes correctly" do
27
- @ie.checkboxes.each_with_index do |c, index|
28
- c.name.should == @ie.checkbox(:index, index+1).name
29
- c.id.should == @ie.checkbox(:index, index+1).id
30
- c.value.should == @ie.checkbox(:index, index+1).value
27
+ @browser.checkboxes.each_with_index do |c, index|
28
+ c.name.should == @browser.checkbox(:index, index+1).name
29
+ c.id.should == @browser.checkbox(:index, index+1).id
30
+ c.value.should == @browser.checkbox(:index, index+1).value
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  after :all do
36
- @ie.close
36
+ @browser.close
37
37
  end
38
38
 
39
39
  end