druid-ts 1.1.4 → 1.1.5

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +27 -0
  3. data/cucumber.yml +6 -2
  4. data/features/area.feature +33 -0
  5. data/features/audio.feature +66 -0
  6. data/features/canvas.feature +35 -0
  7. data/features/element.feature +9 -0
  8. data/features/html/hover.html +11 -0
  9. data/features/html/planets.gif +0 -0
  10. data/features/html/static_elements.html +43 -0
  11. data/features/html/sun.gif +0 -0
  12. data/features/html/sun.html +7 -0
  13. data/features/list_item.feature +1 -0
  14. data/features/page_level_actions.feature +25 -0
  15. data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
  16. data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
  17. data/features/sample-app/public/movie.mp4 +0 -0
  18. data/features/sample-app/public/movie.ogg +0 -0
  19. data/features/select_list.feature +5 -1
  20. data/features/step_definations/area_steps.rb +23 -0
  21. data/features/step_definations/audio_steps.rb +31 -0
  22. data/features/step_definations/canvas_steps.rb +19 -0
  23. data/features/step_definations/element_steps.rb +23 -2
  24. data/features/step_definations/page_level_actions_steps.rb +35 -0
  25. data/features/step_definations/select_list_steps.rb +4 -0
  26. data/features/step_definations/table_steps.rb +4 -0
  27. data/features/step_definations/video_steps.rb +19 -0
  28. data/features/support/page.rb +38 -2
  29. data/features/support/persistent_browser.rb +2 -1
  30. data/features/support/url_helper.rb +4 -0
  31. data/features/table.feature +8 -0
  32. data/features/video.feature +59 -0
  33. data/lib/druid/accessors.rb +162 -26
  34. data/lib/druid/assist.rb +63 -0
  35. data/lib/druid/element_locators.rb +126 -0
  36. data/lib/druid/elements.rb +29 -24
  37. data/lib/druid/elements/area.rb +29 -0
  38. data/lib/druid/elements/audio.rb +9 -0
  39. data/lib/druid/elements/canvas.rb +22 -0
  40. data/lib/druid/elements/element.rb +15 -1
  41. data/lib/druid/elements/list_item.rb +4 -0
  42. data/lib/druid/elements/media.rb +45 -0
  43. data/lib/druid/elements/select_list.rb +7 -1
  44. data/lib/druid/elements/table_row.rb +1 -0
  45. data/lib/druid/elements/video.rb +17 -0
  46. data/lib/druid/nested_elements.rb +32 -0
  47. data/lib/druid/version.rb +1 -1
  48. data/spec/druid/accessors_spec.rb +77 -0
  49. data/spec/druid/element_locators_spec.rb +89 -0
  50. data/spec/druid/elements/area_spec.rb +33 -0
  51. data/spec/druid/elements/canvas_spec.rb +28 -0
  52. data/spec/druid/elements/list_item_spec.rb +1 -1
  53. data/spec/druid/elements/select_list_spec.rb +6 -0
  54. metadata +42 -1
@@ -0,0 +1,17 @@
1
+ module Druid
2
+ module Elements
3
+ class Video < Media
4
+
5
+ def height
6
+ height = attribute(:height)
7
+ return height.to_i if height
8
+ end
9
+
10
+ def width
11
+ width = attribute(:width)
12
+ return width.to_i if width
13
+ end
14
+ end
15
+ Druid::Elements.type_to_class[:video] = Druid::Elements::Video
16
+ end
17
+ end
@@ -203,5 +203,37 @@ module Druid
203
203
  def label_elements(identifier={:index => 0})
204
204
  labels_for(identifier)
205
205
  end
