page-object 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/ChangeLog +10 -0
- data/README.md +1 -1
- data/features/bold.feature +21 -0
- data/features/html/indexed_property.html +14 -0
- data/features/html/multi_elements.html +1 -1
- data/features/html/static_elements.html +1 -2
- data/features/indexed_property.feature +15 -0
- data/features/multi_elements.feature +6 -0
- data/features/step_definitions/async_steps.rb +1 -1
- data/features/step_definitions/bold_steps.rb +12 -0
- data/features/step_definitions/check_box_steps.rb +2 -2
- data/features/step_definitions/indexed_property_steps.rb +47 -1
- data/features/step_definitions/label_steps.rb +1 -1
- data/features/step_definitions/multi_elements_steps.rb +13 -0
- data/features/step_definitions/select_list_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +4 -0
- data/features/support/page.rb +9 -0
- data/features/table.feature +12 -4
- data/lib/page-object.rb +6 -5
- data/lib/page-object/accessors.rb +78 -58
- data/lib/page-object/elements.rb +1 -0
- data/lib/page-object/elements/bold.rb +11 -0
- data/lib/page-object/elements/element.rb +12 -1
- data/lib/page-object/elements/table.rb +12 -1
- data/lib/page-object/indexed_properties.rb +20 -21
- data/lib/page-object/javascript/angularjs.rb +14 -0
- data/lib/page-object/javascript_framework_facade.rb +4 -2
- data/lib/page-object/locator_generator.rb +1 -0
- data/lib/page-object/page_populator.rb +0 -1
- data/lib/page-object/platforms/selenium_webdriver/button.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/element.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +26 -10
- data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -7
- data/lib/page-object/platforms/watir_webdriver/element.rb +1 -1
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +23 -8
- data/lib/page-object/platforms/watir_webdriver/radio_button.rb +0 -7
- data/lib/page-object/version.rb +1 -1
- data/lib/page-object/widgets.rb +7 -0
- data/page-object.gemspec +3 -3
- data/spec/page-object/accessors_spec.rb +40 -0
- data/spec/page-object/element_locators_spec.rb +340 -305
- data/spec/page-object/elements/area_spec.rb +8 -8
- data/spec/page-object/elements/bold_spec.rb +29 -0
- data/spec/page-object/elements/button_spec.rb +7 -7
- data/spec/page-object/elements/canvas_spec.rb +6 -6
- data/spec/page-object/elements/check_box_spec.rb +9 -9
- data/spec/page-object/elements/div_spec.rb +3 -3
- data/spec/page-object/elements/element_spec.rb +21 -21
- data/spec/page-object/elements/file_field_spec.rb +4 -4
- data/spec/page-object/elements/form_spec.rb +3 -3
- data/spec/page-object/elements/heading_spec.rb +8 -8
- data/spec/page-object/elements/hidden_field_spec.rb +3 -3
- data/spec/page-object/elements/image_spec.rb +14 -14
- data/spec/page-object/elements/label_spec.rb +3 -3
- data/spec/page-object/elements/link_spec.rb +6 -6
- data/spec/page-object/elements/list_item_spec.rb +4 -3
- data/spec/page-object/elements/nested_element_spec.rb +47 -47
- data/spec/page-object/elements/option_spec.rb +1 -1
- data/spec/page-object/elements/ordered_list_spec.rb +33 -33
- data/spec/page-object/elements/paragraph_spec.rb +3 -4
- data/spec/page-object/elements/select_list_spec.rb +52 -52
- data/spec/page-object/elements/selenium/radio_button_spec.rb +7 -13
- data/spec/page-object/elements/selenium/text_field_spec.rb +7 -7
- data/spec/page-object/elements/selenium_element_spec.rb +53 -53
- data/spec/page-object/elements/span_spec.rb +3 -3
- data/spec/page-object/elements/table_cell_spec.rb +3 -3
- data/spec/page-object/elements/table_row_spec.rb +22 -22
- data/spec/page-object/elements/table_spec.rb +28 -28
- data/spec/page-object/elements/text_area_spec.rb +5 -5
- data/spec/page-object/elements/unordered_list_spec.rb +33 -34
- data/spec/page-object/elements/watir_element_spec.rb +47 -48
- data/spec/page-object/javascript_framework_facade_spec.rb +6 -6
- data/spec/page-object/loads_platform_spec.rb +4 -4
- data/spec/page-object/page-object_spec.rb +103 -102
- data/spec/page-object/page_factory_spec.rb +43 -61
- data/spec/page-object/page_populator_spec.rb +44 -50
- data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +15 -15
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +6 -6
- data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +4 -4
- data/spec/page-object/platforms/watir_webdriver_spec.rb +1 -1
- data/spec/page-object/selenium_accessors_spec.rb +166 -153
- data/spec/page-object/watir_accessors_spec.rb +265 -245
- data/spec/page-object/widget_spec.rb +62 -30
- data/spec/spec_helper.rb +8 -8
- metadata +20 -10
@@ -35,6 +35,7 @@ class WatirAccessorsTestPageObject
|
|
35
35
|
canvas(:my_canvas, :id => 'canvas_id')
|
36
36
|
audio(:acdc, :id => 'audio_id')
|
37
37
|
video(:movie, :id => 'video_id')
|
38
|
+
b(:bold,:id=>'bold')
|
38
39
|
end
|
39
40
|
|
40
41
|
class WatirBlockPageObject
|
@@ -129,6 +130,9 @@ class WatirBlockPageObject
|
|
129
130
|
video :movie do |element|
|
130
131
|
"video"
|
131
132
|
end
|
133
|
+
b :bold do |element|
|
134
|
+
"b"
|
135
|
+
end
|
132
136
|
end
|
133
137
|
|
134
138
|
describe PageObject::Accessors do
|
@@ -139,7 +143,7 @@ describe PageObject::Accessors do
|
|
139
143
|
context "goto a page" do
|
140
144
|
|
141
145
|
it "should navigate to a page when requested" do
|
142
|
-
watir_browser.
|
146
|
+
expect(watir_browser).to receive(:goto)
|
143
147
|
WatirAccessorsTestPageObject.new(watir_browser, true)
|
144
148
|
end
|
145
149
|
|
@@ -154,32 +158,32 @@ describe PageObject::Accessors do
|
|
154
158
|
super(b, v)
|
155
159
|
end
|
156
160
|
end
|
157
|
-
watir_browser.
|
161
|
+
expect(watir_browser).to receive(:goto).with('custom')
|
158
162
|
SymbolPageUrl.new(watir_browser, true, 'custom')
|
159
163
|
|
160
|
-
watir_browser.
|
161
|
-
SymbolPageUrl.new(watir_browser, true, 'different')
|
164
|
+
expect(watir_browser).to receive(:goto).with('different')
|
165
|
+
SymbolPageUrl.new(watir_browser, true, 'different')
|
162
166
|
end
|
163
167
|
|
164
168
|
it "should not navigate to a page when not requested" do
|
165
|
-
watir_browser.
|
169
|
+
expect(watir_browser).not_to receive(:goto)
|
166
170
|
WatirAccessorsTestPageObject.new(watir_browser)
|
167
171
|
end
|
168
172
|
|
169
173
|
it "should not navigate to a page when 'page_url' not specified" do
|
170
|
-
watir_browser.
|
174
|
+
expect(watir_browser).not_to receive(:goto)
|
171
175
|
WatirBlockPageObject.new(watir_browser, true)
|
172
176
|
end
|
173
177
|
|
174
178
|
it "should provide the page url" do
|
175
|
-
watir_page_object.page_url_value.
|
179
|
+
expect(watir_page_object.page_url_value).to eql 'http://apple.com'
|
176
180
|
end
|
177
181
|
end
|
178
182
|
|
179
183
|
context "validating the page title" do
|
180
184
|
it "should validate the title" do
|
181
|
-
watir_browser.
|
182
|
-
watir_page_object.
|
185
|
+
expect(watir_browser).to receive(:title).and_return("Expected Title")
|
186
|
+
expect(watir_page_object).to have_expected_title
|
183
187
|
end
|
184
188
|
|
185
189
|
it "should validate the by regexp" do
|
@@ -187,20 +191,20 @@ describe PageObject::Accessors do
|
|
187
191
|
include PageObject
|
188
192
|
expected_title /\w+ \w+/
|
189
193
|
end
|
190
|
-
watir_browser.
|
191
|
-
RegexpExpectedTitle.new(watir_browser).
|
194
|
+
expect(watir_browser).to receive(:title).and_return("Expected Title")
|
195
|
+
expect(RegexpExpectedTitle.new(watir_browser)).to have_expected_title
|
192
196
|
end
|
193
197
|
|
194
198
|
it "should raise error when it does not have expected title" do
|
195
|
-
watir_browser.
|
199
|
+
expect(watir_browser).to receive(:title).once.and_return("Not Expected")
|
196
200
|
expect { watir_page_object.has_expected_title? }.to raise_error
|
197
201
|
end
|
198
202
|
end
|
199
203
|
|
200
204
|
context "validating the existence of an element" do
|
201
205
|
it "should validate an element exists" do
|
202
|
-
watir_page_object.
|
203
|
-
watir_browser.
|
206
|
+
expect(watir_page_object).to receive(:google_search_element).and_return(watir_browser)
|
207
|
+
expect(watir_browser).to receive(:when_present).and_return(true)
|
204
208
|
watir_page_object.has_expected_element?
|
205
209
|
end
|
206
210
|
|
@@ -209,7 +213,7 @@ describe PageObject::Accessors do
|
|
209
213
|
include PageObject
|
210
214
|
expected_element :foo
|
211
215
|
end
|
212
|
-
FakePage.new(watir_browser).
|
216
|
+
expect(FakePage.new(watir_browser)).not_to have_expected_element
|
213
217
|
end
|
214
218
|
end
|
215
219
|
|
@@ -248,7 +252,7 @@ describe PageObject::Accessors do
|
|
248
252
|
let(:default_identifier) { WatirDefaultIdentifier.new(watir_browser) }
|
249
253
|
|
250
254
|
def mock_driver_for(tag)
|
251
|
-
watir_browser.
|
255
|
+
expect(watir_browser).to receive(tag).with(:index => 0).and_return(watir_browser)
|
252
256
|
end
|
253
257
|
|
254
258
|
it "should work with a text_field" do
|
@@ -303,7 +307,7 @@ describe PageObject::Accessors do
|
|
303
307
|
|
304
308
|
it "should work for a table" do
|
305
309
|
mock_driver_for :table
|
306
|
-
default_identifier.default_tab_element.
|
310
|
+
expect(default_identifier.default_tab_element).not_to be_nil
|
307
311
|
end
|
308
312
|
|
309
313
|
it "should work for a cell" do
|
@@ -391,24 +395,24 @@ describe PageObject::Accessors do
|
|
391
395
|
context "link accessors" do
|
392
396
|
context "when called on a page object" do
|
393
397
|
it "should generate accessor methods" do
|
394
|
-
watir_page_object.
|
395
|
-
watir_page_object.
|
398
|
+
expect(watir_page_object).to respond_to(:google_search)
|
399
|
+
expect(watir_page_object).to respond_to(:google_search_element)
|
396
400
|
end
|
397
401
|
|
398
402
|
it "should call a block on the element method when present" do
|
399
|
-
block_page_object.continue_element.
|
403
|
+
expect(block_page_object.continue_element).to eql "link"
|
400
404
|
end
|
401
405
|
end
|
402
406
|
|
403
407
|
it "should select a link" do
|
404
|
-
watir_browser.
|
408
|
+
expect(watir_browser).to receive_messages(link: watir_browser, click: watir_browser)
|
405
409
|
watir_page_object.google_search
|
406
410
|
end
|
407
411
|
|
408
412
|
it "should return a link element" do
|
409
|
-
watir_browser.
|
413
|
+
expect(watir_browser).to receive(:link).and_return(watir_browser)
|
410
414
|
element = watir_page_object.google_search_element
|
411
|
-
element.
|
415
|
+
expect(element).to be_instance_of PageObject::Elements::Link
|
412
416
|
end
|
413
417
|
end
|
414
418
|
|
@@ -416,33 +420,33 @@ describe PageObject::Accessors do
|
|
416
420
|
describe "text_field accessors" do
|
417
421
|
context "when called on a page object" do
|
418
422
|
it "should generate accessor methods" do
|
419
|
-
watir_page_object.
|
420
|
-
watir_page_object.
|
421
|
-
watir_page_object.
|
422
|
-
watir_page_object.
|
423
|
+
expect(watir_page_object).to respond_to(:first_name)
|
424
|
+
expect(watir_page_object).to respond_to(:first_name=)
|
425
|
+
expect(watir_page_object).to respond_to(:first_name_element)
|
426
|
+
expect(watir_page_object).to respond_to(:first_name?)
|
423
427
|
end
|
424
428
|
|
425
429
|
it "should call a block on the element method when present" do
|
426
|
-
block_page_object.first_name_element.
|
430
|
+
expect(block_page_object.first_name_element).to eql "text_field"
|
427
431
|
end
|
428
432
|
end
|
429
433
|
|
430
434
|
it "should get the text from the text field element" do
|
431
|
-
watir_browser.
|
432
|
-
watir_browser.
|
433
|
-
watir_page_object.first_name.
|
435
|
+
expect(watir_browser).to receive(:text_field).and_return(watir_browser)
|
436
|
+
expect(watir_browser).to receive(:value).and_return('Kim')
|
437
|
+
expect(watir_page_object.first_name).to eql 'Kim'
|
434
438
|
end
|
435
439
|
|
436
440
|
it "should set some text on a text field element" do
|
437
|
-
watir_browser.
|
438
|
-
watir_browser.
|
441
|
+
expect(watir_browser).to receive(:text_field).and_return(watir_browser)
|
442
|
+
expect(watir_browser).to receive(:set).with('Kim')
|
439
443
|
watir_page_object.first_name = 'Kim'
|
440
444
|
end
|
441
445
|
|
442
446
|
it "should retrieve a text field element" do
|
443
|
-
watir_browser.
|
447
|
+
expect(watir_browser).to receive(:text_field).and_return(watir_browser)
|
444
448
|
element = watir_page_object.first_name_element
|
445
|
-
element.
|
449
|
+
expect(element).to be_instance_of PageObject::Elements::TextField
|
446
450
|
end
|
447
451
|
end
|
448
452
|
|
@@ -450,147 +454,144 @@ describe PageObject::Accessors do
|
|
450
454
|
describe "hidden field accessors" do
|
451
455
|
context "when called on a page object" do
|
452
456
|
it "should generate accessor methods" do
|
453
|
-
watir_page_object.
|
454
|
-
watir_page_object.
|
457
|
+
expect(watir_page_object).to respond_to(:social_security_number)
|
458
|
+
expect(watir_page_object).to respond_to(:social_security_number_element)
|
455
459
|
end
|
456
460
|
|
457
461
|
it "should call a block on the element method when present" do
|
458
|
-
block_page_object.secret_element.
|
462
|
+
expect(block_page_object.secret_element).to eql "hidden_field"
|
459
463
|
end
|
460
464
|
end
|
461
465
|
|
462
466
|
it "should get the text from a hidden field" do
|
463
|
-
watir_browser.
|
464
|
-
watir_browser.
|
465
|
-
watir_page_object.social_security_number.
|
467
|
+
expect(watir_browser).to receive(:hidden).and_return(watir_browser)
|
468
|
+
expect(watir_browser).to receive(:value).and_return("value")
|
469
|
+
expect(watir_page_object.social_security_number).to eql "value"
|
466
470
|
end
|
467
471
|
|
468
472
|
it "should retrieve a hidden field element" do
|
469
|
-
watir_browser.
|
473
|
+
expect(watir_browser).to receive(:hidden).and_return(watir_browser)
|
470
474
|
element = watir_page_object.social_security_number_element
|
471
|
-
element.
|
475
|
+
expect(element).to be_instance_of(PageObject::Elements::HiddenField)
|
472
476
|
end
|
473
477
|
end
|
474
478
|
|
475
479
|
describe "text area accessors" do
|
476
480
|
context "when called on a page object" do
|
477
481
|
it "should generate accessor methods" do
|
478
|
-
watir_page_object.
|
479
|
-
watir_page_object.
|
480
|
-
watir_page_object.
|
482
|
+
expect(watir_page_object).to respond_to(:address)
|
483
|
+
expect(watir_page_object).to respond_to(:address=)
|
484
|
+
expect(watir_page_object).to respond_to(:address_element)
|
481
485
|
end
|
482
486
|
|
483
487
|
it "should call a block on the element method when present" do
|
484
|
-
block_page_object.address_element.
|
488
|
+
expect(block_page_object.address_element).to eql "text_area"
|
485
489
|
end
|
486
490
|
end
|
487
491
|
|
488
492
|
it "should set some text on the text area" do
|
489
|
-
watir_browser.
|
490
|
-
watir_browser.
|
493
|
+
expect(watir_browser).to receive(:textarea).and_return(watir_browser)
|
494
|
+
expect(watir_browser).to receive(:set).with("123 main street")
|
491
495
|
watir_page_object.address = "123 main street"
|
492
496
|
end
|
493
497
|
|
494
498
|
it "should get the text from the text area" do
|
495
|
-
watir_browser.
|
496
|
-
watir_browser.
|
497
|
-
watir_page_object.address.
|
499
|
+
expect(watir_browser).to receive(:textarea).and_return(watir_browser)
|
500
|
+
expect(watir_browser).to receive(:value).and_return("123 main street")
|
501
|
+
expect(watir_page_object.address).to eql "123 main street"
|
498
502
|
end
|
499
503
|
|
500
504
|
it "should retrieve a text area element" do
|
501
|
-
watir_browser.
|
505
|
+
expect(watir_browser).to receive(:textarea).and_return(watir_browser)
|
502
506
|
element = watir_page_object.address_element
|
503
|
-
element.
|
507
|
+
expect(element).to be_instance_of PageObject::Elements::TextArea
|
504
508
|
end
|
505
509
|
end
|
506
510
|
|
507
511
|
describe "select_list accessors" do
|
508
512
|
context "when called on a page object" do
|
509
513
|
it "should generate accessor methods" do
|
510
|
-
watir_page_object.
|
511
|
-
watir_page_object.
|
512
|
-
watir_page_object.
|
514
|
+
expect(watir_page_object).to respond_to :state
|
515
|
+
expect(watir_page_object).to respond_to :state=
|
516
|
+
expect(watir_page_object).to respond_to(:state_element)
|
513
517
|
end
|
514
518
|
|
515
519
|
it "should call a block on the element method when present" do
|
516
|
-
block_page_object.state_element.
|
520
|
+
expect(block_page_object.state_element).to eql "select_list"
|
517
521
|
end
|
518
522
|
end
|
519
523
|
|
520
524
|
it "should get the current item from a select list" do
|
521
525
|
selected = "OH"
|
522
|
-
selected.
|
523
|
-
selected.
|
524
|
-
watir_browser.
|
525
|
-
watir_browser.
|
526
|
-
watir_page_object.state.
|
526
|
+
expect(selected).to receive(:selected?).and_return(selected)
|
527
|
+
expect(selected).to receive(:text).and_return("OH")
|
528
|
+
expect(watir_browser).to receive(:select_list).and_return watir_browser
|
529
|
+
expect(watir_browser).to receive(:options).and_return([selected])
|
530
|
+
expect(watir_page_object.state).to eql "OH"
|
527
531
|
end
|
528
532
|
|
529
533
|
it "should set the current item of a select list" do
|
530
|
-
watir_browser.
|
531
|
-
watir_browser.
|
534
|
+
expect(watir_browser).to receive(:select_list).and_return watir_browser
|
535
|
+
expect(watir_browser).to receive(:select).with("OH")
|
532
536
|
watir_page_object.state = "OH"
|
533
537
|
end
|
534
538
|
|
535
539
|
it "should retreive the select list element" do
|
536
|
-
watir_browser.
|
540
|
+
expect(watir_browser).to receive(:select_list).and_return(watir_browser)
|
537
541
|
element = watir_page_object.state_element
|
538
|
-
element.
|
542
|
+
expect(element).to be_instance_of PageObject::Elements::SelectList
|
539
543
|
end
|
540
|
-
|
544
|
+
|
541
545
|
it "should return list of selection options" do
|
542
546
|
option1 = double('option')
|
543
547
|
option2 = double('option')
|
544
|
-
option1.
|
545
|
-
option2.
|
548
|
+
expect(option1).to receive(:text).and_return("CA")
|
549
|
+
expect(option2).to receive(:text).and_return("OH")
|
546
550
|
|
547
551
|
select_element = double("select")
|
548
|
-
select_element.
|
549
|
-
watir_page_object.
|
550
|
-
|
551
|
-
watir_page_object.state_options.
|
552
|
+
expect(select_element).to receive(:options).twice.and_return([option1, option2])
|
553
|
+
expect(watir_page_object).to receive(:state_element).and_return(select_element)
|
554
|
+
|
555
|
+
expect(watir_page_object.state_options).to eql ["CA","OH"]
|
552
556
|
end
|
553
|
-
|
554
|
-
|
555
557
|
end
|
556
558
|
|
557
|
-
|
558
559
|
describe "check_box accessors" do
|
559
560
|
context "when called on a page object" do
|
560
561
|
it "should generate accessor methods" do
|
561
|
-
watir_page_object.
|
562
|
-
watir_page_object.
|
563
|
-
watir_page_object.
|
564
|
-
watir_page_object.
|
562
|
+
expect(watir_page_object).to respond_to :check_active
|
563
|
+
expect(watir_page_object).to respond_to :uncheck_active
|
564
|
+
expect(watir_page_object).to respond_to :active_checked?
|
565
|
+
expect(watir_page_object).to respond_to :active_element
|
565
566
|
end
|
566
567
|
|
567
568
|
it "should call a block on the element method when present" do
|
568
|
-
block_page_object.active_element.
|
569
|
+
expect(block_page_object.active_element).to eql "checkbox"
|
569
570
|
end
|
570
571
|
end
|
571
572
|
|
572
573
|
it "should check a check box element" do
|
573
|
-
watir_browser.
|
574
|
-
watir_browser.
|
574
|
+
expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
|
575
|
+
expect(watir_browser).to receive(:set)
|
575
576
|
watir_page_object.check_active
|
576
577
|
end
|
577
578
|
|
578
579
|
it "should clear a check box element" do
|
579
|
-
watir_browser.
|
580
|
-
watir_browser.
|
580
|
+
expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
|
581
|
+
expect(watir_browser).to receive(:clear)
|
581
582
|
watir_page_object.uncheck_active
|
582
583
|
end
|
583
584
|
|
584
585
|
it "should know if a check box element is selected" do
|
585
|
-
watir_browser.
|
586
|
-
watir_browser.
|
587
|
-
watir_page_object.active_checked
|
586
|
+
expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
|
587
|
+
expect(watir_browser).to receive(:set?).and_return(true)
|
588
|
+
expect(watir_page_object.active_checked?).to be true
|
588
589
|
end
|
589
590
|
|
590
591
|
it "should retrieve a checkbox element" do
|
591
|
-
watir_browser.
|
592
|
+
expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
|
592
593
|
element = watir_page_object.active_element
|
593
|
-
element.
|
594
|
+
expect(element).to be_instance_of PageObject::Elements::CheckBox
|
594
595
|
end
|
595
596
|
end
|
596
597
|
|
@@ -598,405 +599,398 @@ describe PageObject::Accessors do
|
|
598
599
|
describe "radio accessors" do
|
599
600
|
context "when called on a page object" do
|
600
601
|
it "should generate accessor methods" do
|
601
|
-
watir_page_object.
|
602
|
-
watir_page_object.
|
603
|
-
watir_page_object.
|
604
|
-
watir_page_object.should respond_to(:first_element)
|
602
|
+
expect(watir_page_object).to respond_to :select_first
|
603
|
+
expect(watir_page_object).to respond_to :first_selected?
|
604
|
+
expect(watir_page_object).to respond_to(:first_element)
|
605
605
|
end
|
606
606
|
|
607
607
|
it "should call a block on the element method when present" do
|
608
|
-
block_page_object.first_element.
|
608
|
+
expect(block_page_object.first_element).to eql "radio_button"
|
609
609
|
end
|
610
610
|
end
|
611
611
|
|
612
612
|
it "should select a radio button" do
|
613
|
-
watir_browser.
|
614
|
-
watir_browser.
|
613
|
+
expect(watir_browser).to receive(:radio).and_return(watir_browser)
|
614
|
+
expect(watir_browser).to receive(:set)
|
615
615
|
watir_page_object.select_first
|
616
616
|
end
|
617
617
|
|
618
|
-
it "should clear a radio button" do
|
619
|
-
watir_browser.should_receive(:radio).and_return(watir_browser)
|
620
|
-
watir_browser.should_receive(:clear)
|
621
|
-
watir_page_object.clear_first
|
622
|
-
end
|
623
|
-
|
624
618
|
it "should determine if a radio is selected" do
|
625
|
-
watir_browser.
|
626
|
-
watir_browser.
|
619
|
+
expect(watir_browser).to receive(:radio).and_return(watir_browser)
|
620
|
+
expect(watir_browser).to receive(:set?)
|
627
621
|
watir_page_object.first_selected?
|
628
622
|
end
|
629
623
|
|
630
624
|
it "should retrieve a radio button element" do
|
631
|
-
watir_browser.
|
625
|
+
expect(watir_browser).to receive(:radio).and_return(watir_browser)
|
632
626
|
element = watir_page_object.first_element
|
633
|
-
element.
|
627
|
+
expect(element).to be_instance_of PageObject::Elements::RadioButton
|
634
628
|
end
|
635
629
|
end
|
636
630
|
|
637
631
|
describe "button accessors" do
|
638
632
|
context "when called on a page object" do
|
639
633
|
it "should generate accessor methods" do
|
640
|
-
watir_page_object.
|
641
|
-
watir_page_object.
|
634
|
+
expect(watir_page_object).to respond_to :click_me
|
635
|
+
expect(watir_page_object).to respond_to :click_me_element
|
642
636
|
end
|
643
637
|
|
644
638
|
it "should call a block on the element method when present" do
|
645
|
-
block_page_object.click_me_element.
|
639
|
+
expect(block_page_object.click_me_element).to eql "button"
|
646
640
|
end
|
647
641
|
end
|
648
642
|
|
649
643
|
it "should be able to click a button" do
|
650
|
-
watir_browser.
|
651
|
-
watir_browser.
|
644
|
+
expect(watir_browser).to receive(:button).and_return(watir_browser)
|
645
|
+
expect(watir_browser).to receive(:click)
|
652
646
|
watir_page_object.click_me
|
653
647
|
end
|
654
648
|
|
655
649
|
it "should retrieve a button element" do
|
656
|
-
watir_browser.
|
650
|
+
expect(watir_browser).to receive(:button).and_return(watir_browser)
|
657
651
|
element = watir_page_object.click_me_element
|
658
|
-
element.
|
652
|
+
expect(element).to be_instance_of PageObject::Elements::Button
|
659
653
|
end
|
660
654
|
end
|
661
655
|
|
662
656
|
describe "div accessors" do
|
663
657
|
context "when called on a page object" do
|
664
658
|
it "should generate accessor methods" do
|
665
|
-
watir_page_object.
|
666
|
-
watir_page_object.
|
659
|
+
expect(watir_page_object).to respond_to(:message)
|
660
|
+
expect(watir_page_object).to respond_to(:message_element)
|
667
661
|
end
|
668
662
|
|
669
663
|
it "should call a block on the element method when present" do
|
670
|
-
block_page_object.footer_element.
|
664
|
+
expect(block_page_object.footer_element).to eql "div"
|
671
665
|
end
|
672
666
|
end
|
673
667
|
|
674
668
|
it "should retrieve the text from a div" do
|
675
|
-
watir_browser.
|
676
|
-
watir_browser.
|
677
|
-
watir_page_object.message.
|
669
|
+
expect(watir_browser).to receive(:div).and_return(watir_browser)
|
670
|
+
expect(watir_browser).to receive(:text).and_return("Message from div")
|
671
|
+
expect(watir_page_object.message).to eql "Message from div"
|
678
672
|
end
|
679
673
|
|
680
674
|
it "should retrieve the div element from the page" do
|
681
|
-
watir_browser.
|
675
|
+
expect(watir_browser).to receive(:div).and_return(watir_browser)
|
682
676
|
element = watir_page_object.message_element
|
683
|
-
element.
|
677
|
+
expect(element).to be_instance_of PageObject::Elements::Div
|
684
678
|
end
|
685
679
|
end
|
686
680
|
|
687
681
|
describe "span accessors" do
|
688
682
|
context "when called on a page object" do
|
689
683
|
it "should generate accessor methods" do
|
690
|
-
watir_page_object.
|
691
|
-
watir_page_object.
|
684
|
+
expect(watir_page_object).to respond_to(:alert_span)
|
685
|
+
expect(watir_page_object).to respond_to(:alert_span_element)
|
692
686
|
end
|
693
687
|
|
694
688
|
it "should call a block on the element method when present" do
|
695
|
-
block_page_object.alert_span_element.
|
689
|
+
expect(block_page_object.alert_span_element).to eql "span"
|
696
690
|
end
|
697
691
|
end
|
698
692
|
|
699
693
|
it "should retrieve the text from a span" do
|
700
|
-
watir_browser.
|
701
|
-
watir_browser.
|
702
|
-
watir_page_object.alert_span.
|
694
|
+
expect(watir_browser).to receive(:span).and_return(watir_browser)
|
695
|
+
expect(watir_browser).to receive(:text).and_return("Alert")
|
696
|
+
expect(watir_page_object.alert_span).to eql "Alert"
|
703
697
|
end
|
704
698
|
|
705
699
|
it "should retrieve the span element from the page" do
|
706
|
-
watir_browser.
|
700
|
+
expect(watir_browser).to receive(:span).and_return(watir_browser)
|
707
701
|
element = watir_page_object.alert_span_element
|
708
|
-
element.
|
702
|
+
expect(element).to be_instance_of PageObject::Elements::Span
|
709
703
|
end
|
710
704
|
end
|
711
705
|
|
712
706
|
describe "table accessors" do
|
713
707
|
context "when called on a page object" do
|
714
708
|
it "should generate accessor methods" do
|
715
|
-
watir_page_object.
|
716
|
-
watir_page_object.
|
709
|
+
expect(watir_page_object).to respond_to(:cart)
|
710
|
+
expect(watir_page_object).to respond_to(:cart_element)
|
717
711
|
end
|
718
712
|
|
719
713
|
it "should call a block on the element method when present" do
|
720
|
-
block_page_object.cart_element.
|
714
|
+
expect(block_page_object.cart_element).to eql "table"
|
721
715
|
end
|
722
716
|
end
|
723
717
|
|
724
718
|
it "should retrieve the table element from the page" do
|
725
|
-
watir_browser.
|
719
|
+
expect(watir_browser).to receive(:table).and_return(watir_browser)
|
726
720
|
element = watir_page_object.cart_element
|
727
|
-
element.
|
721
|
+
expect(element).to be_instance_of PageObject::Elements::Table
|
728
722
|
end
|
729
723
|
end
|
730
724
|
|
731
725
|
describe "table cell accessors" do
|
732
726
|
context "when called on a page object" do
|
733
727
|
it "should generate accessor methods" do
|
734
|
-
watir_page_object.
|
735
|
-
watir_page_object.
|
728
|
+
expect(watir_page_object).to respond_to(:total)
|
729
|
+
expect(watir_page_object).to respond_to(:total_element)
|
736
730
|
end
|
737
731
|
|
738
732
|
it "should call a block on the element method when present" do
|
739
|
-
block_page_object.total_element.
|
733
|
+
expect(block_page_object.total_element).to eql "cell"
|
740
734
|
end
|
741
735
|
end
|
742
736
|
|
743
737
|
it "should retrieve the text for the cell" do
|
744
|
-
watir_browser.
|
745
|
-
watir_browser.
|
746
|
-
watir_page_object.total.
|
738
|
+
expect(watir_browser).to receive(:td).and_return(watir_browser)
|
739
|
+
expect(watir_browser).to receive(:text).and_return('10.00')
|
740
|
+
expect(watir_page_object.total).to eql '10.00'
|
747
741
|
end
|
748
742
|
|
749
743
|
it "should retrieve the cell element from the page" do
|
750
|
-
watir_browser.
|
744
|
+
expect(watir_browser).to receive(:td).and_return(watir_browser)
|
751
745
|
element = watir_page_object.total_element
|
752
|
-
element.
|
746
|
+
expect(element).to be_instance_of PageObject::Elements::TableCell
|
753
747
|
end
|
754
748
|
end
|
755
749
|
|
756
750
|
describe "image accessors" do
|
757
751
|
context "when called on a page object" do
|
758
752
|
it "should generate accessor methods" do
|
759
|
-
watir_page_object.
|
753
|
+
expect(watir_page_object).to respond_to(:logo_element)
|
760
754
|
end
|
761
755
|
|
762
756
|
it "should call a block on the element method when present" do
|
763
|
-
block_page_object.logo_element.
|
757
|
+
expect(block_page_object.logo_element).to eql "image"
|
764
758
|
end
|
765
759
|
end
|
766
760
|
|
767
761
|
it "should retrieve the image element from the page" do
|
768
|
-
watir_browser.
|
762
|
+
expect(watir_browser).to receive(:image).and_return(watir_browser)
|
769
763
|
element = watir_page_object.logo_element
|
770
|
-
element.
|
764
|
+
expect(element).to be_instance_of PageObject::Elements::Image
|
771
765
|
end
|
772
766
|
end
|
773
767
|
|
774
768
|
describe "form accessors" do
|
775
769
|
context "when called on a page object" do
|
776
770
|
it "should generate accessor methods" do
|
777
|
-
watir_page_object.
|
771
|
+
expect(watir_page_object).to respond_to(:login_element)
|
778
772
|
end
|
779
773
|
|
780
774
|
it "should call a block on the element method when present" do
|
781
|
-
block_page_object.login_element.
|
775
|
+
expect(block_page_object.login_element).to eql "form"
|
782
776
|
end
|
783
777
|
end
|
784
778
|
|
785
779
|
it "should retrieve the form element from the page" do
|
786
|
-
watir_browser.
|
780
|
+
expect(watir_browser).to receive(:form).and_return(watir_browser)
|
787
781
|
element = watir_page_object.login_element
|
788
|
-
element.
|
782
|
+
expect(element).to be_instance_of PageObject::Elements::Form
|
789
783
|
end
|
790
784
|
end
|
791
785
|
|
792
786
|
describe "list item accessors" do
|
793
787
|
context "when called on a page object" do
|
794
788
|
it "should generate accessor methods" do
|
795
|
-
watir_page_object.
|
796
|
-
watir_page_object.
|
789
|
+
expect(watir_page_object).to respond_to(:item_one)
|
790
|
+
expect(watir_page_object).to respond_to(:item_one_element)
|
797
791
|
end
|
798
792
|
|
799
793
|
it "should call a block on the element method when present" do
|
800
|
-
block_page_object.item_one_element.
|
794
|
+
expect(block_page_object.item_one_element).to eql "list_item"
|
801
795
|
end
|
802
796
|
end
|
803
797
|
|
804
798
|
it "should retrieve the text from the list item" do
|
805
|
-
watir_browser.
|
806
|
-
watir_browser.
|
807
|
-
watir_page_object.item_one.
|
799
|
+
expect(watir_browser).to receive(:li).and_return(watir_browser)
|
800
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
801
|
+
expect(watir_page_object.item_one).to eql "value"
|
808
802
|
end
|
809
803
|
|
810
804
|
it "should retrieve the list item element from the page" do
|
811
|
-
watir_browser.
|
805
|
+
expect(watir_browser).to receive(:li).and_return(watir_browser)
|
812
806
|
element = watir_page_object.item_one_element
|
813
|
-
element.
|
807
|
+
expect(element).to be_instance_of PageObject::Elements::ListItem
|
814
808
|
end
|
815
809
|
end
|
816
810
|
|
817
811
|
describe "unordered list accessors" do
|
818
812
|
context "when called on a page object" do
|
819
813
|
it "should generate accessor methods" do
|
820
|
-
watir_page_object.
|
814
|
+
expect(watir_page_object).to respond_to(:menu_element)
|
821
815
|
end
|
822
816
|
|
823
817
|
it "should call a block on the element method when present" do
|
824
|
-
block_page_object.menu_element.
|
818
|
+
expect(block_page_object.menu_element).to eql "unordered_list"
|
825
819
|
end
|
826
820
|
end
|
827
821
|
|
828
822
|
it "should retrieve the element from the page" do
|
829
|
-
watir_browser.
|
823
|
+
expect(watir_browser).to receive(:ul).and_return(watir_browser)
|
830
824
|
element = watir_page_object.menu_element
|
831
|
-
element.
|
825
|
+
expect(element).to be_instance_of PageObject::Elements::UnorderedList
|
832
826
|
end
|
833
827
|
end
|
834
828
|
|
835
829
|
describe "ordered list accessors" do
|
836
830
|
context "when called on a page object" do
|
837
831
|
it "should generate accessor methods" do
|
838
|
-
watir_page_object.
|
832
|
+
expect(watir_page_object).to respond_to(:top_five_element)
|
839
833
|
end
|
840
834
|
|
841
835
|
it "should call a block on the element method when present" do
|
842
|
-
block_page_object.top_five_element.
|
836
|
+
expect(block_page_object.top_five_element).to eql "ordered_list"
|
843
837
|
end
|
844
838
|
end
|
845
839
|
|
846
840
|
it "should retrieve the element from the page" do
|
847
|
-
watir_browser.
|
841
|
+
expect(watir_browser).to receive(:ol).and_return(watir_browser)
|
848
842
|
element = watir_page_object.top_five_element
|
849
|
-
element.
|
843
|
+
expect(element).to be_instance_of PageObject::Elements::OrderedList
|
850
844
|
end
|
851
845
|
end
|
852
846
|
|
853
847
|
describe "h1 accessors" do
|
854
848
|
context "when called on a page object" do
|
855
849
|
it "should generate accessor methods" do
|
856
|
-
watir_page_object.
|
857
|
-
watir_page_object.
|
850
|
+
expect(watir_page_object).to respond_to(:heading1)
|
851
|
+
expect(watir_page_object).to respond_to(:heading1_element)
|
858
852
|
end
|
859
853
|
|
860
854
|
it "should call a block on the element method when present" do
|
861
|
-
block_page_object.heading1_element.
|
855
|
+
expect(block_page_object.heading1_element).to eql "h1"
|
862
856
|
end
|
863
857
|
end
|
864
858
|
|
865
859
|
it "should retrieve the text from the h1" do
|
866
|
-
watir_browser.
|
867
|
-
watir_browser.
|
868
|
-
watir_page_object.heading1.
|
860
|
+
expect(watir_browser).to receive(:h1).and_return(watir_browser)
|
861
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
862
|
+
expect(watir_page_object.heading1).to eql "value"
|
869
863
|
end
|
870
864
|
|
871
865
|
it "should retrieve the element from the page" do
|
872
|
-
watir_browser.
|
866
|
+
expect(watir_browser).to receive(:h1).and_return(watir_browser)
|
873
867
|
element = watir_page_object.heading1_element
|
874
|
-
element.
|
868
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
875
869
|
end
|
876
870
|
end
|
877
871
|
|
878
872
|
describe "h2 accessors" do
|
879
873
|
context "when called on a page object" do
|
880
874
|
it "should generate accessor methods" do
|
881
|
-
watir_page_object.
|
882
|
-
watir_page_object.
|
875
|
+
expect(watir_page_object).to respond_to(:heading2)
|
876
|
+
expect(watir_page_object).to respond_to(:heading2_element)
|
883
877
|
end
|
884
878
|
|
885
879
|
it "should call a block on the element method when present" do
|
886
|
-
block_page_object.heading2_element.
|
880
|
+
expect(block_page_object.heading2_element).to eql "h2"
|
887
881
|
end
|
888
882
|
end
|
889
883
|
|
890
884
|
it "should retrieve the text from the h2" do
|
891
|
-
watir_browser.
|
892
|
-
watir_browser.
|
893
|
-
watir_page_object.heading2.
|
885
|
+
expect(watir_browser).to receive(:h2).and_return(watir_browser)
|
886
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
887
|
+
expect(watir_page_object.heading2).to eql "value"
|
894
888
|
end
|
895
889
|
|
896
890
|
it "should retrieve the element from the page" do
|
897
|
-
watir_browser.
|
891
|
+
expect(watir_browser).to receive(:h2).and_return(watir_browser)
|
898
892
|
element = watir_page_object.heading2_element
|
899
|
-
element.
|
893
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
900
894
|
end
|
901
895
|
end
|
902
896
|
|
903
897
|
describe "h3 accessors" do
|
904
898
|
context "when called on a page object" do
|
905
899
|
it "should generate accessor methods" do
|
906
|
-
watir_page_object.
|
907
|
-
watir_page_object.
|
900
|
+
expect(watir_page_object).to respond_to(:heading3)
|
901
|
+
expect(watir_page_object).to respond_to(:heading3_element)
|
908
902
|
end
|
909
903
|
|
910
904
|
it "should call a block on the element method when present" do
|
911
|
-
block_page_object.heading3_element.
|
905
|
+
expect(block_page_object.heading3_element).to eql "h3"
|
912
906
|
end
|
913
907
|
end
|
914
908
|
|
915
909
|
it "should retrieve the text from the h3" do
|
916
|
-
watir_browser.
|
917
|
-
watir_browser.
|
918
|
-
watir_page_object.heading3.
|
910
|
+
expect(watir_browser).to receive(:h3).and_return(watir_browser)
|
911
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
912
|
+
expect(watir_page_object.heading3).to eql "value"
|
919
913
|
end
|
920
914
|
|
921
915
|
it "should retrieve the element from the page" do
|
922
|
-
watir_browser.
|
916
|
+
expect(watir_browser).to receive(:h3).and_return(watir_browser)
|
923
917
|
element = watir_page_object.heading3_element
|
924
|
-
element.
|
918
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
925
919
|
end
|
926
920
|
end
|
927
921
|
|
928
922
|
describe "h4 accessors" do
|
929
923
|
context "when called on a page object" do
|
930
924
|
it "should generate accessor methods" do
|
931
|
-
watir_page_object.
|
932
|
-
watir_page_object.
|
925
|
+
expect(watir_page_object).to respond_to(:heading4)
|
926
|
+
expect(watir_page_object).to respond_to(:heading4_element)
|
933
927
|
end
|
934
928
|
|
935
929
|
it "should call a block on the element method when present" do
|
936
|
-
block_page_object.heading4_element.
|
930
|
+
expect(block_page_object.heading4_element).to eql "h4"
|
937
931
|
end
|
938
932
|
end
|
939
933
|
|
940
934
|
it "should retrieve the text from the h4" do
|
941
|
-
watir_browser.
|
942
|
-
watir_browser.
|
943
|
-
watir_page_object.heading4.
|
935
|
+
expect(watir_browser).to receive(:h4).and_return(watir_browser)
|
936
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
937
|
+
expect(watir_page_object.heading4).to eql "value"
|
944
938
|
end
|
945
939
|
|
946
940
|
it "should retrieve the element from the page" do
|
947
|
-
watir_browser.
|
941
|
+
expect(watir_browser).to receive(:h4).and_return(watir_browser)
|
948
942
|
element = watir_page_object.heading4_element
|
949
|
-
element.
|
943
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
950
944
|
end
|
951
945
|
end
|
952
946
|
|
953
947
|
describe "h5 accessors" do
|
954
948
|
context "when called on a page object" do
|
955
949
|
it "should generate accessor methods" do
|
956
|
-
watir_page_object.
|
957
|
-
watir_page_object.
|
950
|
+
expect(watir_page_object).to respond_to(:heading5)
|
951
|
+
expect(watir_page_object).to respond_to(:heading5_element)
|
958
952
|
end
|
959
953
|
|
960
954
|
it "should call a block on the element method when present" do
|
961
|
-
block_page_object.heading5_element.
|
955
|
+
expect(block_page_object.heading5_element).to eql "h5"
|
962
956
|
end
|
963
957
|
end
|
964
958
|
|
965
959
|
it "should retrieve the text from the h5" do
|
966
|
-
watir_browser.
|
967
|
-
watir_browser.
|
968
|
-
watir_page_object.heading5.
|
960
|
+
expect(watir_browser).to receive(:h5).and_return(watir_browser)
|
961
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
962
|
+
expect(watir_page_object.heading5).to eql "value"
|
969
963
|
end
|
970
964
|
|
971
965
|
it "should retrieve the element from the page" do
|
972
|
-
watir_browser.
|
966
|
+
expect(watir_browser).to receive(:h5).and_return(watir_browser)
|
973
967
|
element = watir_page_object.heading5_element
|
974
|
-
element.
|
968
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
975
969
|
end
|
976
970
|
end
|
977
971
|
|
978
972
|
describe "h6 accessors" do
|
979
973
|
context "when called on a page object" do
|
980
974
|
it "should generate accessor methods" do
|
981
|
-
watir_page_object.
|
982
|
-
watir_page_object.
|
975
|
+
expect(watir_page_object).to respond_to(:heading6)
|
976
|
+
expect(watir_page_object).to respond_to(:heading6_element)
|
983
977
|
end
|
984
978
|
|
985
979
|
it "should call a block on the element method when present" do
|
986
|
-
block_page_object.heading6_element.
|
980
|
+
expect(block_page_object.heading6_element).to eql "h6"
|
987
981
|
end
|
988
982
|
end
|
989
983
|
|
990
984
|
it "should retrieve the text from the h6" do
|
991
|
-
watir_browser.
|
992
|
-
watir_browser.
|
993
|
-
watir_page_object.heading6.
|
985
|
+
expect(watir_browser).to receive(:h6).and_return(watir_browser)
|
986
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
987
|
+
expect(watir_page_object.heading6).to eql "value"
|
994
988
|
end
|
995
989
|
|
996
990
|
it "should retrieve the element from the page" do
|
997
|
-
watir_browser.
|
991
|
+
expect(watir_browser).to receive(:h6).and_return(watir_browser)
|
998
992
|
element = watir_page_object.heading6_element
|
999
|
-
element.
|
993
|
+
expect(element).to be_instance_of PageObject::Elements::Heading
|
1000
994
|
end
|
1001
995
|
end
|
1002
996
|
|
@@ -1004,98 +998,98 @@ describe PageObject::Accessors do
|
|
1004
998
|
describe "p accessors" do
|
1005
999
|
context "when called on a page object" do
|
1006
1000
|
it "should generate accessor methods" do
|
1007
|
-
watir_page_object.
|
1008
|
-
watir_page_object.
|
1001
|
+
expect(watir_page_object).to respond_to(:first_para)
|
1002
|
+
expect(watir_page_object).to respond_to(:first_para_element)
|
1009
1003
|
end
|
1010
1004
|
|
1011
1005
|
it "should call a block on the element method when present" do
|
1012
|
-
block_page_object.first_para_element.
|
1006
|
+
expect(block_page_object.first_para_element).to eql "p"
|
1013
1007
|
end
|
1014
1008
|
end
|
1015
1009
|
|
1016
1010
|
it "should retrieve the text from the p" do
|
1017
|
-
watir_browser.
|
1018
|
-
watir_browser.
|
1019
|
-
watir_page_object.first_para.
|
1011
|
+
expect(watir_browser).to receive(:p).and_return(watir_browser)
|
1012
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
1013
|
+
expect(watir_page_object.first_para).to eql "value"
|
1020
1014
|
end
|
1021
1015
|
|
1022
1016
|
it "should retrieve the element from the page" do
|
1023
|
-
watir_browser.
|
1017
|
+
expect(watir_browser).to receive(:p).and_return(watir_browser)
|
1024
1018
|
element = watir_page_object.first_para_element
|
1025
|
-
element.
|
1019
|
+
expect(element).to be_instance_of PageObject::Elements::Paragraph
|
1026
1020
|
end
|
1027
1021
|
end
|
1028
1022
|
|
1029
1023
|
describe "file_field accessors" do
|
1030
1024
|
context "when called on a page object" do
|
1031
1025
|
it "should generate accessor methods" do
|
1032
|
-
watir_page_object.
|
1033
|
-
watir_page_object.
|
1026
|
+
expect(watir_page_object).to respond_to(:upload_me=)
|
1027
|
+
expect(watir_page_object).to respond_to(:upload_me_element)
|
1034
1028
|
end
|
1035
1029
|
|
1036
1030
|
it "should call a block on the element method when present" do
|
1037
|
-
block_page_object.a_file_element.
|
1031
|
+
expect(block_page_object.a_file_element).to eql "file_field"
|
1038
1032
|
end
|
1039
1033
|
end
|
1040
1034
|
|
1041
1035
|
it "should set the file name" do
|
1042
|
-
watir_browser.
|
1043
|
-
watir_browser.
|
1036
|
+
expect(watir_browser).to receive(:file_field).and_return(watir_browser)
|
1037
|
+
expect(watir_browser).to receive(:set).with('some_file')
|
1044
1038
|
watir_page_object.upload_me = 'some_file'
|
1045
1039
|
end
|
1046
1040
|
|
1047
1041
|
it "should retrieve a text field element" do
|
1048
|
-
watir_browser.
|
1042
|
+
expect(watir_browser).to receive(:file_field).and_return(watir_browser)
|
1049
1043
|
element = watir_page_object.upload_me_element
|
1050
|
-
element.
|
1044
|
+
expect(element).to be_instance_of PageObject::Elements::FileField
|
1051
1045
|
end
|
1052
1046
|
end
|
1053
1047
|
|
1054
1048
|
describe "area accessors" do
|
1055
1049
|
context "when called on a page object" do
|
1056
1050
|
it "should generate accessor methods" do
|
1057
|
-
watir_page_object.
|
1058
|
-
watir_page_object.
|
1051
|
+
expect(watir_page_object).to respond_to(:img_area)
|
1052
|
+
expect(watir_page_object).to respond_to(:img_area_element)
|
1059
1053
|
end
|
1060
1054
|
|
1061
1055
|
it "should call a block on the element method when present" do
|
1062
|
-
block_page_object.img_area_element.
|
1056
|
+
expect(block_page_object.img_area_element).to eql "area"
|
1063
1057
|
end
|
1064
1058
|
end
|
1065
1059
|
|
1066
1060
|
it "should click on the area" do
|
1067
|
-
watir_browser.
|
1068
|
-
watir_browser.
|
1061
|
+
expect(watir_browser).to receive(:area).and_return(watir_browser)
|
1062
|
+
expect(watir_browser).to receive(:click)
|
1069
1063
|
watir_page_object.img_area
|
1070
1064
|
end
|
1071
1065
|
|
1072
1066
|
it "should retrieve the element from the page" do
|
1073
|
-
watir_browser.
|
1067
|
+
expect(watir_browser).to receive(:area).and_return(watir_browser)
|
1074
1068
|
element = watir_page_object.img_area_element
|
1075
|
-
element.
|
1069
|
+
expect(element).to be_instance_of PageObject::Elements::Area
|
1076
1070
|
end
|
1077
1071
|
end
|
1078
1072
|
|
1079
1073
|
describe "canvas accessors" do
|
1080
1074
|
context "when called on a page object" do
|
1081
1075
|
it "should generate accessor methods" do
|
1082
|
-
watir_page_object.
|
1076
|
+
expect(watir_page_object).to respond_to(:my_canvas_element)
|
1083
1077
|
end
|
1084
1078
|
|
1085
1079
|
it "should call a block on the element method when present" do
|
1086
|
-
block_page_object.my_canvas_element.
|
1080
|
+
expect(block_page_object.my_canvas_element).to eql "canvas"
|
1087
1081
|
end
|
1088
1082
|
end
|
1089
1083
|
end
|
1090
|
-
|
1084
|
+
|
1091
1085
|
describe "audio accessors" do
|
1092
1086
|
context "when called on a page object" do
|
1093
1087
|
it "should generate accessor methods" do
|
1094
|
-
watir_page_object.
|
1088
|
+
expect(watir_page_object).to respond_to(:acdc_element)
|
1095
1089
|
end
|
1096
1090
|
|
1097
1091
|
it "should call a block on the element method when present" do
|
1098
|
-
block_page_object.acdc_element.
|
1092
|
+
expect(block_page_object.acdc_element).to eql "audio"
|
1099
1093
|
end
|
1100
1094
|
end
|
1101
1095
|
end
|
@@ -1103,12 +1097,38 @@ describe PageObject::Accessors do
|
|
1103
1097
|
describe "video accessors" do
|
1104
1098
|
context "when called on a page object" do
|
1105
1099
|
it "should generate accessor methods" do
|
1106
|
-
watir_page_object.
|
1100
|
+
expect(watir_page_object).to respond_to(:movie_element)
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
it "should call a block on the element method when present" do
|
1104
|
+
expect(block_page_object.movie_element).to eql "video"
|
1105
|
+
end
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
describe "b accessors" do
|
1110
|
+
context "when called on a page object" do
|
1111
|
+
it "should generate accessor methods" do
|
1112
|
+
expect(watir_page_object).to respond_to(:bold)
|
1113
|
+
expect(watir_page_object).to respond_to(:bold_element)
|
1107
1114
|
end
|
1108
1115
|
|
1109
1116
|
it "should call a block on the element method when present" do
|
1110
|
-
block_page_object.
|
1117
|
+
expect(block_page_object.bold_element).to eql "b"
|
1111
1118
|
end
|
1112
1119
|
end
|
1120
|
+
|
1121
|
+
it "should retrieve the text from the b" do
|
1122
|
+
expect(watir_browser).to receive(:b).and_return(watir_browser)
|
1123
|
+
expect(watir_browser).to receive(:text).and_return("value")
|
1124
|
+
expect(watir_page_object.bold).to eql "value"
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
it "should retrieve the element from the page" do
|
1128
|
+
expect(watir_browser).to receive(:b).and_return(watir_browser)
|
1129
|
+
element = watir_page_object.bold_element
|
1130
|
+
expect(element).to be_instance_of PageObject::Elements::Bold
|
1131
|
+
end
|
1113
1132
|
end
|
1133
|
+
|
1114
1134
|
end
|