commonwatir 3.0.0.rc3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README +24 -0
  2. data/Rakefile +3 -14
  3. data/commonwatir.gemspec +18 -0
  4. data/lib/watir.rb +1 -14
  5. metadata +19 -131
  6. data/CHANGES +0 -712
  7. data/LICENSE +0 -34
  8. data/README.rdoc +0 -101
  9. data/VERSION +0 -1
  10. data/lib/watir/assertions.rb +0 -44
  11. data/lib/watir/browser.rb +0 -149
  12. data/lib/watir/browsers.rb +0 -13
  13. data/lib/watir/element_extensions.rb +0 -69
  14. data/lib/watir/exceptions.rb +0 -50
  15. data/lib/watir/matches.rb +0 -23
  16. data/lib/watir/options.rb +0 -56
  17. data/lib/watir/testcase.rb +0 -97
  18. data/lib/watir/util.rb +0 -35
  19. data/lib/watir/version.rb +0 -4
  20. data/lib/watir/wait.rb +0 -41
  21. data/lib/watir/wait_helper.rb +0 -12
  22. data/lib/watir/waiter.rb +0 -98
  23. data/unittests/attach_to_existing_window_test.rb +0 -70
  24. data/unittests/browser_test.rb +0 -38
  25. data/unittests/buttons_test.rb +0 -288
  26. data/unittests/dd_test.rb +0 -84
  27. data/unittests/dl_test.rb +0 -82
  28. data/unittests/dt_test.rb +0 -82
  29. data/unittests/element_collections_test.rb +0 -22
  30. data/unittests/element_test.rb +0 -24
  31. data/unittests/em_test.rb +0 -81
  32. data/unittests/form2_test.rb +0 -22
  33. data/unittests/html/blankpage.html +0 -11
  34. data/unittests/html/buttons1.html +0 -40
  35. data/unittests/html/buttons2.html +0 -60
  36. data/unittests/html/definition_lists.html +0 -48
  37. data/unittests/html/elements.html +0 -13
  38. data/unittests/html/emphasis.html +0 -12
  39. data/unittests/html/entertainment_com.html +0 -667
  40. data/unittests/html/frame_buttons.html +0 -4
  41. data/unittests/html/images/button.jpg +0 -0
  42. data/unittests/html/pass.html +0 -10
  43. data/unittests/html/phrase_elements.html +0 -15
  44. data/unittests/html/select_lists.html +0 -18
  45. data/unittests/html/utf8.html +0 -12
  46. data/unittests/html/visibility.html +0 -90
  47. data/unittests/html/wait.html +0 -15
  48. data/unittests/html/watir_unit_tests.css +0 -64
  49. data/unittests/html/whitespace.html +0 -29
  50. data/unittests/options.yml.example +0 -13
  51. data/unittests/select_list_test.rb +0 -19
  52. data/unittests/setup.rb +0 -17
  53. data/unittests/setup/browser.rb +0 -14
  54. data/unittests/setup/capture_io_helper.rb +0 -17
  55. data/unittests/setup/filter.rb +0 -24
  56. data/unittests/setup/lib.rb +0 -22
  57. data/unittests/setup/options.rb +0 -29
  58. data/unittests/setup/testUnitAddons.rb +0 -8
  59. data/unittests/setup/watir-unittest.rb +0 -78
  60. data/unittests/strong_test.rb +0 -46
  61. data/unittests/utf8_test.rb +0 -24
  62. data/unittests/visibility_test.rb +0 -47
  63. data/unittests/wait_test.rb +0 -126
  64. data/unittests/whitespace_test.rb +0 -46