206
+
207
+ def area_element(identifier={:index => 0})
208
+ area_for(identifier)
209
+ end
210
+
211
+ def area_elements(identifier={:index => 0})
212
+ areas_for(identifier)
213
+ end
214
+
215
+ def canvas_element(identifier={:index => 0})
216
+ canvas_for(identifier)
217
+ end
218
+
219
+ def canvas_elements(identifier={:index => 0})
220
+ canvases_for(identifier)
221
+ end
222
+
223
+ def audio_element(identifier={:index => 0})
224
+ audio_for(identifier)
225
+ end
226
+
227
+ def audio_elements(identifier={:index => 0})
228
+ audios_for(identifier)
229
+ end
230
+
231
+ def video_element(identifier={:index => 0})
232
+ video_for(identifier)
233
+ end
234
+
235
+ def video_elements(identifier={:index => 0})
236
+ videos_for(identifier)
237
+ end
206
238
  end
207
239
  end
data/lib/druid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Druid
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
@@ -31,6 +31,10 @@ class AccessorsTestDruid
31
31
  h6(:heading6, :id => 'main_heading')
32
32
  paragraph(:first_para, :id => 'first')
33
33
  file_field(:upload_me, :id => 'the_file')
34
+ area(:img_area, :id => 'area')
35
+ canvas(:my_canvas, :id => 'canvas_id')
36
+ audio(:acdc, :id => 'audio_id')
37
+ video(:movie, :id => 'video_id')
34
38
  end
35
39
 
36
40
  class BlockDruid
@@ -111,6 +115,18 @@ class BlockDruid
111
115
  file_field :a_file do |element|
112
116
  "file_field"
113
117
  end
118
+ area :img_area do |element|
119
+ "area"
120
+ end
121
+ canvas :my_canvas do |element|
122
+ "canvas"
123
+ end
124
+ audio :acdc do |element|
125
+ "audio"
126
+ end
127
+ video :movie do |element|
128
+ "video"
129
+ end
114
130
  end
115
131
 
116
132
  class TestDruidBackUp
@@ -1018,4 +1034,65 @@ describe Druid::Accessors do
1018
1034
  end
1019
1035
  end
1020
1036
  end
1037
+
1038
+ describe "area accessors" do
1039
+ context "when called on a page object" do
1040
+ it "should generate accessor methods" do
1041
+ expect(druid).to respond_to(:img_area)
1042
+ expect(druid).to respond_to(:img_area_element)
1043
+ end
1044
+
1045
+ it "should call a block on the element method when present" do
1046
+ expect(block_druid.img_area_element).to eql "area"
1047
+ end
1048
+ end
1049
+
1050
+ it "should click on the area" do
1051
+ expect(driver).to receive(:area).and_return(driver)
1052
+ expect(driver).to receive(:click)
1053
+ druid.img_area
1054
+ end
1055
+
1056
+ it "should retrieve the element from the page" do
1057
+ expect(driver).to receive(:area).and_return(driver)
1058
+ element = druid.img_area_element
1059
+ expect(element).to be_instance_of Druid::Elements::Area
1060
+ end
1061
+ end
1062
+
1063
+ describe "canvas accessors" do
1064
+ context "when called on a page object" do
1065
+ it "should generate accessor methods" do
1066
+ expect(druid).to respond_to(:my_canvas_element)
1067
+ end
1068
+
1069
+ it "should call a block on the element method when present" do
1070
+ expect(block_druid.my_canvas_element).to eql "canvas"
1071
+ end
1072
+ end
1073
+ end
1074
+
1075
+ describe "audio accessors" do
1076
+ context "when called on a page object" do
1077
+ it "should generate accessor methods" do
1078
+ expect(druid).to respond_to(:acdc_element)
1079
+ end
1080
+
1081
+ it "should call a block on the element method when present" do
1082
+ expect(block_druid.acdc_element).to eql "audio"
1083
+ end
1084
+ end
1085
+ end
1086
+
1087
+ describe "video accessors" do
1088
+ context "when called on a page object" do
1089
+ it "should generate accessor methods" do
1090
+ expect(druid).to respond_to(:movie_element)
1091
+ end
1092
+
1093
+ it "should call a block on the element method when present" do
1094
+ expect(block_druid.movie_element).to eql "video"
1095
+ end
1096
+ end
1097
+ end
1021
1098
  end
