druid-ts 1.1.7 → 1.1.8

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +59 -0
  3. data/Gemfile +1 -0
  4. data/druid.gemspec +1 -0
  5. data/features/area.feature +1 -0
  6. data/features/audio.feature +1 -0
  7. data/features/canvas.feature +1 -0
  8. data/features/checkbox.feature +2 -0
  9. data/features/div.feature +1 -0
  10. data/features/element.feature +15 -0
  11. data/features/file_field.feature +2 -0
  12. data/features/form.feature +1 -0
  13. data/features/generic_elements.feature +5 -0
  14. data/features/heading.feature +6 -0
  15. data/features/hidden_field.feature +1 -0
  16. data/features/html/images/img_pulpit.jpg +0 -0
  17. data/features/html/static_elements.html +19 -1
  18. data/features/image.feature +1 -0
  19. data/features/label.feature +1 -0
  20. data/features/list_item.feature +1 -0
  21. data/features/multi_elements.feature +7 -0
  22. data/features/ordered_list.feature +1 -0
  23. data/features/paragraph.feature +1 -0
  24. data/features/radio_button.feature +2 -0
  25. data/features/select_list.feature +2 -2
  26. data/features/span.feature +2 -1
  27. data/features/step_definations/element_steps.rb +25 -0
  28. data/features/step_definations/generic_element_steps.rb +12 -0
  29. data/features/step_definations/multi_elements_steps.rb +5 -0
  30. data/features/support/page.rb +37 -2
  31. data/features/table.feature +1 -0
  32. data/features/table_cell.feature +1 -0
  33. data/features/text_area.feature +2 -0
  34. data/features/text_field.feature +2 -0
  35. data/features/unordered_list.feature +1 -0
  36. data/features/video.feature +1 -0
  37. data/lib/druid/accessors.rb +117 -84
  38. data/lib/druid/assist.rb +19 -1
  39. data/lib/druid/elements/canvas.rb +1 -1
  40. data/lib/druid/elements/check_box.rb +1 -1
  41. data/lib/druid/elements/element.rb +1 -1
  42. data/lib/druid/elements/file_field.rb +1 -1
  43. data/lib/druid/elements/radio_button.rb +1 -1
  44. data/lib/druid/elements/select_list.rb +1 -1
  45. data/lib/druid/elements/text_area.rb +3 -0
  46. data/lib/druid/locator_generator.rb +112 -58
  47. data/lib/druid/page_factory.rb +17 -83
  48. data/lib/druid/page_populator.rb +2 -1
  49. data/lib/druid/version.rb +1 -1
  50. data/spec/druid/druid_spec.rb +1 -1
  51. data/spec/druid/page_factory_spec.rb +12 -11
  52. data/spec/druid/page_populator_spec.rb +27 -0
  53. metadata +17 -1
@@ -32,6 +32,7 @@ class Page
32
32
  text_field(:text_field_value, :value => "")
33
33
  text_field(:text_field_title, :title => "text_field_title")
34
34
  text_field(:text_field_label, :label => "Text Field")
35
+ text_field(:text_field_data_field, :data_field => 'title')
35
36
  text_field(:text_field_class_index, :class => "text_field_class", :index => 0)
36
37
  text_field(:text_field_name_index, :name => "text_field_name", :index => 0)
37
38
 
@@ -41,6 +42,8 @@ class Page
41
42
  checkbox(:cb_index, :index => 0)
42
43
  checkbox(:cb_value, :value => '1')
43
44
  checkbox(:cb_xpath, :xpath => "//input[@type='checkbox']")
45
+ checkbox(:cb_label, :label => 'Checkbox')
46
+ checkbox(:cb_css, :css => '.cb_class')
44
47
  checkbox(:cb_class_index, :class => "cb_class", :index => 0)
45
48
  checkbox(:cb_name_index, :name => "cb_name", :index => 0)
46
49
 
@@ -52,6 +55,8 @@ class Page
52
55
  select_list(:select_list_text, :text => "Test 1")
53
56
  select_list(:select_list_value, :value => "option1")
54
57
  select_list(:select_list_multiple, :id => "sel_list_multiple")
58
+ select_list(:select_list_label, :label => "Select List")
59
+ select_list(:select_list_css, :css => '.sel_list_class')
55
60
  select_list(:select_list_class_index, :class => "sel_list_class", :index => 0)
