celerity 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +14 -0
  3. data/Manifest.txt +127 -151
  4. data/README.txt +15 -20
  5. data/lib/celerity.rb +13 -5
  6. data/lib/celerity/browser.rb +296 -0
  7. data/lib/celerity/clickable_element.rb +1 -0
  8. data/lib/celerity/collections.rb +4 -0
  9. data/lib/celerity/container.rb +69 -2
  10. data/lib/celerity/disabled_element.rb +1 -0
  11. data/lib/celerity/element.rb +103 -38
  12. data/lib/celerity/element_collections.rb +14 -8
  13. data/lib/celerity/element_locator.rb +61 -50
  14. data/lib/celerity/element_map.rb +51 -0
  15. data/lib/celerity/elements/button.rb +1 -0
  16. data/lib/celerity/elements/file_field.rb +3 -2
  17. data/lib/celerity/elements/form.rb +1 -0
  18. data/lib/celerity/elements/frame.rb +16 -1
  19. data/lib/celerity/elements/image.rb +15 -13
  20. data/lib/celerity/elements/link.rb +4 -1
  21. data/lib/celerity/elements/option.rb +1 -0
  22. data/lib/celerity/elements/radio_check.rb +19 -7
  23. data/lib/celerity/elements/select_list.rb +17 -2
  24. data/lib/celerity/elements/table.rb +34 -20
  25. data/lib/celerity/elements/table_body.rb +2 -2
  26. data/lib/celerity/elements/table_cell.rb +3 -1
  27. data/lib/celerity/elements/table_footer.rb +2 -2
  28. data/lib/celerity/elements/table_header.rb +2 -2
  29. data/lib/celerity/elements/table_row.rb +4 -2
  30. data/lib/celerity/elements/text_field.rb +20 -9
  31. data/lib/celerity/exception.rb +11 -18
  32. data/lib/celerity/extra/method_generator.rb +13 -8
  33. data/lib/celerity/htmlunit/download.sh +23 -0
  34. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  36. data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
  37. data/lib/celerity/input_element.rb +1 -1
  38. data/lib/celerity/version.rb +1 -1
  39. data/lib/celerity/watir_compatibility.rb +37 -23
  40. data/spec/area_spec.rb +19 -4
  41. data/spec/areas_spec.rb +2 -3
  42. data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
  43. data/spec/button_spec.rb +36 -3
  44. data/spec/buttons_spec.rb +2 -3
  45. data/spec/checkbox_spec.rb +43 -8
  46. data/spec/checkboxes_spec.rb +2 -3
  47. data/spec/div_spec.rb +31 -4
  48. data/spec/divs_spec.rb +2 -3
  49. data/spec/element_spec.rb +36 -6
  50. data/spec/filefield_spec.rb +28 -13
  51. data/spec/filefields_spec.rb +2 -3
  52. data/spec/form_spec.rb +6 -3
  53. data/spec/forms_spec.rb +2 -3
  54. data/spec/frame_spec.rb +14 -5
  55. data/spec/frames_spec.rb +71 -0
  56. data/spec/hidden_spec.rb +21 -3
  57. data/spec/hiddens_spec.rb +2 -3
  58. data/spec/hn_spec.rb +30 -12
  59. data/spec/hns_spec.rb +14 -10
  60. data/spec/html/form_js_bug.html +11 -0
  61. data/spec/html/forms_with_input_elements.html +2 -1
  62. data/spec/html/invalid_js.html +11 -0
  63. data/spec/html/latin1_text.html +1 -0
  64. data/spec/html/non_control_elements.html +8 -4
  65. data/spec/html/simple_ajax.html +22 -0
  66. data/spec/htmlunit_spec.rb +4 -5
  67. data/spec/image_spec.rb +33 -3
  68. data/spec/images_spec.rb +2 -3
  69. data/spec/label_spec.rb +16 -3
  70. data/spec/labels_spec.rb +2 -3
  71. data/spec/li_spec.rb +25 -3
  72. data/spec/link_spec.rb +35 -3
  73. data/spec/links_spec.rb +2 -3
  74. data/spec/lis_spec.rb +2 -3
  75. data/spec/map_spec.rb +19 -3
  76. data/spec/maps_spec.rb +2 -3
  77. data/spec/meta_spec.rb +3 -1
  78. data/spec/ol_spec.rb +17 -3
  79. data/spec/ols_spec.rb +2 -3
  80. data/spec/option_spec.rb +28 -3
  81. data/spec/p_spec.rb +30 -2
  82. data/spec/pre_spec.rb +25 -3
  83. data/spec/pres_spec.rb +2 -3
  84. data/spec/ps_spec.rb +2 -3
  85. data/spec/radio_spec.rb +47 -3
  86. data/spec/radios_spec.rb +2 -3
  87. data/spec/select_list_spec.rb +42 -3
  88. data/spec/select_lists_spec.rb +2 -3
  89. data/spec/span_spec.rb +32 -7
  90. data/spec/spans_spec.rb +2 -4
  91. data/spec/spec_helper.rb +5 -25
  92. data/spec/table_bodies_spec.rb +7 -5
  93. data/spec/table_body_spec.rb +11 -4
  94. data/spec/table_cell_spec.rb +15 -4
  95. data/spec/table_cells_spec.rb +3 -4
  96. data/spec/table_footer_spec.rb +11 -4
  97. data/spec/table_footers_spec.rb +7 -5
  98. data/spec/table_header_spec.rb +11 -4
  99. data/spec/table_headers_spec.rb +7 -5
  100. data/spec/table_row_spec.rb +31 -7
  101. data/spec/table_rows_spec.rb +5 -4
  102. data/spec/table_spec.rb +36 -7
  103. data/spec/tables_spec.rb +2 -3
  104. data/spec/text_field_spec.rb +51 -13
  105. data/spec/text_fields_spec.rb +2 -3
  106. data/spec/ul_spec.rb +18 -3
  107. data/spec/uls_spec.rb +2 -3
  108. data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
  109. data/support/spec_server.rb +9 -0
  110. metadata +167 -161
  111. metadata.gz.sig +0 -0
  112. data/benchmark/bm_2000_spans.rb +0 -48
  113. data/benchmark/bm_digg.rb +0 -26
  114. data/benchmark/bm_google_images.rb +0 -36
  115. data/benchmark/bm_input_locator.rb +0 -69
  116. data/benchmark/loader.rb +0 -9
  117. data/config/hoe.rb +0 -68
  118. data/config/requirements.rb +0 -15
  119. data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
  120. data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
  121. data/lib/celerity/ie.rb +0 -195
  122. data/setup.rb +0 -1583
  123. data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
  124. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
  125. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
  126. data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
  127. data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
  128. data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
  129. data/support/celerity_viewer/rubycocoa/README +0 -94
  130. data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
  131. data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
  132. data/support/celerity_viewer/rubycocoa/main.m +0 -7
  133. data/support/celerity_viewer/rubycocoa/main.rb +0 -27
  134. data/tasks/benchmark.rake +0 -4
  135. data/tasks/environment.rake +0 -7
  136. data/tasks/simple_ci.rake +0 -94
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TableRows do
3
+ describe "TableRows" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -17,6 +16,7 @@ describe TableRows do
17
16
  @browser.table(:id, 'inner').rows.length.should == 1
