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
@@ -105,7 +105,28 @@ When(/^I retrieve the label element$/) do
105
105
  end
106
106
 
107
107
  Then(/^I should be able to flash it$/) do
108
- sleep 5
109
108
  @element.flash
110
- sleep 5
109
+ end
110
+
111
+ class HoverPage
112
+ include Druid
113
+
114
+ link(:hello)
115
+ end
116
+
117
+ Given(/^I am on the hover page$/) do
118
+ @page = HoverPage.new(@driver)
119
+ @page.navigate_to UrlHelper.hover
120
+ end
121
+
122
+ When(/^I hover over the hello link$/) do
123
+ @page.hello_element.hover
124
+ end
125
+
126
+ Then(/^the font size should be "([^"]*)"$/) do |font_size|
127
+ expect(@page.hello_element.style('font-size')).to eql font_size
128
+ end
129
+
130
+ Then(/^I should know its id is "([^"]*)"$/) do |id|
131
+ expect(@element.id).to eql id
111
132
  end
@@ -135,3 +135,38 @@ Then(/^the page should not have the expected element$/) do
135
135
 
136
136
  expect(FakePage.new(@driver)).not_to have_expected_element
137
137
  end
138
+
139
+
140
+ When(/^I handle the alert that reloads the page$/) do
141
+ @msg = @page.alert do
142
+ @page.alert_button_that_reloads
143
+ end
144
+ end
145
+
146
+ When(/^I handle the confirm that reloads the page$/) do
147
+ @msg = @page.confirm(true) do
148
+ @page.confirm_button_that_reloads
149
+ end
150
+ end
151
+
152
+ When(/^I handle the possible alert$/) do
153
+ @msg = @page.alert do
154
+ @page.alert_button_element.focus
155
+ end
156
+ end
157
+
158
+ Then(/^I should be able to verify the popup didn't have a message$/) do
159
+ expect(@msg).to be_nil
160
+ end
161
+
162
+ When(/^I handle the possible confirm$/) do
163
+ @msg = @page.confirm(true) do
164
+ @page.confirm_button_element.focus
165
+ end
166
+ end
167
+
168
+ When(/^I handle the possible prompt$/) do
169
+ @msg = @page.prompt("Tim") do
170
+ @page.prompt_button_element.focus
171
+ end
172
+ end
@@ -81,3 +81,7 @@ end
81
81
  When(/^I select an option using the value "([^"]*)"$/) do |value|
82
82
  @page.select_list_id_element.select_value(value)
83
83
  end