56
61
  select_list(:select_list_name_index, :name => "sel_list_name", :index => 0)
57
62
 
@@ -62,6 +67,8 @@ class Page
62
67
  radio_button(:milk_index, :index => 0)
63
68
  radio_button(:milk_value, :value => 'Milk')
64
69
  radio_button(:milk_xpath, :xpath => "//input[@type='radio']")
70
+ radio_button(:milk_label, :label => "Radio")
71
+ radio_button(:milk_css, :css => '.milk_class')
65
72
  radio_button(:milk_class_index, :class => "milk_class", :index => 0)
66
73
  radio_button(:milk_name_index, :name => "milk_name", :index => 0)
67
74
 
@@ -98,6 +105,8 @@ class Page
98
105
  div(:div_xpath, :xpath => '//div')
99
106
  div(:div_text, :text => "page-object rocks!")
100
107
  div(:div_title, :title => "div_title")
108
+ div(:div_css, :css => '.div_class')
109
+ div(:div_data_entity, :data_entity => "test")
101
110
  div(:div_class_index, :class => "div_class", :index => 0)
102
111
  div(:div_name_index, :name => "div_name", :index => 0)
103
112
 
@@ -107,6 +116,7 @@ class Page
107
116
  table(:table_xpath, :xpath => '//table')
108
117
  table(:table_name, :name => 'table_name')
109
118
  table(:table_with_thead_id, :id => 'table_with_thead_id')
119
+ table(:table_css, :css => '.table_class')
110
120
  table(:table_class_index, :class => "table_class", :index => 0)
111
121
  table(:table_name_index, :name => "table_name", :index => 0)
112
122
 
@@ -116,6 +126,7 @@ class Page
116
126
  cell(:cell_xpath, :xpath => '//table//tr[2]//td[2]')
117
127
  cell(:cell_name, :name => 'cell_name')
118
128
  cell(:cell_text, :text => 'Data4')
129
+ cell(:cell_css, :css => '.cell_class')
119
130
  cell(:cell_class_index, :class => "cell_class", :index => 0)
120
131
  cell(:cell_name_index, :name => "cell_name", :index => 0)
121
132
 
@@ -126,6 +137,7 @@ class Page
126
137
  span(:span_name, :name => 'span_name')
127
138
  span(:span_text, :text => 'My alert')
128
139
  span(:span_title, :title => 'span_title')
140
+ span(:span_css, :css => '.span_class')
129
141
  span(:span_class_index, :class => "span_class", :index => 0)
130
142
  span(:span_name_index, :name => "span_name", :index => 0)
131
143
 
@@ -133,8 +145,9 @@ class Page
133
145
  label(:label_name, :name => "label_name")
134
146
  label(:label_class, :class => "label_class")
135
147
  label(:label_text, :text => "page-object is the best!")
136
- label(:label_index, :index => 1)
137
- label(:label_xpath, :xpath => "//label[2]")
148
+ label(:label_index, :index => 5)
149
+ label(:label_xpath, :xpath => "//label[6]")
150
+ label(:label_css, :css => '.label_class')
138
151
  label(:label_class_index, :class => "label_class", :index => 0)
139
152
  label(:label_name_index, :name => "label_name", :index => 0)
140
153
 
@@ -145,6 +158,7 @@ class Page
145
158
  image(:image_xpath, :xpath => '//img[2]')
146
159
  image(:image_alt, :alt => 'image_alt')
147
160
  image(:image_src, :src => 'images/circle.png')
161
+ image(:image_css, :css => '.image_class')
148
162
  image(:image_class_index, :class => "image_class", :index => 0)
149
163
  image(:image_name_index, :name => "image_name", :index => 0)
150
164
 
@@ -154,6 +168,7 @@ class Page
154
168
  form(:form_index, :index => 0)
155
169
  form(:form_xpath, :xpath => '//form')
156
170
  form(:form_action, :action => 'success.html')
171
+ form(:form_css, :css => '.form_class')
157
172
  form(:form_class_index, :class => "form_class", :index => 0)
158
173
  form(:form_name_index, :name => "form_name", :index => 0)
159
174
 
@@ -175,6 +190,7 @@ class Page
175
190
  list_item(:li_index, :index => 0)
