page-object 0.8.1 → 0.8.2

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 (36) hide show
  1. data/ChangeLog +39 -0
  2. data/Gemfile +1 -0
  3. data/Rakefile +2 -2
  4. data/cucumber.yml +4 -4
  5. data/features/element.feature +5 -0
  6. data/features/{sample-app/public → html}/04-Death_Becomes_Fur.mp4 +0 -0
  7. data/features/{sample-app/public → html}/04-Death_Becomes_Fur.oga +0 -0
  8. data/features/{sample-app/public → html}/movie.mp4 +0 -0
  9. data/features/{sample-app/public → html}/movie.ogg +0 -0
  10. data/features/html/static_elements.html +7 -7
  11. data/features/sample-app/sample_app.rb +1 -1
  12. data/features/step_definitions/element_steps.rb +7 -0
  13. data/features/step_definitions/image_steps.rb +1 -1
  14. data/features/step_definitions/javascript_steps.rb +8 -2
  15. data/features/support/persistent_browser.rb +56 -3
  16. data/features/support/targets/firefox14_osx.rb +6 -0
  17. data/features/support/targets/firefox14_windows7.rb +6 -0
  18. data/features/support/url_helper.rb +3 -1
  19. data/lib/page-object/accessors.rb +131 -1003
  20. data/lib/page-object/element_locators.rb +9 -1008
  21. data/lib/page-object/locator_generator.rb +77 -0
  22. data/lib/page-object/nested_elements.rb +7 -230
  23. data/lib/page-object/page_factory.rb +10 -6
  24. data/lib/page-object/platforms/selenium_webdriver/element.rb +7 -0
  25. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +2 -2
  26. data/lib/page-object/platforms/watir_webdriver/element.rb +7 -0
  27. data/lib/page-object/platforms/watir_webdriver/page_object.rb +2 -2
  28. data/lib/page-object/version.rb +1 -1
  29. data/spec/page-object/elements/selenium_element_spec.rb +5 -0
  30. data/spec/page-object/elements/watir_element_spec.rb +6 -0
  31. data/spec/page-object/page_factory_spec.rb +9 -0
  32. data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +29 -0
  33. data/spec/page-object/platforms/watir_webdriver_spec.rb +0 -24
  34. data/spec/page-object/selenium_accessors_spec.rb +14 -0
  35. data/spec/page-object/watir_accessors_spec.rb +16 -17
  36. metadata +19 -12
@@ -196,6 +196,15 @@ describe PageObject::PageFactory do
196
196
  @world.navigate_to(AnotherPage).class.should == AnotherPage
197
197
  end
198
198
 
199
+ it "should pass parameters to methods when navigating" do
200
+ pages = [[FactoryTestPage, :a_method, 'blah'], [AnotherPage, :b_method]]
201
+ PageObject::PageFactory.routes = {:default => pages}
202
+ fake_page = double('a_page')
203
+ FactoryTestPage.should_receive(:new).and_return(fake_page)
204
+ fake_page.should_receive(:a_method).with('blah')
205
+ @world.navigate_to(AnotherPage).class.should == AnotherPage
206
+ end
207
+
199
208
  it "should fail when it does not find a proper route" do
200
209
  PageObject::PageFactory.routes = {:default => ['a'], :another => ['b']}