@@ -592,4 +592,93 @@ describe Druid::ElementLocators do
592
592
  expect(driver).to receive(:audio).with(:index => 0).and_return(driver)
593
593
  page.element(:audio)
594
594
  end
595
+
596
+ it "should find an area element" do
597
+ expect(driver).to receive(:area).with(:id => 'blah').and_return(driver)
598
+ element = page.area_element(:id => 'blah')
599
+ expect(element).to be_instance_of Druid::Elements::Area
600
+ end
601
+
602
+ it "should find an area element using a default identifier" do
603
+ expect(driver).to receive(:area).with(:index => 0).and_return(driver)
604
+ page.area_element
605
+ end
606
+
607
+ it "should find all area elements" do
608
+ expect(driver).to receive(:areas).with(:id => 'blah').and_return([driver])
609
+ elements = page.area_elements(:id => 'blah')
610
+ expect(elements[0]).to be_instance_of Druid::Elements::Area
611
+ end
612
+
613
+ it "should find all areas with no identifier" do
614
+ expect(driver).to receive(:areas).with({}).and_return([driver])
615
+ page.area_elements
616
+ end
617
+
618
+ it "should find a canvas element" do
619
+ expect(driver).to receive(:canvas).with(:id => 'blah').and_return(driver)
620
+ element = page.canvas_element(:id => 'blah')
621
+ expect(element).to be_instance_of Druid::Elements::Canvas
622
+ end
623
+
624
+ it "should find a canvas element using a default identifier" do
625
+ expect(driver).to receive(:canvas).with(:index => 0).and_return(driver)
626
+ page.canvas_element
627
+ end
628
+
629
+ it "should find all canvas elements" do
630
+ expect(driver).to receive(:canvases).with(:id => 'blah').and_return([driver])
631
+ elements = page.canvas_elements(:id => 'blah')
632
+ expect(elements[0]).to be_instance_of Druid::Elements::Canvas
633
+ end
634
+
635
+ it "should find all canvas elements with no identifier" do
636
+ expect(driver).to receive(:canvases).with({}).and_return([driver])
637
+ page.canvas_elements
638
+ end
639
+
640
+ it "should find an audio element" do
641
+ expect(driver).to receive(:audio).with(:id => 'blah').and_return(driver)
642
+ element = page.audio_element(:id => 'blah')
643
+ expect(element).to be_instance_of Druid::Elements::Audio
644
+ end
645
+
646
+ it "should find an audio element using a default identifier" do
647
+ expect(driver).to receive(:audio).with(:index => 0).and_return(driver)
648
+ page.audio_element
649
+ end
650
+
651
+ it "should find all audios elements" do
652
+ expect(driver).to receive(:audios).with(:id => 'blah').and_return([driver])
653
+ elements = page.audio_elements(:id => 'blah')
654
+ expect(elements[0]).to be_instance_of Druid::Elements::Audio
655
+ end
656
+
657
+ it "should find all audios elements with no identifier" do
658
+ expect(driver).to receive(:audios).with({}).and_return([driver])
659
+ page.audio_elements
660
+ end
661
+
662
+ it "should find an video element" do
663
+ expect(driver).to receive(:video).with(:id => 'blah').and_return(driver)
664
+ element = page.video_element(:id => 'blah')
665
+ expect(element).to be_instance_of Druid::Elements::Video
666
+ end
667
+
668
+ it "should find an video element using a default identifier" do
669
+ expect(driver).to receive(:video).with(:index => 0).and_return(driver)
670
+ page.video_element
671
+ end
672
+
673
+ it "should find all videos elements" do
674
+ expect(driver).to receive(:videos).with(:id => 'blah').and_return([driver])
675
+ elements = page.video_elements(:id => 'blah')
676
+ expect(elements[0]).to be_instance_of Druid::Elements::Video
677
+ end
678
+
679
+ it "should find all videos elements with no identifier" do
680
+ expect(driver).to receive(:videos).with({}).and_return([driver])
681
+ page.video_elements
682
+ end
683
+
595
684
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'druid/elements'
3
+
4
+ describe Druid::Elements::Area do
5
+ context "when mapping how to find an element" do
6
+ it "should map watir types to same" do
7
+ [:class, :id, :index, :name, :xpath].each do |t|
8
+ identifier = Druid::Elements::Area.identifier_for t => 'value'
9
+ expect(identifier.keys.first).to eql t
10
+ end
11
+ end
12
+ end
13
+
14
+ context "implementation" do
15
+ let(:element) { double('element') }
16
+ let(:area) { Druid::Elements::Area.new(element) }
17
+
18
+ it "should know its coords" do
19
+ expect(element).to receive(:attribute_value).with(:coords).and_return("1,2,3,4")
20
+ expect(area.coords).to eql "1,2,3,4"
21
+ end
22
+
23
+ it "should know its shape" do
24
+ expect(element).to receive(:attribute_value).with(:shape).and_return("circle")
25
+ expect(area.shape).to eql "circle"
26
+ end
27
+
28
+ it "should know its href" do
29
+ expect(element).to receive(:attribute_value).with(:href).and_return("twitter.com")
30
+ expect(area.href).to eql "twitter.com"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'druid/elements'
3
+
4
+ describe Druid::Elements::Canvas do
5
+ context "when mapping how to find an element" do
6
+ it "should map watir types to same" do
7
+ [:class, :id, :index, :name, :xpath].each do |t|
8
+ identifier = Druid::Elements::Canvas.identifier_for t => 'value'
9
+ expect(identifier.keys.first).to eql t
10
+ end
11
+ end
12
+ end
13
+
14
+ context "implementation" do
15
+ let(:element) { double('canvas_element') }
16
+ let(:canvas) { Druid::Elements::Canvas.new(element) }
17
+
18
+ it "should knwo its width" do
19
+ expect(element).to receive(:attribute_value).with(:width).and_return("400")
20
+ expect(canvas.width).to eql 400
21
+ end
22
+
23
+ it "should know its height" do
24
+ expect(element).to receive(:attribute_value).with(:height).and_return("100")
25
+ expect(canvas.height).to eql 100
26
+ end
27
+ end
28
+ end
@@ -4,7 +4,7 @@ require 'druid/elements'
4
4
  describe Druid::Elements::ListItem do