176
191
  list_item(:li_xpath, :xpath => '//li[1]')
177
192
  list_item(:li_text, :text => 'Item One')
193
+ list_item(:li_css, :css => '.li_class')
178
194
  list_item(:li_class_index, :class => "li_class", :index => 0)
179
195
  list_item(:li_name_index, :name => "li_name", :index => 0)
180
196
 
@@ -183,6 +199,7 @@ class Page
183
199
  ordered_list(:ol_index, :index => 0)
184
200
  ordered_list(:ol_xpath, :xpath => '//ol')
185
201
  ordered_list(:ol_name, :name => 'ol_name')
202
+ ordered_list(:ol_css, :css => '.ol_class')
186
203
  ordered_list(:ol_class_index, :class => "ol_class", :index => 0)
187
204
  ordered_list(:ol_name_index, :name => "ol_name", :index => 0)
188
205
 
@@ -195,6 +212,7 @@ class Page
195
212
  text_area(:text_area_index, :index => 0)
196
213
  text_area(:text_area_text, :text => "")
197
214
  text_area(:text_area_value, :value => "")
215
+ text_area(:text_area_label, :label => "Text Area")
198
216
  text_area(:text_area_class_index, :class => "text_area_class", :index => 0)
199
217
  text_area(:text_area_name_index, :name => "text_area_name", :index => 0)
200
218
 
@@ -203,6 +221,7 @@ class Page
203
221
  unordered_list(:ul_index, :index => 0)
204
222
  unordered_list(:ul_xpath, :xpath => '//ul')
205
223
  unordered_list(:ul_name, :name => 'ul_name')
224
+ unordered_list(:ul_css, :css => '.ul_class')
206
225
  unordered_list(:ul_class_index, :class => "ul_class", :index => 0)
207
226
  unordered_list(:ul_name_index, :name => "ul_name", :index => 0)
208
227
  unordered_list(:ul_class_name, :class => "ul_class", :name => "ul_name")
@@ -220,6 +239,7 @@ class Page
220
239
  h1(:h1_name, :name => 'h1_name')
221
240
  h1(:h1_index, :index => 0)
222
241
  h1(:h1_xpath, :xpath => '//h1')
242
+ h1(:h1_css, :css => '.h1_class')
223
243
  h1(:h1_class_index, :class => 'h1_class', :index => 0)
224
244
  h1(:h1_name_index, :name => 'h1_name', :index => 0)
225
245
 
@@ -228,6 +248,7 @@ class Page
228
248
  h2(:h2_name, :name => 'h2_name')
229
249
  h2(:h2_index, :index => 0)
230
250
  h2(:h2_xpath, :xpath => '//h2')
251
+ h2(:h2_css, :css => '.h2_class')
231
252
  h2(:h2_class_index, :class => 'h2_class', :index => 0)
232
253
  h2(:h2_name_index, :name => 'h2_name', :index =>0)
233
254
 
@@ -236,6 +257,7 @@ class Page
236
257
  h3(:h3_name, :name => 'h3_name')
237
258
  h3(:h3_index, :index => 0)
238
259
  h3(:h3_xpath, :xpath => '//h3')
260
+ h3(:h3_css, :css => '.h3_class')
239
261
  h3(:h3_class_index, :class => 'h3_class', :index => 0)
240
262
  h3(:h3_name_index, :name => 'h3_name', :index => 0)
241
263
 
@@ -244,6 +266,7 @@ class Page
244
266
  h4(:h4_name, :name => 'h4_name')
245
267
  h4(:h4_index, :index => 0)
246
268
  h4(:h4_xpath, :xpath => '//h4')
269
+ h4(:h4_css, :css => '.h4_class')
247
270
  h4(:h4_class_index, :class => 'h4_class', :index => 0)
248
271
  h4(:h4_name_index, :name => 'h4_name', :index => 0)
249
272
 
@@ -252,6 +275,7 @@ class Page
252
275
  h5(:h5_name, :name => 'h5_name')
253
276
  h5(:h5_index, :index => 0)
254
277
  h5(:h5_xpath, :xpath => '//h5')
278
+ h5(:h5_css, :css => '.h5_class')
255
279
  h5(:h5_class_index, :class => 'h5_class', :index => 0)
