page-object 0.6.4 → 0.6.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.
- data/ChangeLog +10 -0
- data/features/hidden_field.feature +0 -2
- data/features/html/multi_elements.html +4 -0
- data/features/multi_elements.feature +139 -24
- data/features/step_definitions/multi_elements_steps.rb +108 -0
- data/features/text_area.feature +1 -3
- data/features/text_field.feature +0 -2
- data/lib/page-object/accessors.rb +53 -58
- data/lib/page-object/element_locators.rb +187 -104
- data/lib/page-object/elements/element.rb +7 -7
- data/lib/page-object/elements/hidden_field.rb +2 -10
- data/lib/page-object/elements/text_area.rb +0 -16
- data/lib/page-object/elements/text_field.rb +2 -10
- data/lib/page-object/platforms/selenium_webdriver/null_selenium_element.rb +28 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +8 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +10 -1
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +1 -1
- data/spec/page-object/accessors_spec.rb +180 -0
- data/spec/page-object/element_locators_spec.rb +281 -2
- data/spec/page-object/elements/hidden_field_spec.rb +2 -12
- data/spec/page-object/elements/text_area_spec.rb +2 -12
- data/spec/page-object/elements/text_field_spec.rb +2 -12
- metadata +16 -15
data/features/text_area.feature
CHANGED
@@ -18,8 +18,6 @@ Feature: Text Area
|
|
18
18
|
| class |
|
19
19
|
| name |
|
20
20
|
| xpath |
|
21
|
-
| css |
|
22
|
-
| tag_name |
|
23
21
|
| index |
|
24
22
|
|
25
23
|
|
@@ -41,4 +39,4 @@ Feature: Text Area
|
|
41
39
|
When I type "abcdefghijklmnop" into the text area
|
42
40
|
Then the text area should contain "abcdefghijklmnop"
|
43
41
|
When I clear the text area
|
44
|
-
Then the text area should contain ""
|
42
|
+
Then the text area should contain ""
|
data/features/text_field.feature
CHANGED
@@ -97,18 +97,16 @@ module PageObject
|
|
97
97
|
# @param [Hash] identifier how we find a text field. You can use a multiple paramaters
|
98
98
|
# by combining of any of the following except xpath. The valid keys are:
|
99
99
|
# * :class => Watir and Selenium
|
100
|
-
# * :css => Watir and Selenium
|
101
100
|
# * :id => Watir and Selenium
|
102
101
|
# * :index => Watir and Selenium
|
103
102
|
# * :name => Watir and Selenium
|
104
|
-
# * :tag_name => Watir and Selenium
|
105
103
|
# * :text => Watir only
|
106
104
|
# * :title => Watir and Selenium
|
107
105
|
# * :value => Watir only
|
108
106
|
# * :xpath => Watir and Selenium
|
109
107
|
# @param optional block to be invoked when element method is called
|
110
108
|
#
|
111
|
-
def text_field(name, identifier=
|
109
|
+
def text_field(name, identifier={:index => 0}, &block)
|
112
110
|
define_method(name) do
|
113
111
|
return platform.text_field_value_for identifier.clone unless block_given?
|
114
112
|
self.send("#{name}_element").value
|
@@ -141,17 +139,15 @@ module PageObject
|
|
141
139
|
# @param [Hash] identifier how we find a hidden field. You can use a multiple paramaters
|
142
140
|
# by combining of any of the following except xpath. The valid keys are:
|
143
141
|
# * :class => Watir and Selenium
|
144
|
-
# * :css => Watir and Selenium
|
145
142
|
# * :id => Watir and Selenium
|
146
143
|
# * :index => Watir and Selenium
|
147
144
|
# * :name => Watir and Selenium
|
148
|
-
# * :tag_name => Watir and Selenium
|
149
145
|
# * :text => Watir and Selenium
|
150
146
|
# * :value => Watir and Selenium
|
151
147
|
# * :xpath => Watir and Selenium
|
152
148
|
# @param optional block to be invoked when element method is called
|
153
149
|
#
|
154
|
-
def hidden_field(name, identifier=
|
150
|
+
def hidden_field(name, identifier={:index => 0}, &block)
|
155
151
|
define_method(name) do
|
156
152
|
return platform.hidden_field_value_for identifier.clone unless block_given?
|
157
153
|
self.send("#{name}_element").value
|
@@ -181,15 +177,13 @@ module PageObject
|
|
181
177
|
# @param [Hash] identifier how we find a text area. You can use a multiple paramaters
|
182
178
|
# by combining of any of the following except xpath. The valid keys are:
|
183
179
|
# * :class => Watir and Selenium
|
184
|
-
# * :css => Watir and Selenium
|
185
180
|
# * :id => Watir and Selenium
|
186
181
|
# * :index => Watir and Selenium
|
187
182
|
# * :name => Watir and Selenium
|
188
|
-
# * :tag_name => Watir and Selenium
|
189
183
|
# * :xpath => Watir and Selenium
|
190
184
|
# @param optional block to be invoked when element method is called
|
191
185
|
#
|
192
|
-
def text_area(name, identifier=
|
186
|
+
def text_area(name, identifier={:index => 0}, &block)
|
193
187
|
define_method(name) do
|
194
188
|
return platform.text_area_value_for identifier.clone unless block_given?
|
195
189
|
self.send("#{name}_element").value
|
@@ -219,7 +213,7 @@ module PageObject
|
|
219
213
|
# select_list(:state, :id => "state")
|
220
214
|
# # will generate 'state', 'state=', 'state_element', 'state?' methods
|
221
215
|
#
|
222
|
-
# @param [
|
216
|
+
# @param [Symbol] the name used for the generated methods
|
223
217
|
# @param [Hash] identifier how we find a select list. You can use a multiple paramaters
|
224
218
|
# by combining of any of the following except xpath. The valid keys are:
|
225
219
|
# * :class => Watir and Selenium
|
@@ -231,7 +225,7 @@ module PageObject
|
|
231
225
|
# * :xpath => Watir and Selenium
|
232
226
|
# @param optional block to be invoked when element method is called
|
233
227
|
#
|
234
|
-
def select_list(name, identifier=
|
228
|
+
def select_list(name, identifier={:index => 0}, &block)
|
235
229
|
define_method(name) do
|
236
230
|
return platform.select_list_value_for identifier.clone unless block_given?
|
237
231
|
self.send("#{name}_element").value
|
@@ -260,7 +254,7 @@ module PageObject
|
|
260
254
|
# link(:add_to_cart, :text => "Add to Cart")
|
261
255
|
# # will generate 'add_to_cart', 'add_to_cart_element', and 'add_to_cart?' methods
|
262
256
|
#
|
263
|
-
# @param [
|
257
|
+
# @param [Symbol] the name used for the generated methods
|
264
258
|
# @param [Hash] identifier how we find a link. You can use a multiple paramaters
|
265
259
|
# by combining of any of the following except xpath. The valid keys are:
|
266
260
|
# * :class => Watir and Selenium
|
@@ -275,7 +269,7 @@ module PageObject
|
|
275
269
|
# * :xpath => Watir and Selenium
|
276
270
|
# @param optional block to be invoked when element method is called
|
277
271
|
#
|
278
|
-
def link(name, identifier=
|
272
|
+
def link(name, identifier={:index => 0}, &block)
|
279
273
|
define_method(name) do
|
280
274
|
return platform.click_link_for identifier.clone unless block_given?
|
281
275
|
self.send("#{name}_element").click
|
@@ -302,7 +296,7 @@ module PageObject
|
|
302
296
|
# # will generate 'check_active', 'uncheck_active', 'active_checked?',
|
303
297
|
# # 'active_element', and 'active?' methods
|
304
298
|
#
|
305
|
-
# @param [
|
299
|
+
# @param [Symbol] the name used for the generated methods
|
306
300
|
# @param [Hash] identifier how we find a checkbox. You can use a multiple paramaters
|
307
301
|
# by combining of any of the following except xpath. The valid keys are:
|
308
302
|
# * :class => Watir and Selenium
|
@@ -313,7 +307,7 @@ module PageObject
|
|
313
307
|
# * :xpath => Watir and Selenium
|
314
308
|
# @param optional block to be invoked when element method is called
|
315
309
|
#
|
316
|
-
def checkbox(name, identifier=
|
310
|
+
def checkbox(name, identifier={:index => 0}, &block)
|
317
311
|
define_method("check_#{name}") do
|
318
312
|
return platform.check_checkbox(identifier.clone) unless block_given?
|
319
313
|
self.send("#{name}_element").check
|
@@ -349,7 +343,7 @@ module PageObject
|
|
349
343
|
# # will generate 'select_north', 'clear_north', 'north_selected?',
|
350
344
|
# # 'north_element', and 'north?' methods
|
351
345
|
#
|
352
|
-
# @param [
|
346
|
+
# @param [Symbol] the name used for the generated methods
|
353
347
|
# @param [Hash] identifier how we find a radio button. You can use a multiple paramaters
|
354
348
|
# by combining of any of the following except xpath. The valid keys are:
|
355
349
|
# * :class => Watir and Selenium
|
@@ -360,7 +354,7 @@ module PageObject
|
|
360
354
|
# * :xpath => Watir and Selenium
|
361
355
|
# @param optional block to be invoked when element method is called
|
362
356
|
#
|
363
|
-
def radio_button(name, identifier=
|
357
|
+
def radio_button(name, identifier={:index => 0}, &block)
|
364
358
|
define_method("select_#{name}") do
|
365
359
|
return platform.select_radio(identifier.clone) unless block_given?
|
366
360
|
self.send("#{name}_element").select
|
@@ -392,7 +386,7 @@ module PageObject
|
|
392
386
|
# button(:purchase, :id => 'purchase')
|
393
387
|
# # will generate 'purchase', 'purchase_element', and 'purchase?' methods
|
394
388
|
#
|
395
|
-
# @param [
|
389
|
+
# @param [Symbol] the name used for the generated methods
|
396
390
|
# @param [Hash] identifier how we find a button. You can use a multiple paramaters
|
397
391
|
# by combining of any of the following except xpath. The valid keys are:
|
398
392
|
# * :class => Watir and Selenium
|
@@ -407,7 +401,7 @@ module PageObject
|
|
407
401
|
# * :alt => Watir and Selenium (input type=image only)
|
408
402
|
# @param optional block to be invoked when element method is called
|
409
403
|
#
|
410
|
-
def button(name, identifier=
|
404
|
+
def button(name, identifier={:index => 0}, &block)
|
411
405
|
define_method(name) do
|
412
406
|
return platform.click_button_for identifier.clone unless block_given?
|
413
407
|
self.send("#{name}_element").click
|
@@ -431,7 +425,7 @@ module PageObject
|
|
431
425
|
# div(:message, :id => 'message')
|
432
426
|
# # will generate 'message', 'message_element', and 'message?' methods
|
433
427
|
#
|
434
|
-
# @param [
|
428
|
+
# @param [Symbol] the name used for the generated methods
|
435
429
|
# @param [Hash] identifier how we find a div. You can use a multiple paramaters
|
436
430
|
# by combining of any of the following except xpath. The valid keys are:
|
437
431
|
# * :class => Watir and Selenium
|
@@ -442,7 +436,7 @@ module PageObject
|
|
442
436
|
# * :xpath => Watir and Selenium
|
443
437
|
# @param optional block to be invoked when element method is called
|
444
438
|
#
|
445
|
-
def div(name, identifier=
|
439
|
+
def div(name, identifier={:index => 0}, &block)
|
446
440
|
define_method(name) do
|
447
441
|
return platform.div_text_for identifier.clone unless block_given?
|
448
442
|
self.send("#{name}_element").text
|
@@ -466,7 +460,7 @@ module PageObject
|
|
466
460
|
# span(:alert, :id => 'alert')
|
467
461
|
# # will generate 'alert', 'alert_element', and 'alert?' methods
|
468
462
|
#
|
469
|
-
# @param [
|
463
|
+
# @param [Symbol] the name used for the generated methods
|
470
464
|
# @param [Hash] identifier how we find a span. You can use a multiple paramaters
|
471
465
|
# by combining of any of the following except xpath. The valid keys are:
|
472
466
|
# * :class => Watir and Selenium
|
@@ -476,7 +470,7 @@ module PageObject
|
|
476
470
|
# * :xpath => Watir and Selenium
|
477
471
|
# @param optional block to be invoked when element method is called
|
478
472
|
#
|
479
|
-
def span(name, identifier=
|
473
|
+
def span(name, identifier={:index => 0}, &block)
|
480
474
|
define_method(name) do
|
481
475
|
return platform.span_text_for identifier.clone unless block_given?
|
482
476
|
self.send("#{name}_element").text
|
@@ -501,7 +495,7 @@ module PageObject
|
|
501
495
|
# table(:cart, :id => 'shopping_cart')
|
502
496
|
# # will generate a 'cart_element' and 'cart?' method
|
503
497
|
#
|
504
|
-
# @param [
|
498
|
+
# @param [Symbol] the name used for the generated methods
|
505
499
|
# @param [Hash] identifier how we find a table. You can use a multiple paramaters
|
506
500
|
# by combining of any of the following except xpath. The valid keys are:
|
507
501
|
# * :class => Watir and Selenium
|
@@ -511,7 +505,7 @@ module PageObject
|
|
511
505
|
# * :xpath => Watir and Selenium
|
512
506
|
# @param optional block to be invoked when element method is called
|
513
507
|
#
|
514
|
-
def table(name, identifier=
|
508
|
+
def table(name, identifier={:index => 0}, &block)
|
515
509
|
define_method("#{name}_element") do
|
516
510
|
return call_block(&block) if block_given?
|
517
511
|
platform.table_for(identifier.clone)
|
@@ -532,7 +526,7 @@ module PageObject
|
|
532
526
|
# cell(:total, :id => 'total_cell')
|
533
527
|
# # will generate 'total', 'total_element', and 'total?' methods
|
534
528
|
#
|
535
|
-
# @param [
|
529
|
+
# @param [Symbol] the name used for the generated methods
|
536
530
|
# @param [Hash] identifier how we find a cell. You can use a multiple paramaters
|
537
531
|
# by combining of any of the following except xpath. The valid keys are:
|
538
532
|
# * :class => Watir and Selenium
|
@@ -543,7 +537,7 @@ module PageObject
|
|
543
537
|
# * :xpath => Watir and Selenium
|
544
538
|
# @param optional block to be invoked when element method is called
|
545
539
|
#
|
546
|
-
def cell(name, identifier=
|
540
|
+
def cell(name, identifier={:index => 0}, &block)
|
547
541
|
define_method("#{name}") do
|
548
542
|
return platform.cell_text_for identifier.clone unless block_given?
|
549
543
|
self.send("#{name}_element").text
|
@@ -567,7 +561,7 @@ module PageObject
|
|
567
561
|
# image(:logo, :id => 'logo')
|
568
562
|
# # will generate 'logo_element' and 'logo?' methods
|
569
563
|
#
|
570
|
-
# @param [
|
564
|
+
# @param [Symbol] the name used for the generated methods
|
571
565
|
# @param [Hash] identifier how we find an image. You can use a multiple paramaters
|
572
566
|
# by combining of any of the following except xpath. The valid keys are:
|
573
567
|
# * :alt => Watir and Selenium
|
@@ -579,7 +573,7 @@ module PageObject
|
|
579
573
|
# * :xpath => Watir and Selenium
|
580
574
|
# @param optional block to be invoked when element method is called
|
581
575
|
#
|
582
|
-
def image(name, identifier=
|
576
|
+
def image(name, identifier={:index => 0}, &block)
|
583
577
|
define_method("#{name}_element") do
|
584
578
|
return call_block(&block) if block_given?
|
585
579
|
platform.image_for(identifier.clone)
|
@@ -599,7 +593,7 @@ module PageObject
|
|
599
593
|
# form(:login, :id => 'login')
|
600
594
|
# # will generate 'login_element' and 'login?' methods
|
601
595
|
#
|
602
|
-
# @param [
|
596
|
+
# @param [Symbol] the name used for the generated methods
|
603
597
|
# @param [Hash] identifier how we find a form. You can use a multiple paramaters
|
604
598
|
# by combining of any of the following except xpath. The valid keys are:
|
605
599
|
# * :action => Watir and Selenium
|
@@ -609,7 +603,7 @@ module PageObject
|
|
609
603
|
# * :xpath => Watir and Selenium
|
610
604
|
# @param optional block to be invoked when element method is called
|
611
605
|
#
|
612
|
-
def form(name, identifier=
|
606
|
+
def form(name, identifier={:index => 0}, &block)
|
613
607
|
define_method("#{name}_element") do
|
614
608
|
return call_block(&block) if block_given?
|
615
609
|
platform.form_for(identifier.clone)
|
@@ -630,7 +624,7 @@ module PageObject
|
|
630
624
|
# list_item(:item_one, :id => 'one')
|
631
625
|
# # will generate 'item_one', 'item_one_element', and 'item_one?' methods
|
632
626
|
#
|
633
|
-
# @param [
|
627
|
+
# @param [Symbol] the name used for the generated methods
|
634
628
|
# @param [Hash] identifier how we find a list item. You can use a multiple paramaters
|
635
629
|
# by combining of any of the following except xpath. The valid keys are:
|
636
630
|
# * :class => Watir and Selenium
|
@@ -640,7 +634,7 @@ module PageObject
|
|
640
634
|
# * :xpath => Watir and Selenium
|
641
635
|
# @param optional block to be invoked when element method is called
|
642
636
|
#
|
643
|
-
def list_item(name, identifier=
|
637
|
+
def list_item(name, identifier={:index => 0}, &block)
|
644
638
|
define_method(name) do
|
645
639
|
return platform.list_item_text_for identifier.clone unless block_given?
|
646
640
|
self.send("#{name}_element").text
|
@@ -664,7 +658,7 @@ module PageObject
|
|
664
658
|
# unordered_list(:menu, :id => 'main_menu')
|
665
659
|
# # will generate 'menu_element' and 'menu?' methods
|
666
660
|
#
|
667
|
-
# @param [
|
661
|
+
# @param [Symbol] the name used for the generated methods
|
668
662
|
# @param [Hash] identifier how we find an unordered list. You can use a multiple paramaters
|
669
663
|
# by combining of any of the following except xpath. The valid keys are:
|
670
664
|
# * :class => Watir and Selenium
|
@@ -674,7 +668,7 @@ module PageObject
|
|
674
668
|
# * :xpath => Watir and Selenium
|
675
669
|
# @param optional block to be invoked when element method is called
|
676
670
|
#
|
677
|
-
def unordered_list(name, identifier=
|
671
|
+
def unordered_list(name, identifier={:index => 0}, &block)
|
678
672
|
define_method("#{name}_element") do
|
679
673
|
return call_block(&block) if block_given?
|
680
674
|
platform.unordered_list_for(identifier.clone)
|
@@ -694,7 +688,7 @@ module PageObject
|
|
694
688
|
# ordered_list(:top_five, :id => 'top')
|
695
689
|
# # will generate 'top_five_element' and 'top_five?' methods
|
696
690
|
#
|
697
|
-
# @param [
|
691
|
+
# @param [Symbol] the name used for the generated methods
|
698
692
|
# @param [Hash] identifier how we find an ordered list. You can use a multiple paramaters
|
699
693
|
# by combining of any of the following except xpath. The valid keys are:
|
700
694
|
# * :class => Watir and Selenium
|
@@ -704,7 +698,7 @@ module PageObject
|
|
704
698
|
# * :xpath => Watir and Selenium
|
705
699
|
# @param optional block to be invoked when element method is called
|
706
700
|
#
|
707
|
-
def ordered_list(name, identifier=
|
701
|
+
def ordered_list(name, identifier={:index => 0}, &block)
|
708
702
|
define_method("#{name}_element") do
|
709
703
|
return call_block(&block) if block_given?
|
710
704
|
platform.ordered_list_for(identifier.clone)
|
@@ -724,7 +718,7 @@ module PageObject
|
|
724
718
|
# h1(:title, :id => 'title')
|
725
719
|
# # will generate 'title', 'title_element', and 'title?' methods
|
726
720
|
#
|
727
|
-
# @param [
|
721
|
+
# @param [Symbol] the name used for the generated methods
|
728
722
|
# @param [Hash] identifier how we find a H1. You can use a multiple paramaters
|
729
723
|
# by combining of any of the following except xpath. The valid keys are:
|
730
724
|
# * :class => Watir and Selenium
|
@@ -734,7 +728,7 @@ module PageObject
|
|
734
728
|
# * :xpath => Watir and Selenium
|
735
729
|
# @param optional block to be invoked when element method is called
|
736
730
|
#
|
737
|
-
def h1(name, identifier=
|
731
|
+
def h1(name, identifier={:index => 0}, &block)
|
738
732
|
define_method(name) do
|
739
733
|
return platform.h1_text_for identifier.clone unless block_given?
|
740
734
|
self.send("#{name}_element").text
|
@@ -758,7 +752,7 @@ module PageObject
|
|
758
752
|
# h2(:title, :id => 'title')
|
759
753
|
# # will generate 'title', 'title_element', and 'title?' methods
|
760
754
|
#
|
761
|
-
# @param [
|
755
|
+
# @param [Symbol] the name used for the generated methods
|
762
756
|
# @param [Hash] identifier how we find a H2. You can use a multiple paramaters
|
763
757
|
# by combining of any of the following except xpath. The valid keys are:
|
764
758
|
# * :class => Watir and Selenium
|
@@ -768,7 +762,7 @@ module PageObject
|
|
768
762
|
# * :xpath => Watir and Selenium
|
769
763
|
# @param optional block to be invoked when element method is called
|
770
764
|
#
|
771
|
-
def h2(name, identifier=
|
765
|
+
def h2(name, identifier={:index => 0}, &block)
|
772
766
|
define_method(name) do
|
773
767
|
return platform.h2_text_for identifier.clone unless block_given?
|
774
768
|
self.send("#{name}_element").text
|
@@ -792,7 +786,7 @@ module PageObject
|
|
792
786
|
# h3(:title, :id => 'title')
|
793
787
|
# # will generate 'title', 'title_element', and 'title?' methods
|
794
788
|
#
|
795
|
-
# @param [
|
789
|
+
# @param [Symbol] the name used for the generated methods
|
796
790
|
# @param [Hash] identifier how we find a H3. You can use a multiple paramaters
|
797
791
|
# by combining of any of the following except xpath. The valid keys are:
|
798
792
|
# * :class => Watir and Selenium
|
@@ -802,7 +796,7 @@ module PageObject
|
|
802
796
|
# * :xpath => Watir and Selenium
|
803
797
|
# @param optional block to be invoked when element method is called
|
804
798
|
#
|
805
|
-
def h3(name, identifier=
|
799
|
+
def h3(name, identifier={:index => 0}, &block)
|
806
800
|
define_method(name) do
|
807
801
|
return platform.h3_text_for identifier.clone unless block_given?
|
808
802
|
self.send("#{name}_element").text
|
@@ -826,7 +820,7 @@ module PageObject
|
|
826
820
|
# h4(:title, :id => 'title')
|
827
821
|
# # will generate 'title', 'title_element', and 'title?' methods
|
828
822
|
#
|
829
|
-
# @param [
|
823
|
+
# @param [Symbol] the name used for the generated methods
|
830
824
|
# @param [Hash] identifier how we find a H4. You can use a multiple paramaters
|
831
825
|
# by combining of any of the following except xpath. The valid keys are:
|
832
826
|
# * :class => Watir and Selenium
|
@@ -836,7 +830,7 @@ module PageObject
|
|
836
830
|
# * :xpath => Watir and Selenium
|
837
831
|
# @param optional block to be invoked when element method is called
|
838
832
|
#
|
839
|
-
def h4(name, identifier=
|
833
|
+
def h4(name, identifier={:index => 0}, &block)
|
840
834
|
define_method(name) do
|
841
835
|
return platform.h4_text_for identifier.clone unless block_given?
|
842
836
|
self.send("#{name}_element").text
|
@@ -860,7 +854,7 @@ module PageObject
|
|
860
854
|
# h5(:title, :id => 'title')
|
861
855
|
# # will generate 'title', 'title_element', and 'title?' methods
|
862
856
|
#
|
863
|
-
# @param [
|
857
|
+
# @param [Symbol] the name used for the generated methods
|
864
858
|
# @param [Hash] identifier how we find a H5. You can use a multiple paramaters
|
865
859
|
# by combining of any of the following except xpath. The valid keys are:
|
866
860
|
# * :class => Watir and Selenium
|
@@ -870,7 +864,7 @@ module PageObject
|
|
870
864
|
# * :xpath => Watir and Selenium
|
871
865
|
# @param optional block to be invoked when element method is called
|
872
866
|
#
|
873
|
-
def h5(name, identifier=
|
867
|
+
def h5(name, identifier={:index => 0}, &block)
|
874
868
|
define_method(name) do
|
875
869
|
return platform.h5_text_for identifier.clone unless block_given?
|
876
870
|
self.send("#{name}_element").text
|
@@ -894,7 +888,7 @@ module PageObject
|
|
894
888
|
# h6(:title, :id => 'title')
|
895
889
|
# # will generate 'title', 'title_element', and 'title?' methods
|
896
890
|
#
|
897
|
-
# @param [
|
891
|
+
# @param [Symbol] the name used for the generated methods
|
898
892
|
# @param [Hash] identifier how we find a H6. You can use a multiple paramaters
|
899
893
|
# by combining of any of the following except xpath. The valid keys are:
|
900
894
|
# * :class => Watir and Selenium
|
@@ -904,7 +898,7 @@ module PageObject
|
|
904
898
|
# * :xpath => Watir and Selenium
|
905
899
|
# @param optional block to be invoked when element method is called
|
906
900
|
#
|
907
|
-
def h6(name, identifier=
|
901
|
+
def h6(name, identifier={:index => 0}, &block)
|
908
902
|
define_method(name) do
|
909
903
|
return platform.h6_text_for identifier.clone unless block_given?
|
910
904
|
self.send("#{name}_element").text
|
@@ -928,7 +922,7 @@ module PageObject
|
|
928
922
|
# paragraph(:title, :id => 'title')
|
929
923
|
# # will generate 'title', 'title_element', and 'title?' methods
|
930
924
|
#
|
931
|
-
# @param [
|
925
|
+
# @param [Symbol] the name used for the generated methods
|
932
926
|
# @param [Hash] identifier how we find a paragraph. You can use a multiple paramaters
|
933
927
|
# by combining of any of the following except xpath. The valid keys are:
|
934
928
|
# * :class => Watir and Selenium
|
@@ -938,7 +932,7 @@ module PageObject
|
|
938
932
|
# * :xpath => Watir and Selenium
|
939
933
|
# @param optional block to be invoked when element method is called
|
940
934
|
#
|
941
|
-
def paragraph(name, identifier=
|
935
|
+
def paragraph(name, identifier={:index => 0}, &block)
|
942
936
|
define_method(name) do
|
943
937
|
return platform.paragraph_text_for identifier.clone unless block_given?
|
944
938
|
self.send("#{name}_element").text
|
@@ -962,7 +956,7 @@ module PageObject
|
|
962
956
|
# file_field(:the_file, :id => 'file_to_upload')
|
963
957
|
# # will generate 'the_file=', 'the_file_element', and 'the_file?' methods
|
964
958
|
#
|
965
|
-
# @param [
|
959
|
+
# @param [Symbol] the name used for the generated methods
|
966
960
|
# @param [Hash] identifier how we find a file_field. You can use a multiple paramaters
|
967
961
|
# by combining of any of the following except xpath. The valid keys are:
|
968
962
|
# * :class => Watir and Selenium
|
@@ -973,7 +967,7 @@ module PageObject
|
|
973
967
|
# * :xpath => Watir and Selenium
|
974
968
|
# @param optional block to be invoked when element method is called
|
975
969
|
#
|
976
|
-
def file_field(name, identifier=
|
970
|
+
def file_field(name, identifier={:index => 0}, &block)
|
977
971
|
define_method("#{name}=") do |value|
|
978
972
|
return platform.file_field_value_set(identifier.clone, value) unless block_given?
|
979
973
|
self.send("#{name}_element").value = value
|
@@ -996,7 +990,7 @@ module PageObject
|
|
996
990
|
# label(:message, :id => 'message')
|
997
991
|
# # will generate 'message', 'message_element', and 'message?' methods
|
998
992
|
#
|
999
|
-
# @param [
|
993
|
+
# @param [Symbol] the name used for the generated methods
|
1000
994
|
# @param [Hash] identifier how we find a label. You can use a multiple paramaters
|
1001
995
|
# by combining of any of the following except xpath. The valid keys are:
|
1002
996
|
# * :class => Watir and Selenium
|
@@ -1007,7 +1001,7 @@ module PageObject
|
|
1007
1001
|
# * :xpath => Watir and Selenium
|
1008
1002
|
# @param optional block to be invoked when element method is called
|
1009
1003
|
#
|
1010
|
-
def label(name, identifier=
|
1004
|
+
def label(name, identifier={:index => 0}, &block)
|
1011
1005
|
define_method(name) do
|
1012
1006
|
return platform.label_text_for identifier.clone unless block_given?
|
1013
1007
|
self.send("#{name}_element").text
|
@@ -1028,10 +1022,11 @@ module PageObject
|
|
1028
1022
|
# to retrieve an element, and another to check the element's existence.
|
1029
1023
|
#
|
1030
1024
|
# @example
|
1031
|
-
# element(:title, :id => 'title')
|
1025
|
+
# element(:title, :header, :id => 'title')
|
1032
1026
|
# # will generate 'title', 'title_element', and 'title?' methods
|
1033
1027
|
#
|
1034
|
-
# @param [
|
1028
|
+
# @param [Symbol] the name used for the generated methods
|
1029
|
+
# @param [Symbol] the name of the tag for the element
|
1035
1030
|
# @param [Hash] identifier how we find an element. You can use a multiple paramaters
|
1036
1031
|
# by combining of any of the following except xpath. The valid keys are:
|
1037
1032
|
# * :class => Watir and Selenium
|
@@ -1041,7 +1036,7 @@ module PageObject
|
|
1041
1036
|
# * :xpath => Watir and Selenium
|
1042
1037
|
# @param optional block to be invoked when element method is called
|
1043
1038
|
#
|
1044
|
-
def element(name, tag, identifier=
|
1039
|
+
def element(name, tag, identifier={:index => 0}, &block)
|
1045
1040
|
define_method("#{name}") do
|
1046
1041
|
self.send("#{name}_element").text
|
1047
1042
|
end
|