5
5
  describe "when mapping how to find an element" do
6
6
  it "should map watir types to same" do
7
- [:class, :id, :index, :name, :xpath].each do |t|
7
+ [:class, :id, :index, :name, :xpath, :text].each do |t|
8
8
  identifier = Druid::Elements::ListItem.identifier_for t => 'value'
9
9
  expect(identifier.keys.first).to eql t
10
10
  end
@@ -41,6 +41,12 @@ describe Druid::Elements::SelectList do
41
41
  expect(select_list.selected_options).to eql opts
42
42
  end
43
43
 
44
+ it "should be able to get the value for the selected options" do
45
+ allow(element).to receive(:selected_options).and_return(opts)
46
+ allow(element).to receive(:value).and_return(element)
47
+ expect(select_list.selected_values).to eql opts
48
+ end
49
+
44
50
  it "should know if it includes some value" do
45
51
  expect(element).to receive(:include?).with('blah').and_return(true)
46
52
  select_list.include?('blah')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druid-ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sheng
@@ -83,8 +83,11 @@ files:
83
83
  - Rakefile
84
84
  - cucumber.yml
85
85
  - druid.gemspec
86
+ - features/area.feature
86
87
  - features/async.feature
88
+ - features/audio.feature
87
89
  - features/button.feature
90
+ - features/canvas.feature
88
91
  - features/checkbox.feature
89
92
  - features/div.feature
90
93
  - features/element.feature
@@ -99,6 +102,7 @@ files:
99
102
  - features/html/frame_2.html
100
103
  - features/html/frame_3.html
101
104
  - features/html/frames.html
105
+ - features/html/hover.html
102
106
  - features/html/iframes.html
103
107
  - features/html/images/circle.png
104
108
  - features/html/modal.html