256
280
  h5(:h5_name_index, :name => 'h5_name', :index => 0)
257
281
 
@@ -260,6 +284,7 @@ class Page
260
284
  h6(:h6_name, :name => 'h6_name')
261
285
  h6(:h6_index, :index => 0)
262
286
  h6(:h6_xpath, :xpath => '//h6')
287
+ h6(:h6_css, :css => '.h6_class')
263
288
  h6(:h6_class_index, :class => 'h6_class', :index => 0)
264
289
  h6(:h6_name_index, :name => 'h6_name', :index => 0)
265
290
 
@@ -268,6 +293,7 @@ class Page
268
293
  paragraph(:p_name, :name => 'p_name')
269
294
  paragraph(:p_index, :index => 0)
270
295
  paragraph(:p_xpath, :xpath => '//p')
296
+ paragraph(:p_css, :css => '.p_class')
271
297
  paragraph(:p_class_index, :class => 'p_class', :index => 0)
272
298
  paragraph(:p_name_index, :name => 'p_name', :index => 0)
273
299
 
@@ -277,6 +303,8 @@ class Page
277
303
  file_field(:file_field_index, :index => 0)
278
304
  file_field(:file_field_title, :title => 'file_field_title')
279
305
  file_field(:file_field_xpath, :xpath => "//input[@type='file']")
306
+ file_field(:file_field_label, :label => "File Field")
307
+ file_field(:file_field_css, :css => '.file_field_class')
280
308
  file_field(:file_field_class_index, :class => 'file_field_class', :index => 0)
281
309
  file_field(:file_field_name_index, :name => 'file_field_name', :index => 0)
282
310
 
@@ -287,6 +315,7 @@ class Page
287
315
  area(:area_class, :class => 'area')
288
316
  area(:area_index, :index => 0)
289
317
  area(:area_xpath, :xpath => '//area')
318
+ area(:area_css, :css => '.area')
290
319
  area(:area_class_index, :class => 'area', :index => 0)
291
320
  area(:area_name_index, :name => 'area', :index => 0)
292
321
 
@@ -295,6 +324,7 @@ class Page
295
324
  canvas(:canvas_class, :class => 'canvas')
296
325
  canvas(:canvas_index, :index => 0)
297
326
  canvas(:canvas_xpath, :xpath => '//canvas')
327
+ canvas(:canvas_css, :css => '.canvas')
298
328
  canvas(:canvas_class_index, :class => 'canvas', :index => 0)
299
329
  canvas(:canvas_name_index, :name => 'canvas', :index => 0)
300
330
 
@@ -303,6 +333,7 @@ class Page
303
333
  audio(:audio_class, :class => 'audio')
304
334
  audio(:audio_index, :index => 0)
305
335
  audio(:audio_xpath, :xpath => '//audio')
336
+ audio(:audio_css, :css => '.audio')
306
337
  audio(:audio_class_index, :class => 'audio', :index => 0)
307
338
  audio(:audio_name_index, :name => 'audio', :index => 0)
308
339
 
@@ -311,6 +342,7 @@ class Page
311
342
  video(:video_class, :class => 'video')
312
343
  video(:video_index, :index => 0)
313
344
  video(:video_xpath, :xpath => '//video')
345
+ video(:video_css, :css => '.video')
314
346
  video(:video_class_index, :class => 'video', :index => 0)
315
347
  video(:video_name_index, :name => 'video', :index => 0)
316
348
 
@@ -319,4 +351,7 @@ class Page
319
351
  element(:footer_id, :footer, :id => 'footer_id')
320
352
  element(:summary_id, :summary, :id => 'summary_id')
321
353
  element(:details_id, :details, :id => 'details_id')
354
+
355
+ figure(:figure_id, :id => 'figure_id')
356
+ svg(:svg_id, :id => 'the_svg')
322
357
  end
@@ -62,6 +62,7 @@ Feature: Table
62
62
  | xpath |
63
63
  | index |
64
64
  | name |
65
+ | css |
65
66
 
66
67
  Scenario: Retrieve the data from a table
67
68
  When I retrieve a table element
@@ -20,6 +20,7 @@ Feature: Table Cell
20
20
  | index |
21
21
  | name |
22
22
  | text |
23
+ | css |
23
24
 