201
210
  expect { @world.navigate_to(AnotherPage, :using => :no_route) }.to raise_error
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageObject::Platforms::WatirWebDriver do
4
+ describe "create page object" do
5
+ let(:browser) { double('browser') }
6
+ let(:subject) { PageObject::Platforms::WatirWebDriver.create_page_object(browser) }
7
+
8
+ it "should create a WatirPageObject" do
9
+ subject.should be_kind_of PageObject::Platforms::WatirWebDriver::PageObject
10
+ end
11
+
12
+ it "should give the watir page object the browser" do
13
+ subject.browser.should be browser
14
+ end
15
+ end
16
+
17
+ describe "is for?" do
18
+ it "should be true when the browser is Watir::Browser" do
19
+ browser = mock_watir_browser()
20
+ PageObject::Platforms::WatirWebDriver.is_for?(browser).should be true
21
+ end
22
+
23
+ it "should be false at any other point" do
24
+ browser = 'asdf'
25
+ PageObject::Platforms::WatirWebDriver.is_for?('asdf').should be false
26
+ end
27
+ end
28
+ end
29
+
@@ -6,28 +6,4 @@ describe PageObject::Platforms::WatirWebDriver do
6
6
  PageObject::Platforms.get[:watir_webdriver].should be PageObject::Platforms::WatirWebDriver
7
7
  end
8
8
 
9
- describe "create page object" do
10
- let(:browser) { double('browser') }
11
- let(:subject) { PageObject::Platforms::WatirWebDriver.create_page_object(browser) }
12
-
13
- it "should create a WatirPageObject" do
14
- subject.should be_kind_of PageObject::Platforms::WatirWebDriver::PageObject
15
- end
16
-
17
- it "should give the watir page object the browser" do
18
- subject.browser.should be browser
19
- end
20
- end
21
-
22
- describe "is for?" do
23
- it "should be true when the browser is Watir::Browser" do
24
- browser = mock_watir_browser()
25
- PageObject::Platforms::WatirWebDriver.is_for?(browser).should be true
26
- end
27
-
28
- it "should be false at any other point" do
29
- browser = 'asdf'
30
- PageObject::Platforms::WatirWebDriver.is_for?('asdf').should be false
31
- end
32
- end
33
9
  end
@@ -236,6 +236,20 @@ describe PageObject::Accessors do
236
236
  element = selenium_page_object.state_element
237
237
  element.should be_instance_of PageObject::Elements::SelectList
238
238
  end
239
+
240
+ it "should return list of selection options" do
241
+ option1 = double('option')
242
+ option2 = double('option')
243
+ option1.should_receive(:text).and_return("CA")
244
+ option2.should_receive(:text).and_return("OH")
245
+
246
+ select_element = double("select")
247
+ select_element.should_receive(:options).twice.and_return([option1, option2])
248
+ selenium_page_object.should_receive(:state_element).and_return(select_element)
249
+
250
+ selenium_page_object.state_options.should == ["CA","OH"]
251
+ end
252
+
239
253
  end
240
254
 
241
255
 
@@ -389,7 +389,6 @@ describe PageObject::Accessors do
389
389
  it "should generate accessor methods" do
390
390
  watir_page_object.should respond_to(:google_search)
391
391
  watir_page_object.should respond_to(:google_search_element)
392
- watir_page_object.should respond_to(:google_search_link)
393
392
  end
394
393
 
395
394
  it "should call a block on the element method when present" do
@@ -416,7 +415,6 @@ describe PageObject::Accessors do
416
415
  watir_page_object.should respond_to(:first_name)
417
416
  watir_page_object.should respond_to(:first_name=)
418
417
  watir_page_object.should respond_to(:first_name_element)
419
- watir_page_object.should respond_to(:first_name_text_field)
420
418
  watir_page_object.should respond_to(:first_name?)
421
419
  end
422
420
 
@@ -450,7 +448,6 @@ describe PageObject::Accessors do
450
448
  it "should generate accessor methods" do
451
449
  watir_page_object.should respond_to(:social_security_number)
452
450
  watir_page_object.should respond_to(:social_security_number_element)
453
- watir_page_object.should respond_to(:social_security_number_hidden_field)
454
451
  end
455
452
 
456
453
  it "should call a block on the element method when present" do
@@ -477,7 +474,6 @@ describe PageObject::Accessors do
477
474
  watir_page_object.should respond_to(:address)
478
475
  watir_page_object.should respond_to(:address=)
479
476
  watir_page_object.should respond_to(:address_element)
480
- watir_page_object.should respond_to(:address_text_area)
481
477
  end