@@ -1,38 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
- require 'unittests/setup'
3
-
4
- class TC_Browser < Test::Unit::TestCase
5
- location __FILE__
6
-
7
- def setup
8
- uses_page "utf8.html" # could be any page really
9
- end
10
-
11
- def test_status_returns_window_status
12
- browser.execute_script "window.status = 'All done!'"
13
- assert_match /done/i, browser.status
14
- end
15
-
16
- end
17
-
18
- class TC_Browser_Exists < Test::Unit::TestCase
19
- def setup
20
- @browser = Watir::Browser.new
21
- @browser.goto self.class.html_root + "blankpage.html"
22
- end
23
-
24
- def teardown
25
- @browser.close if @browser.exists?
26
- end
27
-
28
- def test_exists
29
- assert @browser.exists?
30
- end
31
-
32
- def test_not_exists
33
- @browser.close
34
- assert_false @browser.exists?
35
- end
36
- end
37
-
38
-
@@ -1,288 +0,0 @@
1
- # feature tests for Buttons
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
-
6
- class TC_Button < Test::Unit::TestCase
7
- location __FILE__
8
-
9
- def setup
10
- uses_page "buttons1.html"
11
- end
12
-
13
- def test_exceptions_on_methods
14
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").id }
15
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").name }
16
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").disabled? }
17
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").type }
18
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").value }
19
- end
20
-
21
- def test_exceptions_with_click
22
- assert_raises(UnknownObjectException) { browser.button(:caption, "Missing Caption").click }
23
- assert_raises(UnknownObjectException) { browser.button(:id, "missingID").click }
24
- end
25
-
26
- def test_disabled_exception
27
- assert_raises(ObjectDisabledException) { browser.button(:caption, "Disabled Button").click }
28
- end
29
-
30
- def test_exception_with_enabled
31
- assert_raises(UnknownObjectException) { browser.button(:name, "noName").enabled? }
32
- end
33
-
34
- tag_method :test_properties, :fails_on_ie
35
- def test_properties
36
- assert_equal("b1", browser.button(:index, 1).name)
37
- assert_equal("b2", browser.button(:index, 1).id)
38
- assert_equal("button", browser.button(:index, 1).type)
39
- assert_equal("Click Me", browser.button(:index, 1).value)
40
- assert_equal(false, browser.button(:index, 1).disabled?)
41
- assert_equal("italic_button", browser.button(:name, "b1").class_name)
42
- assert_equal("", browser.button(:name , "b4").class_name)
43
-
44
- assert_equal("b1", browser.button(:id, "b2").name)
45
- assert_equal("b2", browser.button(:id, "b2").id)
46
- assert_equal("button", browser.button(:id, "b2").type)
47
-
48
- assert_equal("b4", browser.button(:index, 2).name)
49
- assert_equal("b5", browser.button(:index, 2).id)
50
- assert_equal("button", browser.button(:index, 2).type)
51
- assert_equal("Disabled Button", browser.button(:index, 2).value)
52
- assert_equal(true, browser.button(:index, 2).disabled?)
53
-
54
- assert_equal("", browser.button(:index, 2).title)
55
- assert_equal("this is button1", browser.button(:index, 1).title)
56
- end
57
-
58
- tag_method :test_properties_ie, :fails_on_firefox
59
- def test_properties_ie
60
- assert_equal("b1", browser.button(:index, 0).name)
61
- assert_equal("b2", browser.button(:index, 0).id)
62
- assert_equal("button", browser.button(:index, 0).type)
63
- assert_equal("Click Me", browser.button(:index, 0).value)
64
- assert_equal(false, browser.button(:index, 0).disabled?)
65
- assert_equal("italic_button", browser.button(:name, "b1").class_name)
66
- assert_equal("", browser.button(:name , "b4").class_name)
67
-
68
- assert_equal("b1", browser.button(:id, "b2").name)
69
- assert_equal("b2", browser.button(:id, "b2").id)
70
- assert_equal("button", browser.button(:id, "b2").type)
71
-
72
- assert_equal("b4", browser.button(:index, 1).name)
73
- assert_equal("b5", browser.button(:index, 1).id)
74
- assert_equal("button", browser.button(:index, 1).type)
75
- assert_equal("Disabled Button", browser.button(:index, 1).value)
76
- assert_equal(true, browser.button(:index, 1).disabled?)
77
-
78
- assert_equal("", browser.button(:index, 1).title)
79
- assert_equal("this is button1", browser.button(:index, 0).title)
80
- end
81
-
82
- def test_click_and_caption
83
- browser.button(:caption, "Click Me").click
84
- assert(browser.text.include?("PASS") )
85
- end
86
-
87
- def test_access_by_class
88
- assert_equal('b1', browser.button(:class, 'italic_button').name)
89
- end
90
-
91
- def test_access_by_class_name
92
- assert_equal('b1', browser.button(:class_name, 'italic_button').name)
93
- end
94
-
95
- def test_exists
96
- assert(browser.button(:caption, "Click Me").exists?)
97
- assert(browser.button(:caption, "Submit").exists?)
98
- assert(browser.button(:name, "b1").exists?)
99
- assert(browser.button(:id, "b2").exists?)
100
- assert(browser.button(:caption, /sub/i).exists?)
101
-
102
- assert_false(browser.button(:caption, "missingcaption").exists?)
103
- assert_false(browser.button(:name, "missingname").exists?)
104
- assert_false(browser.button(:id, "missingid").exists?)
105
- assert_false(browser.button(:caption, /missing/i).exists?)
106
- end
107
-
108
- def test_enabled
109
- assert(browser.button(:caption, "Click Me").enabled?)
110
- assert_false(browser.button(:caption, "Disabled Button").enabled?)
111
- assert_false(browser.button(:name, "b4").enabled?)
112
- assert_false(browser.button(:id, "b5").enabled?)
113
- end
114
-
115
- end
116
-
117
- class TC_Button2 < Test::Unit::TestCase
118
- location __FILE__
119
-
120
- def setup
121
- uses_page "buttons2.html"
122
- end
123
-
124
- def test_exists
125
- assert(browser.button(:caption, "Click Me2").exists?)
126
- assert(browser.button(:caption, "Disabled Button2").exists?)
127
- assert(browser.button(:caption, "Sign In").exists?)
128
- end
129
-
130
- def test_button2
131
- assert_equal("b6", browser.button(:id, "b7").name)
132
- assert_equal("b7", browser.button(:name, "b6").id)
133
- assert_equal("Click Me2", browser.button(:id, "b7").value)
134
- assert_equal(false, browser.button(:id, "b7").disabled?)
135
- assert_equal("italic_button", browser.button(:name, "b6").class_name )
136
-
137
- assert_equal("b8", browser.button(:id, "b9").name)
138
- assert_equal("b9", browser.button(:name, "b8").id)
139
- assert_equal("Disabled Button2", browser.button(:id, "b9").value)
140
- assert_equal(false, browser.button(:id, "b9").enabled?)
141
- assert_equal("", browser.button(:name, "b8").class_name)
142
- assert_equal("Sign In", browser.button(:caption, "Sign In").value)
143
-
144
- assert(browser.button(:caption, "Click Me").enabled?)
145
-
146
- assert_false(browser.button(:caption, "Disabled Button2").enabled?)
147
-
148
- assert_raises(ObjectDisabledException) { browser.button(:caption, "Disabled Button2").click }
149
-
150
- browser.button(:caption, "Click Me2").click
151
- assert(browser.text.include?("PASS"))
152
- end
153
-
154
- def test_buttons_length
155
- arrButtons = browser.buttons
156
- assert_equal(7, arrButtons.length)
157
- end
158
-
159
- tag_method :test_buttons, :fails_on_ie
160
- def test_buttons
161
- arrButtons = browser.buttons
162
- assert_equal("b2", arrButtons[1].id)
163
- assert_equal("b5", arrButtons[2].id)
164
- assert_equal("Submit", arrButtons[3].value)
165
- assert_equal("sub3", arrButtons[4].name)
166
- assert_equal("b7", arrButtons[5].id)
167
- assert_equal("b9", arrButtons[6].id)
168
- assert_equal("Sign In", arrButtons[7].value)
169
- end
170
-
171
- tag_method :test_buttons_ie, :fails_on_firefox
172
- def test_buttons_ie
173
- arrButtons = browser.buttons
174
- assert_equal("b2", arrButtons[0].id)
175
- assert_equal("b5", arrButtons[1].id)
176
- assert_equal("Submit", arrButtons[2].value)
177
- assert_equal("sub3", arrButtons[3].name)
178
- assert_equal("b7", arrButtons[4].id)
179
- assert_equal("b9", arrButtons[5].id)
180
- assert_equal("Sign In", arrButtons[6].value)
181
- end
182
-
183
- tag_method :test_class_buttons, :fails_on_ie
184
- def test_class_buttons
185
- arr_buttons = browser.buttons
186
- arr_buttons.each do |b|
187
- assert_class b, 'Button'
188
- end
189
- # test properties
190
- assert_equal("b2", arr_buttons[1].id)
191
- assert_equal("b1", arr_buttons[1].name)
192
- assert_equal("button", arr_buttons[1].type)
193
- assert_equal("Click Me", arr_buttons[1].value)
194
- assert_equal(false, arr_buttons[1].disabled?)
195
- assert_equal("italic_button", arr_buttons[1].class_name)
196
- assert_equal( "this is button1", arr_buttons[1].title)
197
-
198
- assert_equal("b5", arr_buttons[2].id)
199
- assert_equal("b4", arr_buttons[2].name)
200
- assert_equal("button", arr_buttons[2].type)
201
- assert_equal("Disabled Button", arr_buttons[2].value)
202
- assert_equal(true, arr_buttons[2].disabled?)
203
- assert_equal( "", arr_buttons[2].title)
204
- assert_equal("", arr_buttons[2].class_name)
205
-
206
- assert_equal("Submit", arr_buttons[3].value)
207
- assert_equal("sub3", arr_buttons[4].name)
208
- assert_equal("b7", arr_buttons[5].id)
209
- assert_equal("b9", arr_buttons[6].id)
210
- assert_equal("Sign In", arr_buttons[7].value)
211
- end
212
-
213
- tag_method :test_class_buttons_ie, :fails_on_firefox
214
- def test_class_buttons_ie
215
- arr_buttons = browser.buttons
216
- arr_buttons.each do |b|
217
- assert_class b, 'Button'
218
- end
219
- # test properties
220
- assert_equal("b2", arr_buttons[0].id)
221
- assert_equal("b1", arr_buttons[0].name)
222
- assert_equal("button", arr_buttons[0].type)
223
- assert_equal("Click Me", arr_buttons[0].value)
224
- assert_equal(false, arr_buttons[0].disabled?)
225
- assert_equal("italic_button", arr_buttons[0].class_name)
226
- assert_equal( "this is button1", arr_buttons[0].title)
227
-
228
- assert_equal("b5", arr_buttons[1].id)
229
- assert_equal("b4", arr_buttons[1].name)
230
- assert_equal("button", arr_buttons[1].type)
231
- assert_equal("Disabled Button", arr_buttons[1].value)
232
- assert_equal(true, arr_buttons[1].disabled?)
233
- assert_equal( "", arr_buttons[1].title)
234
- assert_equal("", arr_buttons[1].class_name)
235
-
236
- assert_equal("Submit", arr_buttons[2].value)
237
- assert_equal("sub3", arr_buttons[3].name)
238
- assert_equal("b7", arr_buttons[4].id)
239
- assert_equal("b9", arr_buttons[5].id)
240
- assert_equal("Sign In", arr_buttons[6].value)
241
- end
242
-
243
- def test_hash_syntax
244
- assert_equal('Click Me2', browser.button(:id => 'b7').value)
245
- end
246
-
247
- tag_method :test_class_and_index, :fails_on_ie
248
- def test_class_and_index
249
- assert_equal('Click Me2',
250
- browser.button(:class => 'italic_button', :index => 2).value)
251
- end
252
-
253
- tag_method :test_class_and_index_ie, :fails_on_firefox
254
- def test_class_and_index_ie
255
- assert_equal('Click Me2',
256
- browser.button(:class => 'italic_button', :index => 1).value)
257
- end
258
-
259
- def test_name_and_id #sick, but what the hell
260
- assert_equal('Disabled Button2',
261
- browser.button(:name => 'b8', :id => 'b9').value)
262
- end
263
-
264
- def test_not_found_with_multi
265
- exception = assert_raise(UnknownObjectException) do
266
- browser.button(:value => 'Click Me', :index => 2).name
267
- end
268
- # can't assume hash ordering
269
- assert_match(/Unable to locate element, using \{.*(:index=>2, :value=>"Click Me"|:value=>"Click Me", :index=>2).*\}/, exception.message)
270
- end
271
- end
272
-
273
- class TC_Button_Frame < Test::Unit::TestCase
274
- location __FILE__
275
-
276
- def setup
277
- goto_page "frame_buttons.html"
278
- end
279
-
280
- def test_in_frame
281
- assert(browser.frame(:name, "buttonFrame").button(:caption, "Click Me").enabled?)
282
- end
283
-
284
- def test_error_in_frame
285
- assert_raises(UnknownObjectException) { browser.button(:caption, "Disabled Button").enabled?}
286
- end
287
- end
288
-
@@ -1,84 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
- require 'unittests/setup'
3
-
4
- class TC_Dd < Test::Unit::TestCase
5
- include Watir::Exception
6
- location __FILE__
7
-
8
- def setup
9
- uses_page "definition_lists.html"
10
- end
11
-
12
- def test_exists
13
- assert browser.dd(:id, "someone").exists?, "Could not find <dd> by :id"
14
- assert browser.dd(:class, "name").exists?, "Could not find <dd> by :class"
15
- assert_nothing_raised do
16
- browser.dd(:xpath, "//dd[@id='someone']").locate
17
- end
18
- assert browser.dd(:xpath, "//dd[@id='someone']").exists?, "Could not find <dd> by :xpath"
19
- assert browser.dd(:index, 1).exists?, "Could not find <dd> by :index"
20
- end
21
-
22
- def test_does_not_exist
23
- assert !browser.dd(:id, 'no_such_id').exists?, "Found non-existing <dd>"
24
- end
25
-
26
- def test_attribute_class_name
27
- assert_equal "name", browser.dd(:id, "someone").class_name
28
- assert_equal "", browser.dd(:id, 'city').class_name
29
- assert_raises(UnknownObjectException) do
30
- browser.dd(:id, 'no_such_id').class_name
31
- end
32
- end
33
-
34
- def test_attribute_id
35
- assert_equal "someone", browser.dd(:class, 'name').id
36
- assert_equal "", browser.dd(:class, 'address').id
37
- assert_raises(UnknownObjectException) do
38
- browser.dd(:id, 'no_such_id').id
39
- end
40
- end
41
-
42
- def test_attribute_title
43
- assert_equal "someone", browser.dd(:class, 'name').title
44
- assert_equal "", browser.dd(:class, 'noop').title
45
- assert_raises(UnknownObjectException) do
46
- browser.dd(:id, 'no_such_id').title
47
- end
48
- end
49
-
50
- def test_attribute_text
51
- assert_equal "John Doe", browser.dd(:id, "someone").text
52
- assert_equal "", browser.dd(:class, 'noop').text
53
- assert_raises(UnknownObjectException) do
54
- browser.dd(:id, 'no_such_id').text
55
- end
56
- end
57
-
58
- tag_method :test_dd_iterator, :fails_on_ie
59
- def test_dd_iterator
60
- assert_equal(11, browser.dds.length)
61
- assert_equal("education", browser.dds[2].title)
62
-
63
- browser.dds.each_with_index do |dd, idx|
64
- assert_equal(browser.dd(:index,idx+1).text, dd.text)
65
- assert_equal(browser.dd(:index,idx+1).id, dd.id)
66
- assert_equal(browser.dd(:index,idx+1).class_name , dd.class_name)
67
- assert_equal(browser.dd(:index,idx+1).title, dd.title)
68
- end
69
- end
70
-
71
- tag_method :test_dd_iterator_ie, :fails_on_firefox
72
- def test_dd_iterator_ie
73
- assert_equal(11, browser.dds.length)
74
- assert_equal("education", browser.dds[1].title)
75
-
76
- browser.dds.each_with_index do |dd, idx|
77
- assert_equal(browser.dd(:index,idx).text, dd.text)
78
- assert_equal(browser.dd(:index,idx).id, dd.id)
79
- assert_equal(browser.dd(:index,idx).class_name , dd.class_name)
80
- assert_equal(browser.dd(:index,idx).title, dd.title)
81
- end
82
- end
83
-
84
- end
@@ -1,82 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
- require 'unittests/setup'
3
-
4
- class TC_Dl < Test::Unit::TestCase
5
- include Watir::Exception
6
- location __FILE__
7
-
8
- def setup
9
- @html_dir = "#{File.dirname(__FILE__)}/html"
10
- uses_page "definition_lists.html"
11
- end
12
-
13
- def test_exists
14
- assert browser.dl(:id, "experience-list").exists?, "Could not find <dl> by :id"
15
- assert browser.dl(:class, "list").exists?, "Could not find <dl> by :class"
16
- assert browser.dl(:xpath, "//dl[@id='experience-list']").exists?, "Could not find <dl> by :xpath"
17
- assert browser.dl(:index, 1).exists?, "Could not find <dl> by :index"
18
- end
19
-
20
- def test_does_not_exist
21
- assert !browser.dl(:id, 'no_such_id').exists?, "Found non-existing <dl>"
22
- end
23
-
24
- def test_attribute_class_name
25
- assert_equal "list", browser.dl(:id, "experience-list").class_name
26
- assert_equal "", browser.dl(:id, 'noop').class_name
27
- assert_raises(UnknownObjectException) do
28
- browser.dl(:id, 'no_such_id').class_name
29
- end
30
- end
31
-
32
- def test_attribute_id
33
- assert_equal "experience-list", browser.dl(:class, 'list').id
34
- assert_equal "", browser.dl(:class, 'personalia').id
35
- assert_raises(UnknownObjectException) do
36
- browser.dl(:id, 'no_such_id').id
37
- end
38
- end
39
-
40
- def test_attribute_title
41
- assert_equal "experience", browser.dl(:class, 'list').title
42
- assert_equal "", browser.dl(:id, 'noop').title
43
- assert_raises(UnknownObjectException) do
44
- browser.dl(:id, 'no_such_id').title
45
- end
46
- end
47
-
48
- def test_attribute_text
49
- assert_match /11 years/, browser.dl(:id, "experience-list").text
50
- assert_equal "", browser.dl(:id, 'noop').text
51
- assert_raises(UnknownObjectException) do
52
- browser.dl(:id, 'no_such_id').text
53
- end
54
- end
55
-
56
- tag_method :test_dls_iterator, :fails_on_ie
57
- def test_dls_iterator
58
- assert_equal(3, browser.dls.length)
59
- assert_equal("experience-list", browser.dls[1].id)
60
-
61
- browser.dls.each_with_index do |dl, idx|
62
- assert_equal(browser.dl(:index,idx+1).text, dl.text)
63
- assert_equal(browser.dl(:index,idx+1).id, dl.id)
64
- assert_equal(browser.dl(:index,idx+1).class_name , dl.class_name)
65
- assert_equal(browser.dl(:index,idx+1).title, dl.title)
66
- end
67
- end
68
-
69
- tag_method :test_dls_iterator_ie, :fails_on_firefox
70
- def test_dls_iterator_ie
71
- assert_equal(3, browser.dls.length)
72
- assert_equal("experience-list", browser.dls[0].id)
73
-
74
- browser.dls.each_with_index do |dl, idx|
75
- assert_equal(browser.dl(:index,idx).text, dl.text)
76
- assert_equal(browser.dl(:index,idx).id, dl.id)
77
- assert_equal(browser.dl(:index,idx).class_name , dl.class_name)
78
- assert_equal(browser.dl(:index,idx).title, dl.title)
79
- end
80
- end
81
-
82
- end