24
25
  Scenario: Retrieve a cell from a table by id
25
26
  When I retrieve table cell
@@ -18,6 +18,8 @@ Feature: Text Area
18
18
  | name |
19
19
  | xpath |
20
20
  | index |
21
+ | label |
22
+ | css |
21
23
 
22
24
  @multi
23
25
  Scenario Outline: Locating a text area using multiple parameters
@@ -24,6 +24,8 @@ Feature: Text Fields
24
24
  | text |
25
25
  | title |
26
26
  | label |
27
+ | css |
28
+ | data_field|
27
29
 
28
30
  Scenario: Retrieve a text field
29
31
  When I retrieve a text field
@@ -22,6 +22,7 @@ Feature: Unordered list
22
22
  | xpath |
23
23
  | index |
24
24
  | name |
25
+ | css |
25
26
 
26
27
  @multi
27
28
  Scenario Outline: Locating unordered lists using multiple parameters
@@ -19,6 +19,7 @@ Feature: Support for video element
19
19
  | name |
20
20
  | xpath |
21
21
  | index |
22
+ | css |
22
23
 
23
24
  Scenario Outline: Locating videos using multiple parameters
24
25
  When I search for the video element by "<param1>" and "<param2>"
@@ -1,5 +1,6 @@
1
1
  require 'druid/elements'
2
2
  require 'erb'
3
+ require 'druid/locator_generator'
3
4
 
4
5
  module Druid
5
6
  #
@@ -184,6 +185,7 @@ module Druid
184
185
  # * :text
185
186
  # * :title
186
187
  # * :label
188
+ # * :css
187
189
  # @param optional block to be invoked when element method is called
188
190
  #
189
191
  def text_field(name, identifier={:index => 0}, &block)
@@ -218,6 +220,8 @@ module Druid
218
220
  # * :name
219
221
  # * :xpath
220
222
  # * :value
223
+ # * :label
224
+ # * :css
221
225
  # @param optional block to be invoked when element method is called
222
226
  #
223
227
  def checkbox(name, identifier={:index => 0}, &block)
@@ -255,6 +259,8 @@ module Druid
255
259
  # :index
256
260
  # :name
257
261
  # :xpath
262
+ # :label
263
+ # :css
258
264
  # @param optional block to be invoked when element method is called
259
265
  #
260
266
  def select_list(name, identifier={:index => 0}, &block)
@@ -295,6 +301,8 @@ module Druid
295
301
  # * :name
296
302
  # * :xpath
297
303
  # * :value
304
+ # * :label
305
+ # * :css
298
306
  # @param optional block to be invoked when element method is called
299
307
  #
300
308
  def radio_button(name, identifier={:index => 0}, &block)
@@ -363,6 +371,7 @@ module Druid
363
371
  # * :text
364
372
  # * :value
365
373
  # * :title
374
+ # * :css
366
375
  # @param optional block to be invoked when element method is called
367
376
  #
368
377
  def div(name, identifier={:index => 0}, &block)
@@ -390,6 +399,7 @@ module Druid
390
399
  # * :index
391
400
  # * :xpath
392
401
  # * :name
402
+ # * :css
393
403
  # @param optional block to be invoked when element method is called
394
404
  #
395
405
  def table(name, identifier={:index => 0}, &block)
@@ -418,6 +428,7 @@ module Druid
418
428
  # * :xpath
419
429
  # * :name
420
430
  # * :text
431
+ # * :css
421
432
  # @param optional block to be invoked when element method is called
422
433
  #
423
434
  def cell(name, identifier={:index => 0}, &block)
@@ -447,6 +458,7 @@ module Druid
447
458
  # * :name
448
459
  # * :text
449
460
  # * :title
461
+ # * :css
450
462
  # @param optional block to be invoked when element method is called
451
463
  #
452
464
  def span(name, identifier={:index => 0}, &block)
@@ -475,6 +487,7 @@ module Druid
475
487
  # * :xpath
476
488
  # * :alt
477
489
  # * :src
490
+ # * :css
478
491
  # @param optional block to be invoked when element method is called
479
492
  #
480
493
  def image(name, identifier={:index => 0}, &block)
@@ -499,6 +512,7 @@ module Druid
499
512
  # * :xpath
500
513
  # * :name