482
478
 
483
479
  it "should call a block on the element method when present" do
@@ -510,7 +506,6 @@ describe PageObject::Accessors do
510
506
  watir_page_object.should respond_to :state
511
507
  watir_page_object.should respond_to :state=
512
508
  watir_page_object.should respond_to(:state_element)
513
- watir_page_object.should respond_to(:state_select_list)
514
509
  end
515
510
 
516
511
  it "should call a block on the element method when present" do
@@ -538,6 +533,21 @@ describe PageObject::Accessors do
538
533
  element = watir_page_object.state_element
539
534
  element.should be_instance_of PageObject::Elements::SelectList
540
535
  end
536
+
537
+ it "should return list of selection options" do
538
+ option1 = double('option')
539
+ option2 = double('option')
540
+ option1.should_receive(:text).and_return("CA")
541
+ option2.should_receive(:text).and_return("OH")
542
+
543
+ select_element = double("select")
544
+ select_element.should_receive(:options).twice.and_return([option1, option2])
545
+ watir_page_object.should_receive(:state_element).and_return(select_element)
546
+
547
+ watir_page_object.state_options.should == ["CA","OH"]
548
+ end
549
+
550
+
541
551
  end
542
552
 
543
553
 
@@ -548,7 +558,6 @@ describe PageObject::Accessors do
548
558
  watir_page_object.should respond_to :uncheck_active
549
559
  watir_page_object.should respond_to :active_checked?
550
560
  watir_page_object.should respond_to :active_element
551
- watir_page_object.should respond_to :active_checkbox
552
561
  end
553
562
 
554
563
  it "should call a block on the element method when present" do
@@ -589,7 +598,6 @@ describe PageObject::Accessors do
589
598
  watir_page_object.should respond_to :clear_first
590
599
  watir_page_object.should respond_to :first_selected?
591
600
  watir_page_object.should respond_to(:first_element)
592
- watir_page_object.should respond_to(:first_radio_button)
593
601
  end
594
602
 
595
603
  it "should call a block on the element method when present" do
@@ -627,7 +635,6 @@ describe PageObject::Accessors do
627
635
  it "should generate accessor methods" do
628
636
  watir_page_object.should respond_to :click_me
629
637
  watir_page_object.should respond_to :click_me_element
630
- watir_page_object.should respond_to :click_me_button
631
638
  end
632
639
 
633
640
  it "should call a block on the element method when present" do
@@ -653,7 +660,6 @@ describe PageObject::Accessors do
653
660
  it "should generate accessor methods" do
654
661
  watir_page_object.should respond_to(:message)
655
662
  watir_page_object.should respond_to(:message_element)
656
- watir_page_object.should respond_to(:message_div)
657
663
  end
658
664
 
659
665
  it "should call a block on the element method when present" do
@@ -679,7 +685,6 @@ describe PageObject::Accessors do
679
685
  it "should generate accessor methods" do
680
686
  watir_page_object.should respond_to(:alert)
681
687
  watir_page_object.should respond_to(:alert_element)
682
- watir_page_object.should respond_to(:alert_span)
683
688
  end
684
689
 
685
690
  it "should call a block on the element method when present" do
@@ -703,8 +708,8 @@ describe PageObject::Accessors do
703
708
  describe "table accessors" do
704
709
  context "when called on a page object" do
705
710
  it "should generate accessor methods" do
711
+ watir_page_object.should respond_to(:cart)
706
712
  watir_page_object.should respond_to(:cart_element)
707
- watir_page_object.should respond_to(:cart_table)
708
713
  end
709
714
 
710
715
  it "should call a block on the element method when present" do
@@ -724,7 +729,6 @@ describe PageObject::Accessors do
724
729
  it "should generate accessor methods" do
725
730
  watir_page_object.should respond_to(:total)
726
731
  watir_page_object.should respond_to(:total_element)
727
- watir_page_object.should respond_to(:total_cell)
728
732
  end