18
17
  @browser.table(:id, 'outer').rows.length.should == 3
19
18
  end
19
+
20
20
  it "should return the correct number of cells (page context)" do
21
21
  @browser.rows.length.should == 14
22
22
  end
@@ -26,6 +26,7 @@ describe TableRows do
26
26
  it "should return the row at the given index (table context)" do
27
27
  @browser.table(:id, 'outer').rows[1].text.should == "Table 1, Row 1, Cell 1 Table 1, Row 1, Cell 2"
28
28
  end
29
+
29
30
  it "should return the row at the given index (page context)" do
30
31
  @browser.rows[1].text.should == "Before income tax Income tax After income tax"
31
32
  end
@@ -1,14 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Table do
3
+ describe "Table" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
11
- @browser = IE.new
10
+ @browser = Browser.new
12
11
  @browser.goto(TEST_HOST + "/tables.html")
13
12
  end
14
13
 
@@ -20,18 +19,22 @@ describe Table do
20
19
  @browser.table(:index, 1).should exist
21
20
  @browser.table(:xpath, "//table[@id='axis_example']").should exist
22
21
  end
22
+
23
23
  it "should return true if the element exists (default how = :id)" do
24
24
  @browser.table("axis_example").should exist
25
25
  end
26
+
26
27
  it "should return false if the table does not exist" do