501
514
  # * :action
515
+ # * :css
502
516
  # @param optional block to be invoked when element method is called
503
517
  #
504
518
  def form(name, identifier={:index => 0}, &block)
@@ -524,6 +538,7 @@ module Druid
524
538
  # * :text
525
539
  # * :xpath
526
540
  # * :value
541
+ # * :css
527
542
  # @param optional block to be invoked when element method is called
528
543
  #
529
544
  def hidden_field(name, identifier={:index => 0}, &block)
@@ -553,6 +568,7 @@ module Druid
553
568
  # * :xpath
554
569
  # * :name
555
570
  # * :text
571
+ # * :css
556
572
  # @param optional block to be invoked when element method is called
557
573
  #
558
574
  def list_item(name, identifier={:index => 0}, &block)
@@ -581,6 +597,7 @@ module Druid
581
597
  # * :index
582
598
  # * :xpath
583
599
  # * :name
600
+ # * :css
584
601
  # @param optional block to be invoked when element method is called
585
602
  #
586
603
  def ordered_list(name, identifier={:index => 0}, &block)
@@ -610,6 +627,8 @@ module Druid
610
627
  # * :index
611
628
  # * :name
612
629
  # * :xpath
630
+ # * :label
631
+ # * :css
613
632
  # @param optional block to be invoked when element method is called
614
633
  #
615
634
  def text_area(name, identifier={:index => 0}, &block)
@@ -641,6 +660,7 @@ module Druid
641
660
  # * :index
642
661
  # * :xpath
643
662
  # * :name
663
+ # * :css
644
664
  # @param optional block to be invoked when element method is called
645
665
  def unordered_list(name, identifier={:index => 0}, &block)
646
666
  define_method(name) do
@@ -667,6 +687,7 @@ module Druid
667
687
  # * :index
668
688
  # * :name
669
689
  # * :xpath
690
+ # * :css
670
691
  # @param optional block to be invoked when element method is called
671
692
  #
672
693
  def h1(name, identifier={:index => 0}, &block)
@@ -693,6 +714,7 @@ module Druid
693
714
  # * :index
694
715
  # * :name
695
716
  # * :xpath
717
+ # * :css
696
718
  # @param optional block to be invoked when element method is called
697
719
  #
698
720
  def h2(name, identifier={:index => 0}, &block)
@@ -719,6 +741,7 @@ module Druid
719
741
  # * :index
720
742
  # * :name
721
743
  # * :xpath
744
+ # * :css
722
745
  # @param optional block to be invoked when element method is called
723
746
  #
724
747
  def h3(name, identifier={:index => 0}, &block)
@@ -745,6 +768,7 @@ module Druid
745
768
  # * :index
746
769
  # * :name
747
770
  # * :xpath
771
+ # * :css
748
772
  # @param optional block to be invoked when element method is called
749
773
  #
750
774
  def h4(name, identifier={:index => 0}, &block)
@@ -771,6 +795,7 @@ module Druid
771
795
  # * :index
772
796
  # * :name
773
797
  # * :xpath
798
+ # * :css
774
799
  # @param optional block to be invoked when element method is called
775
800
  #
776
801
  def h5(name, identifier={:index => 0}, &block)
@@ -797,6 +822,7 @@ module Druid
797
822
  # * :index
798
823
  # * :name
799
824
  # * :xpath
825
+ # * :css
800
826
  # @param optional block to be invoked when element method is called
801
827
  #
802
828
  def h6(name, identifier={:index => 0}, &block)
@@ -823,6 +849,7 @@ module Druid
823
849
  # * :index
824
850
  # * :name
825
851
  # * :xpath
852
+ # * :css
826
853
  # @param optional block to be invoked when element method is called
827
854
  #
828
855
  def paragraph(name, identifier={:index => 0}, &block)
@@ -851,6 +878,8 @@ module Druid
851
878
  # * :name
852
879
  # * :title
853
880
  # * :xpath
881
+ # * :label
882
+ # * :css
854
883
  # @param optional block to be invoked when element method is called
855
884
  #
856
885
  def file_field(name, identifier={:index => 0}, &block)
@@ -878,6 +907,7 @@ module Druid
878
907
  # * :name
879
908
  # * :text
880
909
  # * :xpath