729
733
 
730
734
  it "should call a block on the element method when present" do
@@ -749,7 +753,6 @@ describe PageObject::Accessors do
749
753
  context "when called on a page object" do
750
754
  it "should generate accessor methods" do
751
755
  watir_page_object.should respond_to(:logo_element)
752
- watir_page_object.should respond_to(:logo_image)
753
756
  end
754
757
 
755
758
  it "should call a block on the element method when present" do
@@ -768,7 +771,6 @@ describe PageObject::Accessors do
768
771
  context "when called on a page object" do
769
772
  it "should generate accessor methods" do
770
773
  watir_page_object.should respond_to(:login_element)
771
- watir_page_object.should respond_to(:login_form)
772
774
  end
773
775
 
774
776
  it "should call a block on the element method when present" do
@@ -788,7 +790,6 @@ describe PageObject::Accessors do
788
790
  it "should generate accessor methods" do
789
791
  watir_page_object.should respond_to(:item_one)
790
792
  watir_page_object.should respond_to(:item_one_element)
791
- watir_page_object.should respond_to(:item_one_list_item)
792
793
  end
793
794
 
794
795
  it "should call a block on the element method when present" do
@@ -813,7 +814,6 @@ describe PageObject::Accessors do
813
814
  context "when called on a page object" do
814
815
  it "should generate accessor methods" do
815
816
  watir_page_object.should respond_to(:menu_element)
816
- watir_page_object.should respond_to(:menu_unordered_list)
817
817
  end
818
818
 
819
819
  it "should call a block on the element method when present" do
@@ -832,7 +832,6 @@ describe PageObject::Accessors do
832
832
  context "when called on a page object" do
833
833
  it "should generate accessor methods" do
834
834
  watir_page_object.should respond_to(:top_five_element)
835
- watir_page_object.should respond_to(:top_five_ordered_list)
836
835
  end
837
836
 
838
837
  it "should call a block on the element method when present" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-28 00:00:00.000000000 Z
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
@@ -140,6 +140,8 @@ files:
140
140
  - features/gxt_table_extension.feature
141
141
  - features/headings.feature
142
142
  - features/hidden_field.feature
143
+ - features/html/04-Death_Becomes_Fur.mp4
144
+ - features/html/04-Death_Becomes_Fur.oga
143
145
  - features/html/async.html
144
146
  - features/html/double_click.html
145
147
  - features/html/failure.html
@@ -155,6 +157,8 @@ files:
155
157
  - features/html/modal.html
156
158
  - features/html/modal_1.html
157
159
  - features/html/modal_2.html
160
+ - features/html/movie.mp4
161
+ - features/html/movie.ogg
158
162
  - features/html/multi_elements.html
159
163
  - features/html/nested_elements.html
160
164
  - features/html/nested_frame_1.html
@@ -179,12 +183,8 @@ files:
179
183
  - features/page_level_actions.feature
180
184
  - features/paragraph.feature
181
185
  - features/radio_button.feature
182
- - features/sample-app/public/04-Death_Becomes_Fur.mp4
183
- - features/sample-app/public/04-Death_Becomes_Fur.oga
184
186
  - features/sample-app/public/jquery-1.3.2.js
185
187
  - features/sample-app/public/jquery.html
186
- - features/sample-app/public/movie.mp4
187
- - features/sample-app/public/movie.ogg
188
188
  - features/sample-app/public/prototype-1.6.0.3.js
189
189
  - features/sample-app/public/prototype.html
190
190
  - features/sample-app/sample_app.rb
@@ -233,6 +233,8 @@ files:
233
233
  - features/support/hooks.rb
234
234
  - features/support/page.rb
235
235
  - features/support/persistent_browser.rb
236
+ - features/support/targets/firefox14_osx.rb
237
+ - features/support/targets/firefox14_windows7.rb
236
238
  - features/support/url_helper.rb
237
239
  - features/table.feature
238
240
  - features/table_cell.feature