84
+
85
+ Then(/^the selected option should have a value of "([^"]*)"$/) do |value|
86
+ expect(@page.select_list_id_element.selected_values[0]).to eql value
87
+ end
@@ -71,3 +71,7 @@ end
71
71
  Then(/^the data for row "([^"]*)" and column "([^"]*)" should be nil$/) do |row, column|
72
72
  expect(@element[row][column]).to be_nil
73
73
  end
74
+
75
+ When(/^I retrieve a table with thead element$/) do
76
+ @element = @page.table_with_thead_id_element
77
+ end
@@ -0,0 +1,19 @@
1
+ When(/^I retrieve the video element$/) do
2
+ @element = @page.video_id_element
3
+ end
4
+
5
+ When(/^I search for the video element by "([^"]*)"$/) do |how|
6
+ @element = @page.send "video_#{how}_element"
7
+ end
8
+
9
+ When(/^I search for the video element by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
10
+ @element = @page.send "video_#{param1}_#{param2}_element"
11
+ end
12
+
13
+ Then(/^I should know the video is not autoplay$/) do
14
+ expect(@element).not_to be_autoplay
15
+ end
16
+
17
+ Then(/^I should know that the video is paused$/) do
18
+ expect(@element).to be_paused
19
+ end
@@ -106,6 +106,7 @@ class Page
106
106
  table(:table_index, :index => 0)
107
107
  table(:table_xpath, :xpath => '//table')
108
108
  table(:table_name, :name => 'table_name')
109
+ table(:table_with_thead_id, :id => 'table_with_thead_id')
109
110
  table(:table_class_index, :class => "table_class", :index => 0)
110
111
  table(:table_name_index, :name => "table_name", :index => 0)
111
112
 
@@ -140,8 +141,8 @@ class Page
140
141
  image(:image_id, :id => "image_id")
141
142
  image(:image_name, :name => 'image_name')
142
143
  image(:image_class, :class => 'image_class')
143
- image(:image_index, :index => 0)
144
- image(:image_xpath, :xpath => '//img')
144
+ image(:image_index, :index => 1)
145
+ image(:image_xpath, :xpath => '//img[2]')
145
146
  image(:image_alt, :alt => 'image_alt')
146
147
  image(:image_src, :src => 'images/circle.png')
147
148
  image(:image_class_index, :class => "image_class", :index => 0)
@@ -173,6 +174,7 @@ class Page
173
174
  list_item(:li_name, :name => 'li_name')
174
175
  list_item(:li_index, :index => 0)
175
176
  list_item(:li_xpath, :xpath => '//li[1]')
177
+ list_item(:li_text, :text => 'Item One')
176
178
  list_item(:li_class_index, :class => "li_class", :index => 0)
177
179
  list_item(:li_name_index, :name => "li_name", :index => 0)
178
180
 
@@ -206,7 +208,9 @@ class Page
206
208
  unordered_list(:ul_class_name, :class => "ul_class", :name => "ul_name")
207
209
 
208
210
  button(:alert_button, :id => "alert_button")
211
+ button(:alert_button_that_reloads, :id => 'alert_button_that_reloads')
209
212
  button(:confirm_button, :id => "confirm_button")
213
+ button(:confirm_button_that_reloads, :id => 'confirm_button_that_reloads')
210
214
  button(:prompt_button, :id => "prompt_button")
211
215
 
212
216
  link(:open_window, :text => 'New Window')
@@ -278,6 +282,38 @@ class Page
278
282
 
279
283
  link(:child, :id => 'child')
280
284
 
285
+ area(:area_id, :id => 'area')
286
+ area(:area_name, :name => 'area')
287
+ area(:area_class, :class => 'area')
288
+ area(:area_index, :index => 0)
289
+ area(:area_xpath, :xpath => '//area')
290
+ area(:area_class_index, :class => 'area', :index => 0)
291
+ area(:area_name_index, :name => 'area', :index => 0)
292
+
293
+ canvas(:canvas_id, :id => 'canvas')
294
+ canvas(:canvas_name, :name => 'canvas')
295
+ canvas(:canvas_class, :class => 'canvas')
296
+ canvas(:canvas_index, :index => 0)
297
+ canvas(:canvas_xpath, :xpath => '//canvas')
298
+ canvas(:canvas_class_index, :class => 'canvas', :index => 0)
299
+ canvas(:canvas_name_index, :name => 'canvas', :index => 0)
300
+
301
+ audio(:audio_id, :id => 'audio')
302
+ audio(:audio_name, :name => 'audio')
303
+ audio(:audio_class, :class => 'audio')
304
+ audio(:audio_index, :index => 0)
305
+ audio(:audio_xpath, :xpath => '//audio')
306
+ audio(:audio_class_index, :class => 'audio', :index => 0)
307
+ audio(:audio_name_index, :name => 'audio', :index => 0)
308
+
309
+ video(:video_id, :id => 'video')
310
+ video(:video_name, :name => 'video')
311
+ video(:video_class, :class => 'video')
312
+ video(:video_index, :index => 0)
313
+ video(:video_xpath, :xpath => '//video')
314
+ video(:video_class_index, :class => 'video', :index => 0)
315
+ video(:video_name_index, :name => 'video', :index => 0)
316
+
281
317
  element(:article_id, :article, :id => 'article_id')
282
318
  element(:header_id, :header, :id => 'header_id')
283
319
  element(:footer_id, :footer, :id => 'footer_id')
@@ -3,7 +3,8 @@ module Druid
3
3
  @@driver = false
4
4
  def self.get_browser
5
5
  if !@@driver
6
- @@driver = Watir::Browser.new :firefox if ENV['DRIVER'] == 'WATIR'
6
+ target_browser = ENV['BROWSER'].to_sym
7
+ @@driver = Watir::Browser.new target_browser if ENV['DRIVER'] == 'WATIR'
7
8
  end
8
9
  @@driver
9
10
  end
@@ -40,5 +40,9 @@ module UrlHelper
40
40
  "#{files}/multi_elements.html"
41
41
  end
42
42
 
43
+ def hover
44
+ "#{files}/hover.html"
45
+ end
46
+
43
47
  end
44
48
  end
@@ -84,3 +84,11 @@ Feature: Table
84
84
  When I retrieve a table element while the script is executing
85
85
  Then I should see that the table exists
86
86
  And the data for row "1" should be "Data1" and "Data2"
87
+
88
+ Scenario: Retrieve data from a table with a thead using a column header
89
+ When I retrieve a table with thead element
90
+ Then the data for column "Col1" and row "2" should be "Data1"
91
+
92
+ Scenario: Retrieve data from the first row of a table with a thead using a column header
93
+ When I retrieve a table with thead element
94
+ Then the data for column "Col1" and row "1" should be "Col1"
@@ -0,0 +1,59 @@
1
+ #Feature: Support for video element
2
+
3
+ #Background:
4
+ #Given I am on the static elements page
5
+
6
+ #Scenario: Finding an video element
7
+ #When I retrieve the video element
8
+ #Then I should know it exists
9
+ #And I should know it is visible
10
+
11
+ #Scenario Outline: Locating a video element on the page
12
+ #When I search for the video element by "<search_by>"
13
+ #Then I should know it is visible
14
+
15
+ #Examples:
16
+ #| search_by |
17
+ #| id |
18
+ #| class |
19
+ #| name |
20
+ #| xpath |
21
+ #| index |
22
+
23
+ #Scenario Outline: Locating videos using multiple parameters
24
+ #When I search for the video element by "<param1>" and "<param2>"
25
+ #Then I should know it is visible
26
+
27
+ #Examples:
28
+ # | param1 | param2 |
29
+ #| class | index |
30
+ #| name | index |
31
+
32
+ #Scenario Outline: Locating videos using multiple parameters
33
+ #When I search for the video element by "<param1>" and "<param2>"
34
+ #Then I should know it is visible
35
+
36
+ #Examples:
37
+ #| param1 | param2 |
38
+ #| class | index |
39
+ #| name | index |
40
+
41
+ #Scenario: Should know if it is autoplay
42
+ # When I retrieve the video element
43
+ # Then I should know the video is not autoplay
44
+
45
+ #Scenario: Should know if the controls are displayed
46
+ # When I retrieve the video element
47
+ # Then I should know that the controls are displayed
48
+
49
+ #Scenario: Should know if it is paused
50
+ # When I retrieve the video element
51
+ # Then I should know that the video is paused
52
+
53
+ #Scenario: Should know its duration
54
+ # When I retrieve the video element
55
+ # Then I should know that the duration is greater than 12 seconds
56
+
57
+ #Scenario: Should know its volume
58
+ # When I retrieve the video element
59
+ # Then I should know that its volume is 1
@@ -139,12 +139,15 @@ module Druid
139
139
  # block ? call_block(&block) : link_for(identifier.clone)
140
140
  end
141
141
  define_method("#{name}?") do
142
- return call_block(&block) if block_given?
142
+ return call_block(&block).exist? if block_given?
143
143
  link_for(identifier.clone).exist?
144
144
  end
145
145
  alias_method "#{name}_link".to_sym, "#{name}_element".to_sym
146
146
  end
147
147
 
148
+ alias_method :a, :link
149
+
150
+
148
151
  #
149
152
  # adds four methods to the page objec - one to set text in a text field,
150
153
  # another to retrieve text from a text field, another to return the text
@@ -183,7 +186,7 @@ module Druid
183
186
  # block ? call_block(&block) : text_field_for(identifier.clone)
184
187
  end
185
188
  define_method("#{name}?") do
186
- return call_block(&block) if block_given?
189
+ return call_block(&block).exist? if block_given?
187
190
  text_field_for(identifier.clone).exist?
188
191
  end
189
192
  alias_method "#{name}_text_field".to_sym, "#{name}_element".to_sym
@@ -230,7 +233,7 @@ module Druid
230
233
  # block ? call_block(&block) : checkbox_for(identifier.clone)
231
234
  end
232
235
  define_method("#{name}?") do
233
- return call_block(&block) if block_given?
236
+ return call_block(&block).exist? if block_given?
234
237
  checkbox_for(identifier.clone).exist?
235
238
  end
236
239
  alias_method "#{name}_checkbox".to_sym, "#{name}_element".to_sym
@@ -271,11 +274,12 @@ module Druid
271
274
  # block ? call_block(&block) : select_list_for(identifier.clone)
272
275
  end
273
276
  define_method("#{name}?") do
274
- return call_block(&block) if block_given?
277
+ return call_block(&block).exist? if block_given?
275
278
  select_list_for(identifier.clone).exist?
276
279
  end
277
280
  alias_method "#{name}_select_list".to_sym, "#{name}_element".to_sym
278
281
  end
282
+ alias_method :select, :select_list
279
283
 
280
284
  #
281
285
  # adds five methods - one to select, another to clear,
@@ -319,11 +323,12 @@ module Druid
319
323
  # block ? call_block(&block) : radio_button_for(identifier.clone)
320
324
  end
321
325
  define_method("#{name}?") do
322
- return call_block(&block) if block_given?
326
+ return call_block(&block).exist? if block_given?
323
327
  radio_button_for(identifier.clone).exist?
324
328
  end
325
329
  alias_method "#{name}_radio_button".to_sym, "#{name}_element".to_sym
326
330
  end
331
+ alias_method :radio, :radio_button
327
332
 
328
333
  #
329
334
  # adds three methods - one to click a button, another to
@@ -358,7 +363,7 @@ module Druid
358
363
  # block ? call_block(&block) : button_for(identifier.clone)
359
364
  end
360
365
  define_method("#{name}?") do
361
- return call_block(&block) if block_given?
366
+ return call_block(&block).exist? if block_given?
362
367
  button_for(identifier.clone).exist?
363
368
  end
364
369
  alias_method "#{name}_button".to_sym, "#{name}_element".to_sym
@@ -396,7 +401,7 @@ module Druid
396
401
  # block ? call_block(&block) : div_for(identifier.clone)
397
402
  end
398
403
  define_method("#{name}?") do
399
- return call_block(&block) if block_given?
404
+ return call_block(&block).exist? if block_given?
400
405
  div_for(identifier.clone).exist?
401
406
  end
402
407
  alias_method "#{name}_div".to_sym, "#{name}_element".to_sym
@@ -427,7 +432,7 @@ module Druid
427
432
  # block ? call_block(&block) : table_for(identifier.clone)
428
433
  end
429
434
  define_method("#{name}?") do
430
- return call_block(&block) if block_given?
435
+ return call_block(&block).exist? if block_given?
431
436
  table_for(identifier.clone).exist?
432
437
  end
433
438
  alias_method "#{name}_table".to_sym, "#{name}_element".to_sym
@@ -464,11 +469,12 @@ module Druid
464
469
  # block ? call_block(&block) : cell_for(identifier.clone)
465
470
  end
466
471
  define_method("#{name}?") do
467
- return call_block(&block) if block_given?
472
+ return call_block(&block).exist? if block_given?
468
473
  cell_for(identifier.clone).exist?
469
474
  end
470
475
  alias_method "#{name}_cell".to_sym, "#{name}_element".to_sym
471
476
  end
477
+ alias_method :td, :cell
472
478
 
473
479
  #
474
480
  # adds three methods - one to retrieve the text from a span,
@@ -487,6 +493,7 @@ module Druid
487
493
  # * :xpath
488
494
  # * :name
489
495
  # * :text
496
+ # * :title
490
497
  # @param optional block to be invoked when element method is called
491
498
  #
492
499
  def span(name, identifier={:index => 0}, &block)
@@ -500,7 +507,7 @@ module Druid
500
507
  # block ? call_block(&block) : span_for(identifier.clone)
501
508
  end
502
509
  define_method("#{name}?") do
503
- return call_block(&block) if block_given?
510
+ return call_block(&block).exist? if block_given?
504
511
  span_for(identifier.clone).exist?
505
512
  end
506
513
  alias_method "#{name}_span".to_sym, "#{name}_element".to_sym
@@ -533,11 +540,12 @@ module Druid
533
540
  # block ? call_block(&block) : image_for(identifier.clone)
534
541
  end
535
542
  define_method("#{name}?") do
536
- return call_block(&block) if block_given?
543
+ return call_block(&block).exist? if block_given?
537
544
  image_for(identifier.clone).exist?
538
545
  end
539
546
  alias_method "#{name}_image".to_sym, "#{name}_element".to_sym
540
547
  end
548
+ alias_method :img, :image
541
549
 
542
550
  #
543
551
  # adds two methods - one to retrieve the form element, and another to
@@ -565,7 +573,7 @@ module Druid
565
573
  # block ? call_block(&block) : form_for(identifier.clone)
566
574
  end
567
575
  define_method("#{name}?") do
568
- return call_block(&block) if block_given?
576
+ return call_block(&block).exist? if block_given?
569
577
  form_for(identifier.clone).exist?
570
578
  end
571
579
  alias_method "#{name}_form".to_sym, "#{name}_element".to_sym
@@ -603,11 +611,12 @@ module Druid
603
611
  self.send("#{name}_element").value
604
612
  end
605
613
  define_method("#{name}?") do
606
- return call_block(&block) if block_given?
614
+ return call_block(&block).exist? if block_given?
607
615
  hidden_field_for(identifier.clone).exist?
608
616
  end
609
617
  alias_method "#{name}_hidden_field".to_sym, "#{name}_element".to_sym
610
618
  end
619
+ alias_method :hidden, :hidden_field
611
620
 
612
621
  #
613
622
  # adds three methods - one to retrieve the text from a list item,
@@ -626,6 +635,7 @@ module Druid
626
635
  # * :index
627
636
  # * :xpath
628
637
  # * :name
638
+ # * :text
629
639
  # @param optional block to be invoked when element method is called
630
640
  #
631
641
  def list_item(name, identifier={:index => 0}, &block)
@@ -639,11 +649,12 @@ module Druid
639
649
  # block ? call_block(&block) : list_item_for(identifier.clone)
640
650
  end
641
651
  define_method("#{name}?") do
642
- return call_block(&block) if block_given?
652
+ return call_block(&block).exist? if block_given?
643
653
  list_item_for(identifier.clone).exist?
644
654
  end
645
655
  alias_method "#{name}_list_item".to_sym, "#{name}_element".to_sym
646
656
  end
657
+ alias_method :li, :list_item
647
658
 
648
659
  #
649
660
  # adds two methods - one to retrieve the ordered list element, and another to
@@ -670,11 +681,12 @@ module Druid
670
681
  # block ? call_block(&block) : ordered_list_for(identifier.clone)
671
682
  end
672
683
  define_method("#{name}?") do
673
- return call_block(&block) if block_given?
684
+ return call_block(&block).exist? if block_given?
674
685
  ordered_list_for(identifier.clone).exist?
675
686
  end
676
687
  alias_method "#{name}_ordered_list".to_sym, "#{name}_element".to_sym
677
688
  end
689
+ alias_method :ol, :ordered_list
678
690
 
679
691
  #
680
692
  # adds four methods to the page object - one to set text in a text area,
@@ -711,11 +723,12 @@ module Druid
711
723
  # block ? call_block(&block) : text_area_for(identifier.clone)
712
724
  end
713
725
  define_method("#{name}?") do
714
- return call_block(&block) if block_given?
726
+ return call_block(&block).exist? if block_given?
715
727
  text_area_for(identifier.clone).exist?
716
728
  end
717
729
  alias_method "#{name}_text_area".to_sym, "#{name}_element".to_sym
718
730
  end
731
+ alias_method :textarea, :text_area
719
732
 
720
733
  #
721
734
  # adds two methods - one to retrieve the unordered list element, and another to
@@ -741,11 +754,12 @@ module Druid
741
754
  # block ? call_block(&block) : unordered_list_for(identifier.clone)
742
755
  end
743
756
  define_method("#{name}?") do
744
- return call_block(&block) if block_given?
757
+ return call_block(&block).exist? if block_given?
745
758
  unordered_list_for(identifier.clone).exist?
746
759
  end
747
760
  alias_method "#{name}_unordered_list".to_sym, "#{name}_element".to_sym
748
761
  end
762
+ alias_method :ul, :unordered_list
749
763
 
750
764
  #
751
765
  # adds three methods - one to retrieve the text of a h1 element, another to
@@ -775,7 +789,7 @@ module Druid
775
789
  h1_for(identifier.clone)
776
790
  end
777
791
  define_method("#{name}?") do
778
- return call_block(&block) if block_given?
792
+ return call_block(&block).exist? if block_given?
779
793
  h1_for(identifier.clone).exist?
780
794
  end
781
795
  alias_method "#{name}_h1".to_sym, "#{name}_element".to_sym
@@ -809,7 +823,7 @@ module Druid
809
823
  h2_for(identifier.clone)
810
824
  end
811
825
  define_method("#{name}?") do
812
- return call_block(&block) if block_given?
826
+ return call_block(&block).exist? if block_given?
813
827
  h2_for(identifier.clone).exist?
814
828
  end
815
829
  alias_method "#{name}_h2".to_sym, "#{name}_element".to_sym
@@ -843,7 +857,7 @@ module Druid
843
857
  h3_for(identifier.clone)
844
858
  end
845
859
  define_method("#{name}?") do
846
- return call_block(&block) if block_given?
860
+ return call_block(&block).exist? if block_given?
847
861
  h3_for(identifier.clone).exist?
848
862
  end
849
863
  alias_method "#{name}_h3".to_sym, "#{name}_element".to_sym
@@ -877,7 +891,7 @@ module Druid
877
891
  h4_for(identifier.clone)
878
892
  end
879
893
  define_method("#{name}?") do
880
- return call_block(&block) if block_given?
894
+ return call_block(&block).exist? if block_given?
881
895
  h4_for(identifier.clone).exist?
882
896
  end
883
897
  alias_method "#{name}_h4".to_sym, "#{name}_element".to_sym
@@ -911,7 +925,7 @@ module Druid
911
925
  h5_for(identifier.clone)
912
926
  end
913
927
  define_method("#{name}?") do
914
- return call_block(&block) if block_given?
928
+ return call_block(&block).exist? if block_given?
915
929
  h5_for(identifier.clone).exist?
916
930
  end
917
931
  alias_method "#{name}_h5".to_sym, "#{name}_element".to_sym
@@ -945,7 +959,7 @@ module Druid
945
959
  h6_for(identifier.clone)
946
960
  end
947
961
  define_method("#{name}?") do
948
- return call_block(&block) if block_given?
962
+ return call_block(&block).exist? if block_given?
949
963
  h6_for(identifier.clone).exist?
950
964
  end
951
965
  alias_method "#{name}_h6".to_sym, "#{name}_element".to_sym
@@ -979,11 +993,12 @@ module Druid
979
993
  paragraph_for(identifier.clone)
980
994
  end
981
995
  define_method("#{name}?") do
982
- return call_block(&block) if block_given?
996
+ return call_block(&block).exist? if block_given?
983
997
  paragraph_for(identifier.clone).exist?
984
998
  end
985
999
  alias_method "#{name}_paragraph".to_sym, "#{name}_element".to_sym
986
1000
  end
1001
+ alias_method :p, :paragraph
987
1002
 
988
1003
  #
989
1004
  # adds three methods - one to set the file for a file field, another to retrieve
@@ -1014,7 +1029,7 @@ module Druid
1014
1029
  file_field_for(identifier.clone)
1015
1030
  end
1016
1031
  define_method("#{name}?") do
1017
- return call_block(&block) if block_given?
1032
+ return call_block(&block).exist? if block_given?
1018
1033
  file_field_for(identifier.clone).exist?
1019
1034
  end
1020
1035
  end
@@ -1048,12 +1063,133 @@ module Druid
1048
1063
  label_for(identifier.clone)
1049
1064
  end
1050
1065
  define_method("#{name}?") do
1051
- return call_block(&block) if block_given?
1066
+ return call_block(&block).exist? if block_given?
1052
1067
  label_for(identifier.clone).exist?
1053
1068
  end
1054
1069
  alias_method "#{name}_label".to_sym, "#{name}_element".to_sym
1055
1070
  end
1056
1071
 
1072
+ #
1073
+ # adds three methods - one to click the area,
1074
+ # another to return the area element, and another to check the area's existence.
1075
+ #
1076
+ # @example
1077
+ # area(:message, :id => 'message')
1078
+ # # will generate 'message', 'message_element', and 'message?' methods
1079
+ #
1080
+ # @param [Symbol] the name used for the generated methods
1081
+ # @param [Hash] identifier how we find an area. You can use a multiple parameters
1082
+ # by combining of any of the following except xpath. The valid keys are:
1083
+ # * :class
1084
+ # * :id
1085
+ # * :index
1086
+ # * :name
1087
+ # * :xpath
1088
+ # * :text
1089
+ # @param optional block to be invoked when element method is called
1090
+ #
1091
+ def area(name, identifier={:index => 0}, &block)
1092
+ define_method(name) do
1093
+ return click_area_for identifier.clone unless block_given?
1094
+ self.send("#{name}_element").click
1095
+ end
1096
+ define_method("#{name}_element") do
1097
+ return call_block(&block) if block_given?
1098
+ area_for(identifier.clone)
1099
+ end
1100
+ define_method("#{name}?") do
1101
+ return call_block(&block).exist? if block_given?
1102
+ area_for(identifier.clone).exist?
1103
+ end
1104
+ end
1105
+
1106
+ #
1107
+ # adds two method - one to return the canvas element and another to check
1108
+ # the canvas's existence.
1109
+ #
1110
+ # @example
1111
+ # canvas(:my_canvas, :id => 'canvas_id')
1112
+ # # will generate 'my_canvas_element' and 'my_canvas?' methods
1113
+ #
1114
+ # @param [Symbol] the name used for the generated methods
1115
+ # @param [Hash] identifier how we find a canvas. You can use a multiple parameters
1116
+ # by combining of any of the following except xpath. The valid keys are:
1117
+ # * :class
1118
+ # * :id
1119
+ # * :index
1120
+ # * :name
1121
+ # * :xpath
1122
+ # @param optional block to be invoked when element method is called
1123
+ #
1124
+ def canvas(name, identifier={:index => 0}, &block)
1125
+ define_method("#{name}_element") do
1126
+ return call_block(&block) if block_given?
1127
+ canvas_for(identifier.clone)
1128
+ end
1129
+ define_method("#{name}?") do
1130
+ return call_block(&block).exist? if block_given?
1131
+ canvas_for(identifier.clone).exist?
1132
+ end
1133
+ end
1134
+
1135
+ #
1136
+ # adds two methods - one to return the audio element and another to check
1137
+ # the audio's existence
1138
+ #
1139
+ # @example
1140
+ # audio(:acdc, :id => 'audio_id')
1141
+ # # will generate 'acdc_element' and 'acdc?' methods
1142
+ #
1143
+ # @param [Symbol] the name used for the generated methods
1144
+ # @param [Hash] identifier how we find an audio element. You can use a multiple parameters
1145
+ # by combining of any of the following except xpath. The valid keys are:
1146
+ # * :class
1147
+ # * :id
1148
+ # * :index
1149
+ # * :name
1150
+ # * :xpath
1151
+ # @param optional block to be invoked when element method is called
1152
+ #
1153
+ def audio(name, identifier={:index => 0}, &block)
1154
+ define_method("#{name}_element") do
1155
+ return call_block(&block) if block_given?
1156
+ audio_for(identifier.clone)
1157
+ end
1158
+ define_method("#{name}?") do
1159
+ return call_block(&block).exist? if block_given?
1160
+ audio_for(identifier.clone).exist?
1161
+ end
1162
+ end
1163
+
1164
+ #
1165
+ # adds two methods - one to return the video element and another to check
1166
+ # the video's existence
1167
+ #
1168
+ # @example
1169
+ # video(:movie, :id => 'video_id')
1170
+ # # will generate 'movie_element' and 'movie?' methods
1171
+ #
1172
+ # @param [Symbol] the name used for the generated methods
1173
+ # @param [Hash] identifier how we find a video element. You can use a multiple parameters
1174
+ # by combining of any of the following except xpath. The valid keys are:
1175
+ # * :class
1176
+ # * :id
1177
+ # * :index
1178
+ # * :name
1179
+ # * :xpath
1180
+ # @param optional block to be invoked when element method is called
1181
+ #
1182
+ def video(name, identifier={:index => 0}, &block)
1183
+ define_method("#{name}_element") do
1184
+ return call_block(&block) if block_given?
1185
+ video_for(identifier.clone)
1186
+ end
1187
+ define_method("#{name}?") do
1188
+ return call_block(&block).exist? if block_given?
1189
+ video_for(identifier.clone).exist?
1190
+ end
1191
+ end
1192
+
1057
1193
  #
1058
1194
  # adds three methods - one to retrieve the text an element, another
1059
1195
  # to retrieve an element, and another to check the element's existence.