910
+ # * :css
881
911
  # @param optional block to be invoked when element method is called
882
912
  #
883
913
  def label(name, identifier={:index => 0}, &block)
@@ -905,6 +935,7 @@ module Druid
905
935
  # * :name
906
936
  # * :xpath
907
937
  # * :text
938
+ # * :css
908
939
  # @param optional block to be invoked when element method is called
909
940
  #
910
941
  def area(name, identifier={:index => 0}, &block)
@@ -931,6 +962,7 @@ module Druid
931
962
  # * :index
932
963
  # * :name
933
964
  # * :xpath
965
+ # * :css
934
966
  # @param optional block to be invoked when element method is called
935
967
  #
936
968
  def canvas(name, identifier={:index => 0}, &block)
@@ -953,6 +985,7 @@ module Druid
953
985
  # * :index
954
986
  # * :name
955
987
  # * :xpath
988
+ # * :css
956
989
  # @param optional block to be invoked when element method is called
957
990
  #
958
991
  def audio(name, identifier={:index => 0}, &block)
@@ -975,6 +1008,7 @@ module Druid
975
1008
  # * :index
976
1009
  # * :name
977
1010
  # * :xpath
1011
+ # * css
978
1012
  # @param optional block to be invoked when element method is called
979
1013
  #
980
1014
  def video(name, identifier={:index => 0}, &block)
@@ -994,6 +1028,7 @@ module Druid
994
1028
  # by combining of any of the following except xpath. The valid keys are:
995
1029
  # * :class
996
1030
  # * :id
1031
+ # * :css
997
1032
  # * :index
998
1033
  # * :name
999
1034
  # * :xpath
@@ -1013,61 +1048,81 @@ module Druid
1013
1048
  end
1014
1049
 
1015
1050
  #
1016
- # methods to generate accessors for types that follow the same
1017
- # pattern as element
1018
- #
1019
- # @example
1020
- # address(:home_address, :id => "home_address")
1021
- # will generate 'home_address', 'home_address_element' and 'home_address?'
1022
- #
1023
- # @param [Symbol] the name used for the generated methods
1024
- # @param [Symbol] the name of the tag for the element
1025
- # @param [Hash] identifier how we find an element. You can use a multiple paramaters
1026
- # by combining of any of the following except xpath. The valid keys are:
1027
- # * :class
1028
- # * :css
1029
- # * :id
1030
- # * :index
1031
- # * :name
1032
- # * :xpath
1033
- # @param optional block to be invoked when element method is called
1034
- #
1035
- [:abbr,
1036
- :address,
1037
- :article,
1038
- :aside,
1039
- :bdi,
1040
- :bdo,
1041
- :cite,
1042
- :code,
1043
- :dd,
1044
- :dfn,
1045
- :dt,
1046
- :em,
1047
- :figcaption,
1048
- :figure,
1049
- :footer,
1050
- :header,
1051
- :hgroup,
1052
- :kbd,
1053
- :mark,
1054
- :nav,
1055
- :noscript,
1056
- :rp,
1057
- :rt,
1058
- :ruby,
1059
- :samp,
1060
- :section,
1061
- :sub,
1062
- :summary,
1063
- :sup,
1064
- :var,
1065
- :wbr].each do |type|
1066
- define_method(type) do |name, *identifier, &block|
1067
- identifier = identifier[0] ? identifier[0] : {:index => 0}
1068
- element(name, type, identifier, &block)
1069
- end
1070
- end
1051
+ # adds a method to return a collection of generic Element objects
1052
+ # for a specific tag
1053
+ #
1054
+ # @example
1055
+ # elements(:title, :header, :id => 'title')
1056
+ # # will generate 'title_elements'
1057
+ #
1058
+ # @param [Symbol] the name used for the generated methods
1059
+ # @param [Symbol] the name of the tag for the element
1060
+ # @param [Hash] identifier how we find an element. You can use a multiple parameters
1061
+ # by combining of any of the following except xpath. The valid keys are:
1062
+ # * :class
1063
+ # * :id
1064
+ # * :index
1065
+ # * :css
1066
+ # * :name
1067
+ # * :xpath
1068
+ # @param optional block to be invoked when element method is called
1069
+ #
1070
+ def elements(name, tag, identifier={:index => 0}, &block)
1071
+ define_method("#{name}_elements") do
1072
+ return call_block(&block) if block_given?
1073
+ elements_for(tag, identifier.clone)
1074
+ end
1075
+ end
1076
+
1077
+ #
1078
+ # adds two methods - one to retrieve a svg, and another to check
1079
+ # svg's existence.
1080
+ #
1081
+ # @example
1082
+ # svg(:circle, :id => 'circle')
1083
+ # # will generate 'circle_element', and 'circle?' methods
1084
+ #
1085
+ # @param [Symbol] the name used for the generated methods
1086
+ # @param [Hash] identifier how we find a svg. You can use a multiple parameters
1087
+ # by combining of any of the following except xpath. The valid keys are:
1088
+ # * :class
1089
+ # * :css
1090
+ # * :id
1091
+ # * :index
1092
+ # * :name
1093
+ # * :xpath
1094
+ # @param optional block to be invoked when element method is called
1095
+ #
1096
+ def svg(name, identifier={:index => 0}, &block)
1097
+ standard_methods(name, identifier, 'svg_for', &block)
1098
+ end
1099
+
1100
+ #
1101
+ # methods to generate accessors for types that follow the same
1102
+ # pattern as element
1103
+ #
1104
+ # @example
1105
+ # address(:my_article, :id => "article_id")
1106
+ # will generate 'my_article', 'my_article_element' and 'my_article?'
1107
+ #
1108
+ # @param [Symbol] the name used for the generated methods
1109
+ # @param [Symbol] the name of the tag for the element
1110
+ # @param [Hash] identifier how we find an element. You can use a multiple paramaters
1111
+ # by combining of any of the following except xpath. The valid keys are:
1112
+ # * :class
1113
+ # * :css
1114
+ # * :id
1115
+ # * :index
1116
+ # * :name
1117
+ # * :xpath
1118
+ # @param optional block to be invoked when element method is called
1119
+ #
1120
+ LocatorGenerator::BASIC_ELEMENTS.each do |type|
1121
+ define_method(type) do |name, *identifier, &block|
1122
+ identifier = identifier[0] ? identifier[0] : {:index => 0}
1123
+ element(name, type, identifier, &block)
1124
+ end
1125
+ end
1071
1126
 