@@ -280,6 +282,7 @@ files:
280
282
  - lib/page-object/javascript/yui.rb
281
283
  - lib/page-object/javascript_framework_facade.rb
282
284
  - lib/page-object/loads_platform.rb
285
+ - lib/page-object/locator_generator.rb
283
286
  - lib/page-object/nested_elements.rb
284
287
  - lib/page-object/page_factory.rb
285
288
  - lib/page-object/page_populator.rb
@@ -358,6 +361,7 @@ files:
358
361
  - spec/page-object/page_populator_spec.rb
359
362
  - spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb
360
363
  - spec/page-object/platforms/selenium_webdriver_spec.rb
364
+ - spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb
361
365
  - spec/page-object/platforms/watir_webdriver_spec.rb
362
366
  - spec/page-object/selenium_accessors_spec.rb
363
367
  - spec/page-object/watir_accessors_spec.rb
@@ -377,7 +381,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
377
381
  version: '0'
378
382
  segments:
379
383
  - 0
380
- hash: 1255390606004430784
384
+ hash: 2877571143837407410
381
385
  required_rubygems_version: !ruby/object:Gem::Requirement
382
386
  none: false
383
387
  requirements:
@@ -386,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
390
  version: '0'
387
391
  segments:
388
392
  - 0
389
- hash: 1255390606004430784
393
+ hash: 2877571143837407410
390
394
  requirements: []
391
395
  rubyforge_project: page-object
392
396
  rubygems_version: 1.8.24
@@ -409,6 +413,8 @@ test_files:
409
413
  - features/gxt_table_extension.feature
410
414
  - features/headings.feature
411
415
  - features/hidden_field.feature
416
+ - features/html/04-Death_Becomes_Fur.mp4
417
+ - features/html/04-Death_Becomes_Fur.oga
412
418
  - features/html/async.html
413
419
  - features/html/double_click.html
414
420
  - features/html/failure.html
@@ -424,6 +430,8 @@ test_files:
424
430
  - features/html/modal.html
425
431
  - features/html/modal_1.html
426
432
  - features/html/modal_2.html
433
+ - features/html/movie.mp4
434
+ - features/html/movie.ogg
427
435
  - features/html/multi_elements.html
428
436
  - features/html/nested_elements.html
429
437
  - features/html/nested_frame_1.html
@@ -448,12 +456,8 @@ test_files:
448
456
  - features/page_level_actions.feature
449
457
  - features/paragraph.feature
450
458
  - features/radio_button.feature
451
- - features/sample-app/public/04-Death_Becomes_Fur.mp4
452
- - features/sample-app/public/04-Death_Becomes_Fur.oga
453
459
  - features/sample-app/public/jquery-1.3.2.js
454
460
  - features/sample-app/public/jquery.html
455
- - features/sample-app/public/movie.mp4
456
- - features/sample-app/public/movie.ogg
457
461
  - features/sample-app/public/prototype-1.6.0.3.js
458
462
  - features/sample-app/public/prototype.html
459
463
  - features/sample-app/sample_app.rb
@@ -502,6 +506,8 @@ test_files:
502
506
  - features/support/hooks.rb
503
507
  - features/support/page.rb
504
508
  - features/support/persistent_browser.rb
509
+ - features/support/targets/firefox14_osx.rb
510
+ - features/support/targets/firefox14_windows7.rb
505
511
  - features/support/url_helper.rb
506
512
  - features/table.feature
507
513
  - features/table_cell.feature
@@ -546,6 +552,7 @@ test_files:
546
552
  - spec/page-object/page_populator_spec.rb
547
553
  - spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb
548
554
  - spec/page-object/platforms/selenium_webdriver_spec.rb
555
+ - spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb
549
556
  - spec/page-object/platforms/watir_webdriver_spec.rb
550
557
  - spec/page-object/selenium_accessors_spec.rb
551
558
  - spec/page-object/watir_accessors_spec.rb