operawatir 0.3-jruby → 0.3.2-jruby

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/Gemfile +6 -2
  2. data/LICENSE +1 -1
  3. data/Rakefile +7 -8
  4. data/VERSION +1 -1
  5. data/bin/desktopwatir +3 -0
  6. data/bin/operawatir +2 -2
  7. data/lib/operadriver/webdriver-opera.jar +0 -0
  8. data/lib/operawatir.rb +14 -8
  9. data/lib/operawatir/browser.rb +49 -38
  10. data/lib/operawatir/compat/collection.rb +6 -0
  11. data/lib/operawatir/compat/element.rb +5 -2
  12. data/lib/operawatir/compat/element_finders.rb +19 -0
  13. data/lib/operawatir/desktop-waiter.rb +144 -0
  14. data/lib/operawatir/desktop_browser.rb +506 -0
  15. data/lib/operawatir/desktop_common.rb +111 -0
  16. data/lib/operawatir/desktop_container.rb +252 -0
  17. data/lib/operawatir/desktop_enums.rb +42 -0
  18. data/lib/operawatir/desktop_exceptions.rb +16 -0
  19. data/lib/operawatir/element.rb +6 -6
  20. data/lib/operawatir/exceptions.rb +3 -0
  21. data/lib/operawatir/keys.rb +116 -0
  22. data/lib/operawatir/platform.rb +59 -0
  23. data/lib/operawatir/quickwidgets.rb +3 -0
  24. data/lib/operawatir/quickwidgets/quick_addressfield.rb +23 -0
  25. data/lib/operawatir/quickwidgets/quick_button.rb +151 -0
  26. data/lib/operawatir/quickwidgets/quick_checkbox.rb +58 -0
  27. data/lib/operawatir/quickwidgets/quick_dialogtab.rb +23 -0
  28. data/lib/operawatir/quickwidgets/quick_dropdown.rb +27 -0
  29. data/lib/operawatir/quickwidgets/quick_editfield.rb +115 -0
  30. data/lib/operawatir/quickwidgets/quick_label.rb +12 -0
  31. data/lib/operawatir/quickwidgets/quick_radiobutton.rb +11 -0
  32. data/lib/operawatir/quickwidgets/quick_searchfield.rb +25 -0
  33. data/lib/operawatir/quickwidgets/quick_tab.rb +66 -0
  34. data/lib/operawatir/quickwidgets/quick_thumbnail.rb +26 -0
  35. data/lib/operawatir/quickwidgets/quick_toolbar.rb +11 -0
  36. data/lib/operawatir/quickwidgets/quick_treeitem.rb +157 -0
  37. data/lib/operawatir/quickwidgets/quick_treeview.rb +27 -0
  38. data/lib/operawatir/quickwidgets/quick_widget.rb +369 -0
  39. data/lib/operawatir/quickwidgets/quick_window.rb +150 -0
  40. data/lib/operawatir/selector.rb +1 -1
  41. data/lib/operawatir/version.rb +0 -1
  42. data/lib/operawatir/window.rb +9 -0
  43. data/operawatir.gemspec +382 -0
  44. data/spec/new_watirspec/browser_spec.rb +279 -0
  45. data/spec/new_watirspec/clipboard_spec.rb +79 -0
  46. data/spec/new_watirspec/collection_spec.rb +387 -0
  47. data/spec/new_watirspec/element_spec.rb +456 -0
  48. data/spec/new_watirspec/guards.rb +39 -0
  49. data/spec/new_watirspec/keys_spec.rb +206 -0
  50. data/spec/new_watirspec/server.rb +91 -0
  51. data/spec/new_watirspec/watirspec_helper.rb +62 -0
  52. data/spec/new_watirspec/window_spec.rb +370 -0
  53. data/utils/launchers/launcher-mac +0 -0
  54. metadata +191 -28
  55. data/.gitmodules +0 -3
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../watirspec_helper', __FILE__)
3
+
4
+ # These tests use the clipboard gem. On Linux, this gem requires
5
+ # the xclip package to be installed.
6
+ require 'clipboard'
7
+
8
+
9
+ # Clipboard API
10
+ # ---------------
11
+ describe '#select_all' do
12
+ it 'selects the value of an input field' do
13
+ browser.url = fixture('input_fields_value.html')
14
+ window.find_by_name('one').click!
15
+ browser.select_all
16
+ window.eval_js('window.getSelection()').to_s should == 'foobar'
17
+ end
18
+ end
19
+
20
+ describe '#copy' do
21
+ before :each do
22
+ Clipboard.clear
23
+ browser.url = fixture('input_fields_value.html')
24
+ window.find_by_name('one').click!
25
+ browser.select_all
26
+ end
27
+
28
+ it 'copies a string to the keyboard' do
29
+ browser.copy
30
+ Clipboard.paste.should == 'foobar'
31
+ end
32
+
33
+ it 'leaves the copied string alone' do
34
+ browser.copy
35
+ window.find_by_name('one').value.should == 'foobar'
36
+ end
37
+ end
38
+
39
+ describe '#cut!' do
40
+ before :each do
41
+ Clipboard.clear
42
+ browser.url = fixture('input_fields_value.html')
43
+ window.find_by_name('one').click!
44
+ browser.select_all
45
+ end
46
+
47
+ it 'copies a string to the keyboard' do
48
+ browser.cut!
49
+ Clipboard.paste.should == 'foobar'
50
+ end
51
+
52
+ it 'removes the cut string' do
53
+ browser.cut!
54
+ window.find_by_name('one').value.should == ''
55
+ end
56
+ end
57
+
58
+ describe '#paste' do
59
+ before :each do
60
+ Clipboard.clear
61
+ browser.url = fixture('input_fields_value.html')
62
+ window.find_by_name('one').click!
63
+ browser.select_all
64
+ end
65
+
66
+ it 'pastes a copied string' do
67
+ browser.copy
68
+ window.find_by_name('two').click!
69
+ browser.paste
70
+ window.find_by_name('two').value.should == 'foobar'
71
+ end
72
+
73
+ it 'pastes a cut string' do
74
+ browser.cut
75
+ window.find_by_name('two').click!
76
+ browser.paste
77
+ window.find_by_name('two').value.should == 'foobar'
78
+ end
79
+ end
@@ -0,0 +1,387 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../watirspec_helper', __FILE__)
3
+
4
+ describe 'Collection' do
5
+ before :each do
6
+ browser.url = fixture('non_control_elements.html')
7
+ @collection = window.find_by_tag(:div)
8
+ end
9
+
10
+ # elements
11
+ describe '#find_by_id' do
12
+ it 'returns an element with the given ID' do
13
+ elements = @collection.find_by_id('header')
14
+
15
+ elements.should_not be_empty
16
+ elements.length.should == 1
17
+ elements.first.attr(:id).should == 'header'
18
+ end
19
+
20
+ it 'finds multiple elements with the same id' do
21
+ elements = @collection.find_by_id('lead')
22
+ elements.length.should == 4
23
+ end
24
+ end
25
+
26
+ describe '#find_by_tag' do
27
+ it 'is not empty if the tag exists under the collection' do
28
+ @collection.find_by_tag(:a).should_not be_empty
29
+ end
30
+
31
+ it 'contains all elements of the tag name under the collection' do
32
+ as = @collection.find_by_tag(:a)
33
+ as.length.should == 4
34
+ as.all? do |element|
35
+ element.tag_name.should match /a/i
36
+ end.should be_true
37
+ end
38
+
39
+ it 'contains only elements restricted by the selector' do
40
+ @collection.find_by_tag(:span, :title => 'Lorem ipsum').all? do |element|
41
+ element.attr(:title) == 'Lorem ipsum'
42
+ end.should be_true
43
+ end
44
+
45
+ it 'is empty if the elements do not exist' do
46
+ @collection.find_by_tag(:hoobaflooba).should be_empty
47
+ end
48
+ end
49
+
50
+ # css
51
+ # we don't want a complete CSS selector test suite here, so just some common
52
+ # selectors
53
+ describe '#find_by_css' do
54
+ it 'is not empty if an element matches the css selector' do
55
+ @collection.find_by_css('ul').should_not be_empty
56
+ end
57
+
58
+ it 'contains all elements selected by the selector' do
59
+ collection = window.find_by_id('outer_container')
60
+ divs = collection.find_by_css('div')
61
+ divs.length.should == 7
62
+ divs[1].id.should == 'promo'
63
+ divs[3].id.should == 'best_language'
64
+ divs[6].id.should == 'hidden'
65
+ end
66
+
67
+ it 'is empty if the selector does not match' do
68
+ @collection.find_by_css('#hoobaflooba').should be_empty
69
+ end
70
+ end
71
+
72
+ # class
73
+ describe '#find_by_class' do
74
+ it 'is not empty if an element matches the class' do
75
+ @collection.find_by_class(:lead).should_not be_empty
76
+ end
77
+
78
+ it 'contains all elements with the given class' do
79
+ collection = window.find_by_id('promo')
80
+ leads = @collection.find_by_class(:lead)
81
+ leads.length.should == 4
82
+ leads.all? do |element|
83
+ element.attr(:class).should match /lead/
84
+ end.should be_true
85
+
86
+ end
87
+
88
+ it 'finds elements with multiple classes' do
89
+ collection = window.find_by_id('header')
90
+ collection.find_by_class(:one).all? do |element|
91
+ element.attr(:class).should match /one/
92
+ end.should be_true
93
+ end
94
+
95
+ it 'is empty if the class does not match' do
96
+ @collection.find_by_class(:hoobaflooba).should be_empty
97
+ end
98
+ end
99
+
100
+ # xpath
101
+ describe '#find_by_xpath' do
102
+ before :each do
103
+ @headers = @collection.find_by_xpath('//h1')
104
+ end
105
+
106
+ it 'is not empty if elements matches the class' do
107
+ @headers.should_not be_empty
108
+ end
109
+
110
+ it 'contains all elements with the given query' do
111
+ @headers.all? do |element|
112
+ element.tag_name.should match /h1/i
113
+ end
114
+ end
115
+
116
+ it 'is empty if the query does not match' do
117
+ @collection.find_by_xpath('//hoobaflooba').should be_empty
118
+ end
119
+
120
+ it 'finds elements in the current context' do
121
+ subdivs = @collection.find_by_xpath('div')
122
+ subdivs.length.should == 7
123
+
124
+ # XPath spec says order not guaranteed, so just check they're here
125
+ ids = subdivs.map { |el| el.id }
126
+ ids.should include 'promo'
127
+ ids.should include 'best_language'
128
+ ids.should include 'hidden'
129
+ end
130
+ end
131
+
132
+ # sugar
133
+ describe 'syntactic sugar' do
134
+ it 'returns all descendants with the given tag' do
135
+ window.find_by_id('promo').span.length.should == 5
136
+ end
137
+
138
+ it 'can be chained' do
139
+ lis = window.find_by_id('promo').ul.li
140
+ lis[0].text.should == 'Abietic acid, C20H30O2'
141
+ lis[2].text.should == 'Acenaphthoquinone, C12H6O2'
142
+ lis[4].text.should == 'Acetaldehyde (ethanal), CH3CHO'
143
+ end
144
+
145
+ it 'can be chained deeply' do
146
+ window.body.div.div.ul.li.a.id.should == [nil, 'link_2', 'link_3']
147
+ end
148
+
149
+ it 'returns the same as #find_by_tag' do
150
+ @collection.span(:title => 'Lorem ipsum').should == @collection.find_by_tag(:span, :title => 'Lorem ipsum')
151
+ end
152
+
153
+ # This may be unnecessary...
154
+ it 'responds to html elements' do
155
+ [:a,:abbr,:address,:area,:article,:aside,:audio,:b,:base,:bdo,:blockquote,:body,
156
+ :br,:button,:canvas,:caption,:cite,:code,:col,:colgroup,:command,:datalist,:dd,
157
+ :del,:details,:dfn,:div,:dl,:dt,:em,:embed,:eventsource,:fieldset,:figcaption,
158
+ :figure,:footer,:form,:h1,:h2,:h3,:h4,:h5,:h6,:head,:header,:hgroup,:hr,:i,
159
+ :iframe,:img,:input,:ins,:kbd,:keygen,:label,:legend,:li,:link,:mark,:map,
160
+ :menu,:meta,:meter,:nav,:noscript,:object,:ol,:optgroup,:option,:output,:p,
161
+ :param,:pre,:progress,:q,:ruby,:rp,:rt,:samp,:script,:section,:select,:small,
162
+ :source,:span,:strong,:style,:sub,:summary,:sup,:table,:tbody,:td,:textarea,
163
+ :tfoot,:th,:thead,:time,:title,:tr,:ul,:var,:video,:wbr].all? do |symbol|
164
+ @collection.respond_to? symbol
165
+ end.should be_true
166
+ end
167
+
168
+ end
169
+
170
+ # length
171
+ describe '#length' do
172
+ it 'is the number of items in the collection' do
173
+ @collection.length.should == 12
174
+ end
175
+ end
176
+
177
+ # item access
178
+ describe '#[]' do
179
+ it 'accesses the elements in the collection' do
180
+ @collection[5].attr(:id).should == "best_language"
181
+ @collection[@collection.length-1].attr(:id).should == "del_tag_test"
182
+ end
183
+ end
184
+
185
+ describe '#attr' do
186
+ it 'returns the given attribute of the first element' do
187
+ collection = window.find_by_class('external')
188
+ collection.attr(:id).should == 'link_2'
189
+ end
190
+ end
191
+
192
+ # attrs(what)
193
+ describe 'attrs' do
194
+ it 'returns the attributes of each of the elements in the collection' do
195
+ @collection.attrs(:id)[1].should == 'outer_container'
196
+ @collection.attrs(:id)[2].should == 'header'
197
+ @collection.attrs(:id)[9].should == 'messages'
198
+ end
199
+ end
200
+
201
+ # id
202
+ describe '#id' do
203
+ it 'is the id attribute if there is one element' do
204
+ window.find_by_class("primary").id.should == "first_header"
205
+ end
206
+
207
+ it 'is nil if the single element has no id' do
208
+ window.find_by_class("php").id.should == nil
209
+ end
210
+
211
+ it 'is an array of ids if there is more than one element' do
212
+ window.find_by_class("external").id.should == ["link_2", "link_3"]
213
+ end
214
+ end
215
+
216
+ # class
217
+ # TODO this is the class attribute, so it could have multiple classes, in
218
+ # which case this name doesn't make much sense
219
+ describe '#class_name' do
220
+ it 'is the class attribute if there in one element' do
221
+ window.find_by_id("favorite_compounds").class_name.should == "chemistry"
222
+ end
223
+
224
+ it 'is nil if the single element has no class' do
225
+ window.find_by_id("outer_container").class_name.should == nil
226
+ end
227
+
228
+ it 'is an array of class attributes if there is more than one element' do
229
+ window.find_by_class('external').class_name.should == [
230
+ 'external one two', 'external'
231
+ ]
232
+ end
233
+
234
+ it 'is an array with nil elements when the elements have no class' do
235
+ window.find_by_tag("a").class_name.should == [
236
+ nil, 'external one two', 'external', nil
237
+ ]
238
+ end
239
+ end
240
+
241
+ describe '#tag_name' do
242
+ it 'is the tag name if there is one element' do
243
+ window.find_by_id('header4').tag_name.should == 'H4'
244
+ end
245
+
246
+ it 'is an array if there are more than one elements' do
247
+ window.find_by_class('lead').tag_name.should == ['SPAN', 'P', 'INS', 'DEL']
248
+ end
249
+ end
250
+
251
+ # states
252
+ # ------
253
+
254
+ describe '#click!' do
255
+ it 'clicks all the elements in this collection' do
256
+ collection = window.find_by_class('footer')
257
+ collection.click!
258
+ collection.all? do |element|
259
+ element.text.match(/Javascript/) != nil
260
+ end.should be_true
261
+ end
262
+ end
263
+
264
+ # checked?
265
+ describe '#checked?' do
266
+ before :each do
267
+ browser.url = fixture('forms_with_input_elements.html')
268
+ @boxes = window.find_by_tag(:input, :type => 'checkbox')
269
+ end
270
+
271
+ it 'is true if all of the elements are checked' do
272
+ @boxes.each do |box|
273
+ box.check!
274
+ end
275
+ @boxes.checked?.should be_true
276
+ end
277
+
278
+ it 'is false if one of the elements is not checked' do
279
+ @boxes.checked?.should be_false
280
+ end
281
+ end
282
+
283
+ # check!
284
+ describe '#check!' do
285
+ it 'checks all of the checkboxes' do
286
+ browser.url = fixture('forms_with_input_elements.html')
287
+ @boxes = window.find_by_tag(:input, :type => 'checkbox')
288
+
289
+ @boxes.check!
290
+ @boxes.all? do |box|
291
+ box.checked? == true
292
+ end.should be_true
293
+ end
294
+ end
295
+
296
+ # uncheck!
297
+ describe '#uncheck!' do
298
+ it 'unchecks all of the checkboxes' do
299
+ browser.url = fixture('forms_with_input_elements.html')
300
+ @boxes = window.find_by_tag(:input, :type => 'checkbox')
301
+
302
+ @boxes.uncheck!
303
+ @boxes.all? do |box|
304
+ box.checked? == false
305
+ end.should be_true
306
+ end
307
+ end
308
+
309
+ # toggle_check!
310
+ describe '#toggle_check!' do
311
+ it 'toggles the checked state of all of the checkboxes' do
312
+ browser.url = fixture('forms_with_input_elements.html')
313
+ @boxes = window.find_by_tag(:input, :type => 'checkbox')
314
+
315
+ # Store the initial values
316
+ values = @boxes.map { |el| el.checked? }
317
+
318
+ @boxes.toggle_check!
319
+
320
+ # Check they've all changed
321
+ (0..values.size-1).all do |i|
322
+ @boxes[i].checked? == !values[i]
323
+ end.should be_true
324
+ end
325
+ end
326
+
327
+ # enabled?
328
+ describe '#enabled?' do
329
+ before :each do
330
+ browser.url = fixture('forms_with_input_elements.html')
331
+ end
332
+
333
+ it 'returns true if all collection elements are enabled' do
334
+ window.find_by_id('delete_user').fieldset.first.option.enabled? should be_true
335
+ end
336
+
337
+ it 'returns false if any collection elements are disabled' do
338
+ window.find_by_id('new_user').input.enabled?.should be_false
339
+ end
340
+ end
341
+
342
+ # enable!
343
+ describe '#enable!' do
344
+ it 'enables all elements in the collection' do
345
+ browser.url = fixture('forms_with_input_elements.html')
346
+ window.find_by_id('new_user').input.enable!
347
+ window.find_by_id('new_user_species').first.enabled?.should be_true
348
+ end
349
+ end
350
+
351
+ # disable!
352
+ describe '#disable!' do
353
+ it 'disables all elements in the collection' do
354
+ browser.url = fixture('forms_with_input_elements.html')
355
+ window.find_by_id('new_user').input.disable!
356
+ window.find_by_id('new_user_species').input.any? do |element|
357
+ element.enabled?
358
+ end.should be_false
359
+ end
360
+ end
361
+
362
+ # visible?
363
+ describe '#visible?' do
364
+ it 'is true if all the elements are visible' do
365
+ window.find_by_tag(:ul).visible?.should be_true
366
+ end
367
+
368
+ it 'is false if not all elements are visible' do
369
+ @collection.visible?.should be_false
370
+ end
371
+ end
372
+ # show!
373
+ describe '#show!' do
374
+ it 'shows all the elements' do
375
+ @collection.show!
376
+ window.find_by_id('hidden').visible?.should be_true
377
+ end
378
+ end
379
+
380
+ # hide!
381
+ describe '#hide!' do
382
+ it 'hides all the elements' do
383
+ @collection.hide!
384
+ window.find_by_id('outer_container').visible?.should be_false
385
+ end
386
+ end
387
+ end