1072
1127
  def standard_methods(name, identifier, method, &block)
1073
1128
  define_method("#{name}_element") do
@@ -1095,37 +1150,15 @@ module Druid
1095
1150
  # keys are the same ones supported by the standard methods.
1096
1151
  # @param optional block to be invoked when element method is called
1097
1152
  #
1098
- [:text_fields,
1099
- :hidden_fields,
1100
- :text_areas,
1101
- :select_lists,
1102
- :links,
1103
- :checkboxes,
1104
- :radio_buttons,
1105
- :buttons,
1106
- :divs,
1107
- :spans,
1108
- :tables,
1109
- :cells,
1110
- :images,
1111
- :forms,
1112
- :list_items,
1113
- :unordered_lists,
1114
- :ordered_lists,
1115
- :h1s,
1116
- :h2s,
1117
- :h3s,
1118
- :h4s,
1119
- :h5s,
1120
- :h6s,
1121
- :paragraphs,
1122
- :labels,
1123
- :file_fields].each do |method_name|
1124
- define_method(method_name) do |name, *identifier, &block|
1153
+ idx = LocatorGenerator::ADVANCED_ELEMENTS.find_index { |type| type == :checkbox}
1154
+ elements = LocatorGenerator::ADVANCED_ELEMENTS.clone
1155
+ elements[idx] = :checkboxe
1156
+ elements.each do |method_name|
1157
+ define_method("#{method_name}s") do |name, *identifier, &block|
1125
1158
  define_method("#{name}_elements") do
1126
1159
  return call_block(&block) unless block.nil?
1127
- platform_method = (method_name == :checkboxes) ? 'checkboxs_for' : "#{method_name.to_s}_for"
1128
- self.send platform_method, identifier.first.clone
1160
+ platform_method = (method_name == :checkboxe) ? 'checkboxs_for' : "#{method_name.to_s}s_for"
1161
+ self.send platform_method, (identifier.first ? identifier.first.clone : {})
1129
1162
  end
1130
1163
  end
1131
1164
  end