27
28
  @browser.table(:id, 'no_such_id').should_not exist
28
29
  @browser.table(:id, /no_such_id/).should_not exist
29
30
  @browser.table(:index, 1337).should_not exist
30
31
  @browser.table(:xpath, "//table[@id='no_such_id']").should_not exist
31
32
  end
33
+
32
34
  it "should raise ArgumentError when 'what' argument is invalid" do
33
35
  lambda { @browser.table(:id, 3.14).exists? }.should raise_error(ArgumentError)
34
36
  end
37
+
35
38
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
36
39
  lambda { @browser.table(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
37
40
  end
@@ -49,6 +52,7 @@ describe Table do
49
52
  @browser.table(:id, 'inner').row_count.should == 1
50
53
  @browser.table(:id, 'outer').row_count.should == 3
51
54
  end
55
+
52
56
  it "should raise an UnknownObjectException if the table doesn't exist" do
53
57
  lambda { @browser.table(:id, 'no_such_id').row_count }.should raise_error(UnknownObjectException)
54
58
  lambda { @browser.table(:index, 1337).row_count }.should raise_error(UnknownObjectException)
@@ -68,6 +72,7 @@ describe Table do
68
72
  @browser.table(:id, 'inner').column_count.should == 2
69
73
  @browser.table(:id, 'outer').column_count.should == 2
70
74
  end
75
+
71
76
  it "should raise an UnknownObjectException if the table doesn't exist" do
72
77
  lambda { @browser.table(:id, 'no_such_id').column_count }.should raise_error(UnknownObjectException)
73
78
  lambda { @browser.table(:index, 1337).column_count }.should raise_error(UnknownObjectException)
@@ -79,17 +84,41 @@ describe Table do
79
84
  @browser.table(:id, 'inner').column_values(1).should == ["Table 2, Row 1, Cell 1"]
80
85
  @browser.table(:id, 'outer').column_values(1).should == ["Table 1, Row 1, Cell 1", "Table 1, Row 2, Cell 1", "Table 1, Row 3, Cell 1"]
81
86
  end
87
+
82
88
  it "should raise UnknownCellException when trying to locate non-existing cell" do
83
89
  lambda { @browser.table(:id, 'inner').column_values(1337) }.should raise_error(UnknownCellException)
84
90
  end
85
91
  end
86
92
 
87
93
  describe "#[]" do
88
- it "should return the row at the given index" do
94
+ it "should return the nth child row" do
89
95
  @browser.table(:id, 'outer')[1].id.should == "outer_first"
90
96
  @browser.table(:id, 'inner')[1].id.should == "inner_first"
91
97
  @browser.table(:id, 'outer')[3].id.should == "outer_last"
92
98
  end
99
+ it "should raise UnknownRowException if the index is out of bounds" do
100
+ lambda { @browser.table(:id, 'outer')[1337] }.should raise_error(UnknownRowException)
101
+ end
102
+ end
103
+
104
+ describe "#child_row" do
105
+ it "should return the nth child row" do
106
+ @browser.table(:id, 'outer').child_row(1).id.should == "outer_first"
107
+ @browser.table(:id, 'inner').child_row(1).id.should == "inner_first"
108
+ @browser.table(:id, 'outer').child_row(3).id.should == "outer_last"
109
+ end
110
+ it "should raise UnknownRowException if the index is out of bounds" do
111
+ lambda { @browser.table(:id, 'outer').child_row(1337) }.should raise_error(UnknownRowException)
112
+ end
113
+ end
114
+
115
+ describe "#child_cell" do
116
+ it "should return the nth child row" do
117
+ @browser.table(:id, 'outer').child_cell(5).text.should == "Table 1, Row 3, Cell 1"
118
+ end
119
+ it "should raise UnknownCellException if the index is out of bounds" do
120
+ lambda { @browser.table(:id, 'outer').child_cell(1337) }.should raise_error(UnknownCellException)
121
+ end
93
122
  end
94
123
 
95
124
  describe "#each" do
@@ -110,7 +139,7 @@ describe Table do
110
139
  describe "#body" do
111
140
  it "should return the correct instance of TableBody" do
112
141
  body = @browser.table(:index, 1).body(:id, 'first')
113
- body.instance_of?(TableBody).should be_true
142
+ body.should be_instance_of(TableBody)
114
143
  body[1][1].text.should == "March 2008"
115
144
  end
116
145
  end
@@ -118,7 +147,7 @@ describe Table do
118
147
  describe "#bodies" do
119
148
  it "should return the correct instance of TableBodies" do
120
149
  bodies = @browser.table(:index, 1).bodies
121
- bodies.instance_of?(TableBodies).should be_true
150
+ bodies.should be_instance_of(TableBodies)
122
151
  bodies[1].id.should == "first"
123
152
  bodies[2].id.should == "second"
124
153
  end
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Tables do
3
+ describe "Tables" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TextField do
3
+ describe "TextField" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -27,15 +26,19 @@ describe TextField do
27
26
  @browser.text_field(:index, 1).should exist
28
27
  @browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
29
28
  end
29
+
30
30
  it "should return true if the element exists (default how = :name)" do
31
31
  @browser.text_field("new_user_email").should exist
32
32
  end
33
+
33
34
  it "should return true if the element exists (no type attribute)" do
34
35
  @browser.text_field(:id, 'new_user_first_name').should exist
35
36
  end
37
+
36
38
  it "should return true if the element exists (invalid type attribute)" do
37
39
  @browser.text_field(:id, 'new_user_last_name').should exist
38
40
  end
41
+
39
42
  it "should return false if the element does not exist" do
40
43
  @browser.text_field(:id, 'no_such_id').should_not exist
41
44
  @browser.text_field(:id, /no_such_id/).should_not exist
@@ -50,9 +53,11 @@ describe TextField do
50
53
  @browser.text_field(:index, 1337).should_not exist
51
54
  @browser.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
52
55
  end
56
+
53
57
  it "should raise ArgumentError when 'what' argument is invalid" do
54
58
  lambda { @browser.text_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
55
59
  end
60
+
56
61
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
57
62
  lambda { @browser.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
58
63
  end
@@ -63,6 +68,7 @@ describe TextField do
63
68
  it "should return the id attribute if the text field exists" do
64
69
  @browser.text_field(:index, 4).id.should == "new_user_occupation"
65
70
  end
71
+
66
72
  it "should raise UnknownObjectException if the text field doesn't exist" do
67
73
  lambda { @browser.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
68
74
  end
@@ -72,6 +78,7 @@ describe TextField do
72
78
  it "should return the name attribute if the text field exists" do
73
79
  @browser.text_field(:index, 4).name.should == "new_user_occupation"
74
80
  end
81
+
75
82
  it "should raise UnknownObjectException if the text field doesn't exist" do
76
83
  lambda { @browser.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
77
84
  end
@@ -81,6 +88,7 @@ describe TextField do
81
88
  it "should return the title attribute if the text field exists" do
82
89
  @browser.text_field(:id, "new_user_code").title.should == "Your personal code"
83
90
  end
91
+
84
92
  it "should raise UnknownObjectException if the text field doesn't exist" do
85
93
  lambda { @browser.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
86
94
  end
@@ -90,12 +98,15 @@ describe TextField do
90
98
  it "should return the type attribute if the text field exists" do
91
99
  @browser.text_field(:index, 4).type.should == "text"
92
100
  end
101
+
93
102
  it "should return 'text' if the type attribute is invalid" do
94
103
  @browser.text_field(:id, 'new_user_last_name').type.should == "text"
95
104
  end
105
+
96
106
  it "should return 'text' if the type attribute does not exist" do
97
107
  @browser.text_field(:id, 'new_user_first_name').type.should == "text"
98
108
  end
109
+
99
110
  it "should raise UnknownObjectException if the text field doesn't exist" do
100
111
  lambda { @browser.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
101
112
  end
@@ -107,10 +118,23 @@ describe TextField do
107
118
  @browser.text_field(:index, 4).value.should == "Developer"
108
119
  @browser.text_field(:name, /new_user_occupation/i).value.should == "Developer"
109
120
  end
121
+
110
122
  it "should raise UnknownObjectException if the text field doesn't exist" do
111
123
  lambda { @browser.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
112
124
  end
113
125
  end
126
+
127
+ describe "#respond_to?" do
128
+ it "should return true for all attribute methods" do
129
+ @browser.text_field(:index, 1).should respond_to(:class_name)
130
+ @browser.text_field(:index, 1).should respond_to(:id)
131
+ @browser.text_field(:index, 1).should respond_to(:name)
132
+ @browser.text_field(:index, 1).should respond_to(:title)
133
+ @browser.text_field(:index, 1).should respond_to(:type)
134
+ @browser.text_field(:index, 1).should respond_to(:value)
135
+ end
136
+ end
137
+
114
138
 
115
139
  # Access methods
116
140
  describe "#enabled?" do
@@ -118,9 +142,11 @@ describe TextField do
118
142
  @browser.text_field(:name, "new_user_occupation").should be_enabled
119
143
  @browser.text_field(:id, "new_user_email").should be_enabled
120
144
  end
145
+
121
146
  it "should return false for disabled text fields" do
122
147
  @browser.text_field(:name, "new_user_species").should_not be_enabled
123
148
  end
149
+
124
150
  it "should raise UnknownObjectException if the text field doesn't exist" do
125
151
  lambda { @browser.text_field(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
126
152
  end
@@ -130,9 +156,11 @@ describe TextField do
130
156
  it "should return true if the text field is disabled" do
131
157
  @browser.text_field(:id, 'new_user_species').should be_disabled
132
158
  end
159
+
133
160
  it "should return false if the text field is enabled" do
134
161
  @browser.text_field(:index, 1).should_not be_disabled
135
162
  end
163
+
136
164
  it "should raise UnknownObjectException if the text field doesn't exist" do
137
165
  lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
138
166
  end
@@ -143,9 +171,11 @@ describe TextField do
143
171
  @browser.text_field(:name, "new_user_code").should be_readonly
144
172
  @browser.text_field(:id, "new_user_code").should be_readonly
145
173
  end
174
+
146
175
  it "should return false for writeable text fields" do
147
176
  @browser.text_field(:name, "new_user_email").should_not be_readonly
148
177
  end
178
+
149
179
  it "should raise UnknownObjectException if the text field doesn't exist" do
150
180
  lambda { @browser.text_field(:id, 'no_such_id').readonly? }.should raise_error(UnknownObjectException)
151
181
  end
@@ -158,16 +188,20 @@ describe TextField do
158
188
  @browser.text_field(:name, "new_user_occupation").append(" Append This")
159
189
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer Append This"
160
190
  end
191
+
161
192
  it "should append multi-byte characters" do
162
193
  @browser.text_field(:name, "new_user_occupation").append(" ijij")
163
194
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer ijij"
164
195
  end
196
+
165
197
  it "should raise ObjectReadOnlyException if the object is read only" do
166
198
  lambda { @browser.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
167
199
  end
200
+
168
201
  it "should raise ObjectDisabledException if the object is disabled" do
169
202
  lambda { @browser.text_field(:name, "new_user_species").append("Append This") }.should raise_error(ObjectDisabledException)
170
203
  end
204
+
171
205
  it "should raise UnknownObjectException if the object doesn't exist" do
172
206
  lambda { @browser.text_field(:name, "no_such_name").append("Append This") }.should raise_error(UnknownObjectException)
173
207
  end
@@ -180,6 +214,7 @@ describe TextField do
180
214
  @browser.text_field(:id, "delete_user_comment").clear
181
215
  @browser.text_field(:id, "delete_user_comment").get_contents.should be_empty
182
216
  end
217
+
183
218
  it "should raise UnknownObjectException if the text field doesn't exist" do
184
219
  lambda { @browser.text_field(:id, "no_such_id").clear }.should raise_error(UnknownObjectException)
185
220
  end
@@ -192,6 +227,7 @@ describe TextField do
192
227
  @browser.text_field(:name, "new_user_first_name").value.should be_empty
193
228
  @browser.text_field(:id, "new_user_last_name").value.should == "Smith"
194
229
  end
230
+
195
231
  it "should raise UnknownObjectException if either of the text fields doesn't exist" do
196
232
  lambda { @browser.text_field(:id, "no_such_id").drag_contents_to(:name, "new_user_last_name") }.should raise_error(UnknownObjectException)
197
233
  lambda { @browser.text_field(:name, "new_user_first_name").drag_contents_to(:id, "no_such_id") }.should raise_error(UnknownObjectException)
@@ -202,9 +238,11 @@ describe TextField do
202
238
  it "should return the contents of the text field" do
203
239
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer"
204
240
  end
241
+
205
242
  it "should raise UnknownObjectException when accessing a non-existing element" do
206
243
  lambda { @browser.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
207
244
  end
245
+
208
246
  it "should raise UnknownObjectException if the text field doesn't exist" do
209
247
  lambda { @browser.text_field(:id, "no_such_id").get_contents }.should raise_error(UnknownObjectException)
210
248
  end
@@ -215,19 +253,17 @@ describe TextField do
215
253
  @browser.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
216
254
  @browser.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
217
255
  end
256
+
218
257
  it "should be able to set multi-byte characters" do
219
258
  @browser.text_field(:name, "new_user_occupation").value = "ijij"
220
259
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
221
260
  end
222
- it "should be able to set Latin 1 characters" do
223
- @browser.goto(TEST_HOST + "/latin1_text.html")
224
- @browser.text_field(:id, "charset").value = "B\370rsmegler"
225
- @browser.text_field(:id, "charset").value.should == "B\370rsmegler"
226
- end
261
+
227
262
  it "should set the value of a textarea element" do
228
263
  @browser.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
229
264
  @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
230
265
  end
266
+
231
267
  it "should raise UnknownObjectException if the text field doesn't exist" do
232
268
  lambda { @browser.text_field(:name, "no_such_name").value = 'yo' }.should raise_error(UnknownObjectException)
233
269
  end
@@ -238,27 +274,27 @@ describe TextField do
238
274
  @browser.text_field(:id, 'new_user_email').set('Bye Cruel World')
239
275
  @browser.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
240
276
  end
277
+
241
278
  it "should set the value of a textarea element" do
242
279
  @browser.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
243
280
  @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
244
281
  end
282
+
245
283
  it "should fire events" do
246
284
  @browser.text_field(:id, "new_user_username").set("Hello World")
247
285
  @browser.span(:id, "current_length").text.should == "11"
248
286
  end
287
+
249
288
  it "should be able to set the value of a password field" do
250
289
  @browser.text_field(:name , 'new_user_password').set('secret')
251
290
  @browser.text_field(:name , 'new_user_password').value.should == 'secret'
252
291
  end
292
+
253
293
  it "should be able to set multi-byte characters" do
254
294
  @browser.text_field(:name, "new_user_occupation").set("ijij")
255
295
  @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
256
296
  end
257
- it "should be able to set Latin 1 characters" do
258
- @browser.goto(TEST_HOST + "/latin1_text.html")
259
- @browser.text_field(:id, "charset").set("B\370rsmegler")
260
- @browser.text_field(:id, "charset").get_contents.should == "B\370rsmegler"
261
- end
297
+
262
298
  it "should raise UnknownObjectException if the text field doesn't exist" do
263
299
  lambda { @browser.text_field(:id, "no_such_id").set('secret') }.should raise_error(UnknownObjectException)
264
300
  end
@@ -269,10 +305,12 @@ describe TextField do
269
305
  @browser.text_field(:name, "new_user_occupation").verify_contains("Developer").should be_true
270
306
  @browser.text_field(:name, "new_user_occupation").verify_contains(/Developer/).should be_true
271
307
  end
308
+
272
309
  it "should not verify that a text field contains a non-existing value" do
273
310
  @browser.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
274
311
  @browser.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
275
312
  end
313
+
276
314
  it "should raise UnknownObjectException if the text field doesn't exist" do
277
315
  lambda { @browser.text_field(:id, "no_such_id").verify_contains("Developer") }.should raise_error(UnknownObjectException)
278
316
  end
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe TextFields do
3
+ describe "TextFields" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -1,10 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Ul do
3
+ describe "Ul" do
4
4
 
5
5
  before :all do
6
- @browser = IE.new
7
- add_spec_checker(@browser)
6
+ @browser = Browser.new
8
7
  end
9
8
 
10
9
  before :each do
@@ -19,9 +18,11 @@ describe Ul do
19
18
  @browser.ul(:index, 1).should exist
20
19
  @browser.ul(:xpath, "//ul[@id='navbar']").should exist
21
20
  end
21
+
22
22
  it "should return true if the element exists (default how = :id)" do
23
23
  @browser.ul("navbar").should exist
24
24
  end
25
+
25
26
  it "should return false if the 'ul' doesn't exist" do
26
27
  @browser.ul(:id, "no_such_id").should_not exist
27
28
  @browser.ul(:id, /no_such_id/).should_not exist
@@ -32,9 +33,11 @@ describe Ul do
32
33
  @browser.ul(:index, 1337).should_not exist
33
34
  @browser.ul(:xpath, "//ul[@id='no_such_id']").should_not exist
34
35
  end
36
+
35
37
  it "should raise ArgumentError when 'what' argument is invalid" do
36
38
  lambda { @browser.ul(:id, 3.14).exists? }.should raise_error(ArgumentError)
37
39
  end
40
+
38
41
  it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
42
  lambda { @browser.ul(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
43
  end
@@ -45,9 +48,11 @@ describe Ul do
45
48
  it "should return the class attribute" do
46
49
  @browser.ul(:id, 'navbar').class_name.should == 'navigation'
47
50
  end
51
+
48
52
  it "should return an empty string if the element exists and the attribute doesn't" do
49
53
  @browser.ul(:index, 2).class_name.should == ''
50
54
  end
55
+
51
56
  it "should raise UnknownObjectException if the ul doesn't exist" do
52
57
  lambda { @browser.ul(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
53
58
  end
@@ -57,15 +62,25 @@ describe Ul do
57
62
  it "should return the id attribute" do
58
63
  @browser.ul(:class, 'navigation').id.should == "navbar"
59
64
  end
65
+
60
66
  it "should return an empty string if the element exists and the attribute doesn't" do
61
67
  @browser.ul(:index, 2).id.should == ''
62
68
  end
69
+
63
70
  it "should raise UnknownObjectException if the ul doesn't exist" do
64
71
  lambda { @browser.ul(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
65
72
  lambda { @browser.ul(:index, 1337).id }.should raise_error(UnknownObjectException)
66
73
  end
67
74
  end
68
75
 
76
+ describe "#respond_to?" do
77
+ it "should return true for all attribute methods" do
78
+ @browser.ul(:index, 1).should respond_to(:class_name)
79
+ @browser.ul(:index, 1).should respond_to(:id)
80
+ end
81
+ end
82
+
83
+
69
84
  after :all do
70
85
  @browser.close
71
86
  end