@@ -110,8 +114,11 @@ files:
110
114
  - features/html/nested_frame_2.html
111
115
  - features/html/nested_frame_3.html
112
116
  - features/html/nested_frames.html
117
+ - features/html/planets.gif
113
118
  - features/html/static_elements.html
114
119
  - features/html/success.html
120
+ - features/html/sun.gif
121
+ - features/html/sun.html
115
122
  - features/image.feature
116
123
  - features/javascript.feature
117
124
  - features/label.feature
@@ -124,15 +131,22 @@ files:
124
131
  - features/page_level_actions.feature
125
132
  - features/paragraph.feature
126
133
  - features/radio_button.feature
134
+ - features/sample-app/public/04-Death_Becomes_Fur.mp4
135
+ - features/sample-app/public/04-Death_Becomes_Fur.oga
127
136
  - features/sample-app/public/jquery-1.3.2.js
128
137
  - features/sample-app/public/jquery.html
138
+ - features/sample-app/public/movie.mp4
139
+ - features/sample-app/public/movie.ogg
129
140
  - features/sample-app/public/prototype-1.6.0.3.js
130
141
  - features/sample-app/public/prototype.html
131
142
  - features/sample-app/sample_app.rb
132
143
  - features/select_list.feature
133
144
  - features/span.feature
145
+ - features/step_definations/area_steps.rb
134
146
  - features/step_definations/async_steps.rb
147
+ - features/step_definations/audio_steps.rb
135
148
  - features/step_definations/button_steps.rb
149
+ - features/step_definations/canvas_steps.rb
136
150
  - features/step_definations/checkbox_steps.rb
137
151
  - features/step_definations/div_steps.rb
138
152
  - features/step_definations/element_steps.rb
@@ -162,6 +176,7 @@ files:
162
176
  - features/step_definations/text_area_steps.rb
163
177
  - features/step_definations/text_field_steps.rb
164
178
  - features/step_definations/unordered_list_steps.rb
179
+ - features/step_definations/video_steps.rb
165
180
  - features/support/ajax_test_environment.rb
166
181
  - features/support/env.rb
167
182
  - features/support/hooks.rb
@@ -173,13 +188,17 @@ files:
173
188
  - features/text_area.feature
174
189
  - features/text_field.feature
175
190
  - features/unordered_list.feature
191
+ - features/video.feature
176
192
  - lib/druid.rb
177
193
  - lib/druid/accessors.rb
178
194
  - lib/druid/assist.rb
179
195
  - lib/druid/core_ext/string.rb
180
196
  - lib/druid/element_locators.rb
181
197
  - lib/druid/elements.rb
198
+ - lib/druid/elements/area.rb
199
+ - lib/druid/elements/audio.rb
182
200
  - lib/druid/elements/button.rb
201
+ - lib/druid/elements/canvas.rb
183
202
  - lib/druid/elements/check_box.rb
184
203
  - lib/druid/elements/div.rb
185
204
  - lib/druid/elements/element.rb
@@ -191,6 +210,7 @@ files:
191
210
  - lib/druid/elements/label.rb
192
211
  - lib/druid/elements/link.rb
193
212
  - lib/druid/elements/list_item.rb
213
+ - lib/druid/elements/media.rb
194
214
  - lib/druid/elements/option.rb
195
215
  - lib/druid/elements/ordered_list.rb
196
216
  - lib/druid/elements/paragraph.rb
@@ -203,6 +223,7 @@ files:
203
223
  - lib/druid/elements/text_area.rb
204
224
  - lib/druid/elements/text_field.rb
205
225
  - lib/druid/elements/unordered_list.rb
226
+ - lib/druid/elements/video.rb
206
227
  - lib/druid/javascript/jquery.rb
207
228
  - lib/druid/javascript/prototype.rb
208
229
  - lib/druid/javascript/yui.rb
@@ -214,7 +235,9 @@ files:
214
235
  - spec/druid/accessors_spec.rb
215
236
  - spec/druid/druid_spec.rb
216
237
  - spec/druid/element_locators_spec.rb
238
+ - spec/druid/elements/area_spec.rb
217
239
  - spec/druid/elements/button_spec.rb
240
+ - spec/druid/elements/canvas_spec.rb
218
241
  - spec/druid/elements/check_box_spec.rb
219
242
  - spec/druid/elements/div_spec.rb
220
243
  - spec/druid/elements/element_spec.rb
@@ -269,8 +292,11 @@ signing_key:
269
292
  specification_version: 4
270
293
  summary: Druid DSL for browser testing
271
294
  test_files:
295
+ - features/area.feature
272
296
  - features/async.feature
297
+ - features/audio.feature
273
298
  - features/button.feature
299
+ - features/canvas.feature
274
300
  - features/checkbox.feature
275
301
  - features/div.feature
276
302
  - features/element.feature
@@ -285,6 +311,7 @@ test_files:
285
311
  - features/html/frame_2.html
286
312
  - features/html/frame_3.html
287
313
  - features/html/frames.html
314
+ - features/html/hover.html
288
315
  - features/html/iframes.html
289
316
  - features/html/images/circle.png
290
317
  - features/html/modal.html
@@ -296,8 +323,11 @@ test_files:
296
323
  - features/html/nested_frame_2.html
297
324
  - features/html/nested_frame_3.html
298
325
  - features/html/nested_frames.html
326
+ - features/html/planets.gif
299
327
  - features/html/static_elements.html
300
328
  - features/html/success.html
329
+ - features/html/sun.gif
330
+ - features/html/sun.html
301
331
  - features/image.feature
302
332
  - features/javascript.feature
303
333
  - features/label.feature
@@ -310,15 +340,22 @@ test_files:
310
340
  - features/page_level_actions.feature
311
341
  - features/paragraph.feature
312
342
  - features/radio_button.feature
343
+ - features/sample-app/public/04-Death_Becomes_Fur.mp4
344
+ - features/sample-app/public/04-Death_Becomes_Fur.oga
313
345
  - features/sample-app/public/jquery-1.3.2.js
314
346
  - features/sample-app/public/jquery.html
347
+ - features/sample-app/public/movie.mp4
348
+ - features/sample-app/public/movie.ogg
315
349
  - features/sample-app/public/prototype-1.6.0.3.js
316
350
  - features/sample-app/public/prototype.html
317
351
  - features/sample-app/sample_app.rb
318
352
  - features/select_list.feature
319
353
  - features/span.feature
354
+ - features/step_definations/area_steps.rb
320
355
  - features/step_definations/async_steps.rb
356
+ - features/step_definations/audio_steps.rb
321
357
  - features/step_definations/button_steps.rb
358
+ - features/step_definations/canvas_steps.rb
322
359
  - features/step_definations/checkbox_steps.rb
323
360
  - features/step_definations/div_steps.rb
324
361
  - features/step_definations/element_steps.rb
@@ -348,6 +385,7 @@ test_files:
348
385
  - features/step_definations/text_area_steps.rb
349
386
  - features/step_definations/text_field_steps.rb
350
387
  - features/step_definations/unordered_list_steps.rb
388
+ - features/step_definations/video_steps.rb
351
389
  - features/support/ajax_test_environment.rb
352
390
  - features/support/env.rb
353
391
  - features/support/hooks.rb
@@ -359,10 +397,13 @@ test_files:
359
397
  - features/text_area.feature
360
398
  - features/text_field.feature
361
399
  - features/unordered_list.feature
400
+ - features/video.feature
362
401
  - spec/druid/accessors_spec.rb
363
402
  - spec/druid/druid_spec.rb
364
403
  - spec/druid/element_locators_spec.rb
404
+ - spec/druid/elements/area_spec.rb
365
405
  - spec/druid/elements/button_spec.rb
406
+ - spec/druid/elements/canvas_spec.rb
366
407
  - spec/druid/elements/check_box_spec.rb
367
408
  - spec/druid/elements/div_spec.rb
368
409
  - spec/druid/elements/element_spec.rb