page-object 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -12
  3. data/ChangeLog +10 -0
  4. data/Gemfile +4 -2
  5. data/Guardfile +1 -1
  6. data/README.md +2 -2
  7. data/lib/page-object/accessors.rb +57 -35
  8. data/lib/page-object/elements/element.rb +26 -0
  9. data/lib/page-object/locator_generator.rb +46 -0
  10. data/lib/page-object/platforms/selenium_webdriver/element.rb +6 -6
  11. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +14 -0
  12. data/lib/page-object/platforms/watir_webdriver/element.rb +0 -7
  13. data/lib/page-object/platforms/watir_webdriver/page_object.rb +16 -3
  14. data/lib/page-object/version.rb +1 -1
  15. data/page-object.gemspec +7 -10
  16. metadata +34 -375
  17. data/features/area.feature +0 -35
  18. data/features/async.feature +0 -21
  19. data/features/audio.feature +0 -64
  20. data/features/bold.feature +0 -21
  21. data/features/button.feature +0 -98
  22. data/features/canvas.feature +0 -37
  23. data/features/check_box.feature +0 -55
  24. data/features/div.feature +0 -45
  25. data/features/element.feature +0 -343
  26. data/features/file_field.feature +0 -40
  27. data/features/form.feature +0 -43
  28. data/features/frames.feature +0 -75
  29. data/features/generic_elements.feature +0 -29
  30. data/features/gxt_table_extension.feature +0 -23
  31. data/features/headings.feature +0 -97
  32. data/features/hidden_field.feature +0 -45
  33. data/features/html/04-Death_Becomes_Fur.mp4 +0 -0
  34. data/features/html/04-Death_Becomes_Fur.oga +0 -0
  35. data/features/html/async.html +0 -36
  36. data/features/html/double_click.html +0 -13
  37. data/features/html/failure.html +0 -8
  38. data/features/html/frame_1.html +0 -18
  39. data/features/html/frame_2.html +0 -16
  40. data/features/html/frame_3.html +0 -14
  41. data/features/html/frames.html +0 -12
  42. data/features/html/hover.html +0 -12
  43. data/features/html/iframes.html +0 -12
  44. data/features/html/images/circle.png +0 -0
  45. data/features/html/images/img_pulpit.jpg +0 -0
  46. data/features/html/images/submit.gif +0 -0
  47. data/features/html/indexed_property.html +0 -55
  48. data/features/html/modal.html +0 -17
  49. data/features/html/modal_1.html +0 -38
  50. data/features/html/modal_2.html +0 -27
  51. data/features/html/movie.mp4 +0 -0
  52. data/features/html/movie.ogg +0 -0
  53. data/features/html/multi_elements.html +0 -145
  54. data/features/html/nested_elements.html +0 -77
  55. data/features/html/nested_frame_1.html +0 -1
  56. data/features/html/nested_frame_2.html +0 -11
  57. data/features/html/nested_frame_3.html +0 -14
  58. data/features/html/nested_frames.html +0 -10
  59. data/features/html/planets.gif +0 -0
  60. data/features/html/static_elements.html +0 -194
  61. data/features/html/success.html +0 -8
  62. data/features/html/sun.gif +0 -0
  63. data/features/html/sun.html +0 -7
  64. data/features/html/widgets.html +0 -20
  65. data/features/image.feature +0 -50
  66. data/features/indexed_property.feature +0 -117
  67. data/features/italic.feature +0 -21
  68. data/features/javascript.feature +0 -28
  69. data/features/label.feature +0 -46
  70. data/features/link.feature +0 -52
  71. data/features/list_item.feature +0 -36
  72. data/features/modal_dialog.feature +0 -15
  73. data/features/multi_elements.feature +0 -498
  74. data/features/nested_elements.feature +0 -117
  75. data/features/ordered_list.feature +0 -56
  76. data/features/page_level_actions.feature +0 -90
  77. data/features/paragraph.feature +0 -35
  78. data/features/radio_button.feature +0 -58
  79. data/features/radio_button_group.feature +0 -29
  80. data/features/sample-app/public/audio_video.html +0 -23
  81. data/features/sample-app/public/jquery-1.3.2.js +0 -4376
  82. data/features/sample-app/public/jquery.html +0 -30
  83. data/features/sample-app/public/prototype-1.6.0.3.js +0 -4320
  84. data/features/sample-app/public/prototype.html +0 -35
  85. data/features/sample-app/sample_app.rb +0 -35
  86. data/features/section.feature +0 -136
  87. data/features/select_list.feature +0 -86
  88. data/features/span.feature +0 -37
  89. data/features/step_definitions/accessor_steps.rb +0 -64
  90. data/features/step_definitions/area_steps.rb +0 -19
  91. data/features/step_definitions/async_steps.rb +0 -83
  92. data/features/step_definitions/audio_steps.rb +0 -27
  93. data/features/step_definitions/bold_steps.rb +0 -12
  94. data/features/step_definitions/button_steps.rb +0 -48
  95. data/features/step_definitions/canvas_steps.rb +0 -15
  96. data/features/step_definitions/check_box_steps.rb +0 -35
  97. data/features/step_definitions/div_steps.rb +0 -19
  98. data/features/step_definitions/element_steps.rb +0 -294
  99. data/features/step_definitions/file_field_steps.rb +0 -19
  100. data/features/step_definitions/form_steps.rb +0 -19
  101. data/features/step_definitions/frames_steps.rb +0 -159
  102. data/features/step_definitions/generic_element_steps.rb +0 -31
  103. data/features/step_definitions/gxt_table_steps.rb +0 -53
  104. data/features/step_definitions/headings_steps.rb +0 -12
  105. data/features/step_definitions/hidden_field_steps.rb +0 -27
  106. data/features/step_definitions/image_steps.rb +0 -27
  107. data/features/step_definitions/indexed_property_steps.rb +0 -163
  108. data/features/step_definitions/italic_steps.rb +0 -12
  109. data/features/step_definitions/javascript_steps.rb +0 -53
  110. data/features/step_definitions/label_steps.rb +0 -19
  111. data/features/step_definitions/link_steps.rb +0 -40
  112. data/features/step_definitions/list_item_steps.rb +0 -19
  113. data/features/step_definitions/modal_dialog_steps.rb +0 -62
  114. data/features/step_definitions/multi_elements_steps.rb +0 -554
  115. data/features/step_definitions/nested_elements_steps.rb +0 -212
  116. data/features/step_definitions/ordered_list_steps.rb +0 -23
  117. data/features/step_definitions/page_level_actions_steps.rb +0 -135
  118. data/features/step_definitions/page_traversal_steps.rb +0 -8
  119. data/features/step_definitions/paragraph_steps.rb +0 -28
  120. data/features/step_definitions/radio_button_group_steps.rb +0 -36
  121. data/features/step_definitions/radio_button_steps.rb +0 -27
  122. data/features/step_definitions/section_steps.rb +0 -277
  123. data/features/step_definitions/select_list_steps.rb +0 -65
  124. data/features/step_definitions/span_steps.rb +0 -19
  125. data/features/step_definitions/table_cell_steps.rb +0 -15
  126. data/features/step_definitions/table_row_steps.rb +0 -23
  127. data/features/step_definitions/table_steps.rb +0 -70
  128. data/features/step_definitions/text_area_steps.rb +0 -35
  129. data/features/step_definitions/text_field_steps.rb +0 -35
  130. data/features/step_definitions/unordered_list_steps.rb +0 -23
  131. data/features/step_definitions/video_steps.rb +0 -45
  132. data/features/support/ajax_text_environment.rb +0 -26
  133. data/features/support/audio_video_page.rb +0 -24
  134. data/features/support/env.rb +0 -8
  135. data/features/support/hooks.rb +0 -8
  136. data/features/support/page.rb +0 -373
  137. data/features/support/persistent_browser.rb +0 -70
  138. data/features/support/targets/firefox14_osx.rb +0 -6
  139. data/features/support/targets/firefox14_windows7.rb +0 -6
  140. data/features/support/url_helper.rb +0 -61
  141. data/features/table.feature +0 -122
  142. data/features/table_cell.feature +0 -45
  143. data/features/table_row.feature +0 -43
  144. data/features/text_area.feature +0 -51
  145. data/features/text_field.feature +0 -70
  146. data/features/unordered_list.feature +0 -56
  147. data/features/video.feature +0 -69
  148. data/spec/page-object/accessors_spec.rb +0 -40
  149. data/spec/page-object/element_locators_spec.rb +0 -1144
  150. data/spec/page-object/elements/area_spec.rb +0 -45
  151. data/spec/page-object/elements/bold_spec.rb +0 -29
  152. data/spec/page-object/elements/button_spec.rb +0 -64
  153. data/spec/page-object/elements/canvas_spec.rb +0 -41
  154. data/spec/page-object/elements/check_box_spec.rb +0 -49
  155. data/spec/page-object/elements/div_spec.rb +0 -28
  156. data/spec/page-object/elements/element_spec.rb +0 -196
  157. data/spec/page-object/elements/file_field_spec.rb +0 -39
  158. data/spec/page-object/elements/form_spec.rb +0 -28
  159. data/spec/page-object/elements/heading_spec.rb +0 -48
  160. data/spec/page-object/elements/hidden_field_spec.rb +0 -28
  161. data/spec/page-object/elements/image_spec.rb +0 -66
  162. data/spec/page-object/elements/italic_spec.rb +0 -29
  163. data/spec/page-object/elements/label_spec.rb +0 -29
  164. data/spec/page-object/elements/link_spec.rb +0 -49
  165. data/spec/page-object/elements/list_item_spec.rb +0 -29
  166. data/spec/page-object/elements/media_spec.rb +0 -63
  167. data/spec/page-object/elements/nested_element_spec.rb +0 -254
  168. data/spec/page-object/elements/option_spec.rb +0 -11
  169. data/spec/page-object/elements/ordered_list_spec.rb +0 -78
  170. data/spec/page-object/elements/paragraph_spec.rb +0 -27
  171. data/spec/page-object/elements/select_list_spec.rb +0 -142
  172. data/spec/page-object/elements/selenium/radio_button_spec.rb +0 -44
  173. data/spec/page-object/elements/selenium/text_field_spec.rb +0 -49
  174. data/spec/page-object/elements/selenium_element_spec.rb +0 -218
  175. data/spec/page-object/elements/span_spec.rb +0 -26
  176. data/spec/page-object/elements/table_cell_spec.rb +0 -21
  177. data/spec/page-object/elements/table_row_spec.rb +0 -70
  178. data/spec/page-object/elements/table_spec.rb +0 -98
  179. data/spec/page-object/elements/text_area_spec.rb +0 -39
  180. data/spec/page-object/elements/unordered_list_spec.rb +0 -77
  181. data/spec/page-object/elements/video_spec.rb +0 -33
  182. data/spec/page-object/elements/watir_element_spec.rb +0 -193
  183. data/spec/page-object/javascript_framework_facade_spec.rb +0 -61
  184. data/spec/page-object/loads_platform_spec.rb +0 -53
  185. data/spec/page-object/page-object_spec.rb +0 -435
  186. data/spec/page-object/page_factory_spec.rb +0 -238
  187. data/spec/page-object/page_populator_spec.rb +0 -122
  188. data/spec/page-object/page_section_spec.rb +0 -80
  189. data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +0 -68
  190. data/spec/page-object/platforms/selenium_webdriver_spec.rb +0 -29
  191. data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +0 -29
  192. data/spec/page-object/platforms/watir_webdriver_spec.rb +0 -9
  193. data/spec/page-object/selenium_accessors_spec.rb +0 -628
  194. data/spec/page-object/watir_accessors_spec.rb +0 -1191
  195. data/spec/page-object/widget_spec.rb +0 -226
  196. data/spec/spec_helper.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 441fe4c75e361d33bb3938c23b47d55701f83074
4
- data.tar.gz: 81d70fd600660240c761665482abed0eabde01bc
3
+ metadata.gz: 83096c48419028baf9d916c2f0c6baca18d821df
4
+ data.tar.gz: 96c9fac57d4606967a33a73780d638ad246ef3d4
5
5
  SHA512:
6
- metadata.gz: 312e009090468c99cde07ab1bdf51082018952303849f902846cfdf96c9cac8364fbb601d2f1d8db164bf54d326277aa0163c130f3dcedce1bc6b87929e7cb92
7
- data.tar.gz: ee8d3bcd265dfc90ecef27c3473a2010afeafb14a7c44907fcbac8165a3ec1dadaa2ba82a2e56270005ed9dfb4224c26a15c9a6de2095182a63d9a52927e050a
6
+ metadata.gz: dac077be6fe9e3e6a32ebc5357618ad811d6f7702787cceb0741fa9f9e279ee49c9882ee7f611b0260e852e14b1a6c4640e285f9af609ad49ae9156df3000fb3
7
+ data.tar.gz: 7e90d74a30d201603688e54779c2779a081b5f57154a1ceb87b623610c261eadf8a3f092ba09487c46039508c02736445792906db1ae49cf68aac719d2e89415
@@ -1,15 +1,25 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
1
+ sudo: required
2
+ dist: trusty
4
3
  rvm:
5
- - 2.0.0
6
- - 2.1
7
- - 2.2
8
- - jruby-19mode
9
-
4
+ - 2.2.5
5
+ - 2.3.1
6
+ cache: bundler
10
7
  before_script:
11
- - "export DISPLAY=:99.0"
12
- - "sh -e /etc/init.d/xvfb start"
8
+ - export CHROME_BIN=/usr/bin/google-chrome
9
+ - export DISPLAY=:99.0
10
+ - sh -e /etc/init.d/xvfb start
11
+ - sudo apt-get update
12
+ - sudo apt-get install -y libappindicator1 fonts-liberation
13
+ - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
14
+ - sudo dpkg -i google-chrome*.deb
15
+ - CHROMEDRIVER_VERSION=$(curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
16
+ - curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
17
+ - unzip chromedriver_linux64.zip
18
+ - chmod +x chromedriver
19
+ - sudo mv chromedriver /usr/local/bin
13
20
 
14
- script:
15
- - "bundle exec rake test_with_coveralls"
21
+ script: bundle exec rake $RAKE_TASK
22
+ env:
23
+ - RAKE_TASK=spec
24
+ - RAKE_TASK=features:watir_webdriver WATIR_BRANCH=master
25
+ - RAKE_TASK=features:selenium_webdriver
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ Version 1.2.1 / 2016-11-11
2
+ * Enhancements
3
+ * Added numerous missing element types
4
+ * Support for Selenium 3 (Thanks Titus Fortner)
5
+ * Added new generated method for Image - (name)_loaded? (Thanks joesho112358)
6
+ * Added CSS support for Watir (Thanks Titus Fortner)
7
+ * Added two new methods that check without throwing exception
8
+ - check_visible
9
+ - check_exists
10
+
1
11
  Version 1.2.0 / 2016-6-15
2
12
  * Enhancements
3
13
  * Added array methods to section collections (Thanks Cohen Carlisle)
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  # adding rake so travis-ci will build properly
4
4
  gem 'rake'
5
- gem 'fuubar', '>= 2.0.0'
6
- gem 'fuubar-cucumber', '>= 0.0.22'
7
5
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
8
6
  gem 'growl'
9
7
  gem 'guard-rspec'
@@ -12,5 +10,9 @@ gem 'guard-cucumber'
12
10
  gem 'net-http-persistent'
13
11
  gem 'coveralls', require: false
14
12
 
13
+ if ENV['WATIR_BRANCH']
14
+ gem 'watir', :git => 'https://github.com/watir/watir.git', :branch => ENV['WATIR_BRANCH']
15
+ end
16
+
15
17
 
16
18
  gemspec
data/Guardfile CHANGED
@@ -2,7 +2,7 @@
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
4
 
5
- guard :rspec, cmd: 'rspec --color --format Fuubar' do
5
+ guard :rspec, cmd: 'rspec --color --format documentation' do
6
6
  watch(%r{^spec/.+_spec\.rb$})
7
7
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
8
  watch(%r{^lib/page-object/platforms/(.+)/.+\.rb$}) do |m|
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Coverage Status](https://coveralls.io/repos/cheezy/page-object/badge.svg?nocache)](https://coveralls.io/r/cheezy/page-object)
6
6
 
7
7
 
8
- A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir-webdriver and selenium-webdriver.
8
+ A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir and selenium-webdriver.
9
9
 
10
10
  ## Documentation
11
11
 
@@ -80,7 +80,7 @@ login_page.login_with 'cheezy', 'secret'
80
80
  ````
81
81
 
82
82
  ### Creating your page object
83
- page-object supports both [watir-webdriver](https://github.com/jarib/watir-webdriver) and [selenium-webdriver](http://seleniumhq.org/docs/03_webdriver.html). The one used will be determined by which driver you pass into the constructor of your page object. The page object can be created like this:
83
+ page-object supports both [watir](https://github.com/watir/watir) and [selenium-webdriver](http://seleniumhq.org/docs/03_webdriver.html). The one used will be determined by which driver you pass into the constructor of your page object. The page object can be created like this:
84
84
 
85
85
  ````ruby
86
86
  browser = Watir::Browser.new :firefox
@@ -196,7 +196,7 @@ module PageObject
196
196
  # @param [Hash] identifier how we find a text field. You can use a multiple parameters
197
197
  # by combining of any of the following except xpath. The valid keys are:
198
198
  # * :class => Watir and Selenium
199
- # * :css => Selenium only
199
+ # * :css => Watir and Selenium
200
200
  # * :id => Watir and Selenium
201
201
  # * :index => Watir and Selenium
202
202
  # * :label => Watir and Selenium
@@ -232,7 +232,7 @@ module PageObject
232
232
  # @param [Hash] identifier how we find a hidden field. You can use a multiple parameters
233
233
  # by combining of any of the following except xpath. The valid keys are:
234
234
  # * :class => Watir and Selenium
235
- # * :css => Selenium only
235
+ # * :css => Watir and Selenium
236
236
  # * :id => Watir and Selenium
237
237
  # * :index => Watir and Selenium
238
238
  # * :name => Watir and Selenium
@@ -264,7 +264,7 @@ module PageObject
264
264
  # @param [Hash] identifier how we find a text area. You can use a multiple parameters
265
265
  # by combining of any of the following except xpath. The valid keys are:
266
266
  # * :class => Watir and Selenium
267
- # * :css => Selenium only
267
+ # * :css => Watir and Selenium
268
268
  # * :id => Watir and Selenium
269
269
  # * :index => Watir and Selenium
270
270
  # * :name => Watir and Selenium
@@ -300,7 +300,7 @@ module PageObject
300
300
  # @param [Hash] identifier how we find a select list. You can use a multiple parameters
301
301
  # by combining of any of the following except xpath. The valid keys are:
302
302
  # * :class => Watir and Selenium
303
- # * :css => Selenium only
303
+ # * :css => Watir and Selenium
304
304
  # * :id => Watir and Selenium
305
305
  # * :index => Watir and Selenium
306
306
  # * :name => Watir and Selenium
@@ -376,7 +376,7 @@ module PageObject
376
376
  # @param [Hash] identifier how we find a checkbox. You can use a multiple parameters
377
377
  # by combining of any of the following except xpath. The valid keys are:
378
378
  # * :class => Watir and Selenium
379
- # * :css => Selenium only
379
+ # * :css => Watir and Selenium
380
380
  # * :id => Watir and Selenium
381
381
  # * :index => Watir and Selenium
382
382
  # * :name => Watir and Selenium
@@ -416,7 +416,7 @@ module PageObject
416
416
  # @param [Hash] identifier how we find a radio button. You can use a multiple parameters
417
417
  # by combining of any of the following except xpath. The valid keys are:
418
418
  # * :class => Watir and Selenium
419
- # * :css => Selenium only
419
+ # * :css => Watir and Selenium
420
420
  # * :id => Watir and Selenium
421
421
  # * :index => Watir and Selenium
422
422
  # * :name => Watir and Selenium
@@ -591,7 +591,7 @@ module PageObject
591
591
  # @param [Hash] identifier how we find a table. You can use a multiple parameters
592
592
  # by combining of any of the following except xpath. The valid keys are:
593
593
  # * :class => Watir and Selenium
594
- # * :css => Selenium only
594
+ # * :css => Watir and Selenium
595
595
  # * :id => Watir and Selenium
596
596
  # * :index => Watir and Selenium
597
597
  # * :name => Watir and Selenium
@@ -625,7 +625,7 @@ module PageObject
625
625
  # * :name => Watir and Selenium
626
626
  # * :text => Watir and Selenium
627
627
  # * :xpath => Watir and Selenium
628
- # * :css => Selenium only
628
+ # * :css => Watir and Selenium
629
629
  # @param optional block to be invoked when element method is called
630
630
  #
631
631
  def cell(name, identifier={:index => 0}, &block)
@@ -668,19 +668,20 @@ module PageObject
668
668
  end
669
669
 
670
670
  #
671
- # adds two methods - one to retrieve the image element, and another to
672
- # check the image's existence.
671
+ # adds three methods - one to retrieve the image element, another to
672
+ # check the load status of the image, and another to check the
673
+ # image's existence.
673
674
  #
674
675
  # @example
675
676
  # image(:logo, :id => 'logo')
676
- # # will generate 'logo_element' and 'logo?' methods
677
+ # # will generate 'logo_element', 'logo_loaded?', and 'logo?' methods
677
678
  #
678
679
  # @param [Symbol] the name used for the generated methods
679
680
  # @param [Hash] identifier how we find an image. You can use a multiple parameters
680
681
  # by combining of any of the following except xpath. The valid keys are:
681
682
  # * :alt => Watir and Selenium
682
683
  # * :class => Watir and Selenium
683
- # * :css => Selenium only
684
+ # * :css => Watir and Selenium
684
685
  # * :id => Watir and Selenium
685
686
  # * :index => Watir and Selenium
686
687
  # * :name => Watir and Selenium
@@ -690,6 +691,10 @@ module PageObject
690
691
  #
691
692
  def image(name, identifier={:index => 0}, &block)
692
693
  standard_methods(name, identifier, 'image_for', &block)
694
+ define_method("#{name}_loaded?") do
695
+ return platform.image_loaded_for identifier.clone unless block_given?
696
+ self.send("#{name}_element").loaded?
697
+ end
693
698
  end
694
699
  alias_method :img, :image
695
700
 
@@ -706,7 +711,7 @@ module PageObject
706
711
  # by combining of any of the following except xpath. The valid keys are:
707
712
  # * :action => Watir and Selenium
708
713
  # * :class => Watir and Selenium
709
- # * :css => Selenium only
714
+ # * :css => Watir and Selenium
710
715
  # * :id => Watir and Selenium
711
716
  # * :index => Watir and Selenium
712
717
  # * :xpath => Watir and Selenium
@@ -759,7 +764,7 @@ module PageObject
759
764
  # @param [Hash] identifier how we find an unordered list. You can use a multiple parameters
760
765
  # by combining of any of the following except xpath. The valid keys are:
761
766
  # * :class => Watir and Selenium
762
- # * :css => Selenium only
767
+ # * :css => Watir and Selenium
763
768
  # * :id => Watir and Selenium
764
769
  # * :index => Watir and Selenium
765
770
  # * :name => Watir and Selenium
@@ -788,7 +793,7 @@ module PageObject
788
793
  # @param [Hash] identifier how we find an ordered list. You can use a multiple parameters
789
794
  # by combining of any of the following except xpath. The valid keys are:
790
795
  # * :class => Watir and Selenium
791
- # * :css => Selenium only
796
+ # * :css => Watir and Selenium
792
797
  # * :id => Watir and Selenium
793
798
  # * :index => Watir and Selenium
794
799
  # * :name => Watir and Selenium
@@ -1006,7 +1011,7 @@ module PageObject
1006
1011
  # @param [Hash] identifier how we find a file_field. You can use a multiple parameters
1007
1012
  # by combining of any of the following except xpath. The valid keys are:
1008
1013
  # * :class => Watir and Selenium
1009
- # * :css => Selenium only
1014
+ # * :css => Watir and Selenium
1010
1015
  # * :id => Watir and Selenium
1011
1016
  # * :index => Watir and Selenium
1012
1017
  # * :name => Watir and Selenium
@@ -1215,7 +1220,7 @@ module PageObject
1215
1220
  # @param [Hash] identifier how we find a svg. You can use a multiple parameters
1216
1221
  # by combining of any of the following except xpath. The valid keys are:
1217
1222
  # * :class => Watir and Selenium
1218
- # * :css => Selenium only
1223
+ # * :css => Watir and Selenium
1219
1224
  # * :id => Watir and Selenium
1220
1225
  # * :index => Watir and Selenium
1221
1226
  # * :name => Watir and Selenium
@@ -1240,7 +1245,7 @@ module PageObject
1240
1245
  # @param [Hash] identifier how we find an element. You can use a multiple parameters
1241
1246
  # by combining of any of the following except xpath. The valid keys are:
1242
1247
  # * :class => Watir and Selenium
1243
- # * :css => Selenium only
1248
+ # * :css => Watir and Selenium
1244
1249
  # * :id => Watir and Selenium
1245
1250
  # * :index => Watir and Selenium
1246
1251
  # * :name => Watir and Selenium
@@ -1248,21 +1253,25 @@ module PageObject
1248
1253
  # @param optional block to be invoked when element method is called
1249
1254
  #
1250
1255
  def element(name, tag=:element, identifier={ :index => 0 }, &block)
1251
- # default tag to :element
1252
- #
1253
- # element 'button', css: 'some css'
1254
1256
  #
1255
- # is the same as
1256
- #
1257
- # element 'button', :element, css: 'some css'
1257
+ # sets tag as element if not defined
1258
1258
  #
1259
1259
  if tag.is_a?(Hash)
1260
1260
  identifier = tag
1261
1261
  tag = :element
1262
1262
  end
1263
1263
 
1264
+ standard_methods(name, identifier, 'element_for', &block)
1265
+
1264
1266
  define_method("#{name}") do
1265
- self.send("#{name}_element").text
1267
+ element = self.send("#{name}_element")
1268
+
1269
+ %w(Button TextField Radio Hidden CheckBox FileField).each do |klass|
1270
+ next unless element.element.class.to_s == "Watir::#{klass}"
1271
+ self.class.send(klass.gsub(/(.)([A-Z])/,'\1_\2').downcase, name, identifier, &block)
1272
+ return self.send name
1273
+ end
1274
+ element.text
1266
1275
  end
1267
1276
  define_method("#{name}_element") do
1268
1277
  return call_block(&block) if block_given?
@@ -1271,6 +1280,24 @@ module PageObject
1271
1280
  define_method("#{name}?") do
1272
1281
  self.send("#{name}_element").exists?
1273
1282
  end
1283
+ define_method("#{name}=") do |value|
1284
+ element = self.send("#{name}_element")
1285
+
1286
+ klass = case element.element
1287
+ when Watir::TextField
1288
+ 'text_field'
1289
+ when Watir::TextArea
1290
+ 'text_area'
1291
+ when Watir::Select
1292
+ 'select_list'
1293
+ when Watir::FileField
1294
+ 'file_field'
1295
+ else
1296
+ raise "Can not set a #{element.element} element with #="
1297
+ end
1298
+ self.class.send(klass, name, identifier, &block)
1299
+ self.send("#{name}=", value)
1300
+ end
1274
1301
  end
1275
1302
 
1276
1303
  #
@@ -1286,7 +1313,7 @@ module PageObject
1286
1313
  # @param [Hash] identifier how we find an element. You can use a multiple parameters
1287
1314
  # by combining of any of the following except xpath. The valid keys are:
1288
1315
  # * :class => Watir and Selenium
1289
- # * :css => Selenium only
1316
+ # * :css => Watir and Selenium
1290
1317
  # * :id => Watir and Selenium
1291
1318
  # * :index => Watir and Selenium
1292
1319
  # * :name => Watir and Selenium
@@ -1294,13 +1321,8 @@ module PageObject
1294
1321
  # @param optional block to be invoked when element method is called
1295
1322
  #
1296
1323
  def elements(name, tag=:element, identifier={:index => 0}, &block)
1297
- # default tag to :element
1298
- #
1299
- # elements 'button', css: 'some css'
1300
1324
  #
1301
- # is the same as
1302
- #
1303
- # elements 'button', :element, css: 'some css'
1325
+ # sets tag as element if not defined
1304
1326
  #
1305
1327
  if tag.is_a?(Hash)
1306
1328
  identifier = tag
@@ -1325,7 +1347,7 @@ module PageObject
1325
1347
  # @param [Hash] identifier how we find an element. You can use multiple parameters
1326
1348
  # by combining of any of the following except xpath. The valid keys are:
1327
1349
  # * :class => Watir and Selenium
1328
- # * :css => Selenium only
1350
+ # * :css => Watir and Selenium
1329
1351
  # * :id => Watir and Selenium
1330
1352
  # * :index => Watir and Selenium
1331
1353
  # * :name => Watir and Selenium
@@ -1349,7 +1371,7 @@ module PageObject
1349
1371
  # @param [Hash] identifier how we find an element. You can use a multiple parameters
1350
1372
  # by combining of any of the following except xpath. The valid keys are:
1351
1373
  # * :class => Watir and Selenium
1352
- # * :css => Selenium only
1374
+ # * :css => Watir and Selenium
1353
1375
  # * :id => Watir and Selenium
1354
1376
  # * :index => Watir and Selenium
1355
1377
  # * :name => Watir and Selenium
@@ -1376,7 +1398,7 @@ module PageObject
1376
1398
  # @param [Hash] identifier how we find an element. You can use a multiple parameters
1377
1399
  # by combining of any of the following except xpath. The valid keys are:
1378
1400
  # * :class => Watir and Selenium
1379
- # * :css => Selenium only
1401
+ # * :css => Watir and Selenium
1380
1402
  # * :id => Watir and Selenium
1381
1403
  # * :index => Watir and Selenium
1382
1404
  # * :name => Watir and Selenium
@@ -70,6 +70,23 @@ module PageObject
70
70
  downcase}s"
71
71
  end
72
72
 
73
+ #
74
+ # Keeps checking until the element is visible
75
+ #
76
+ # @param [Integer] (defaults to: 5) seconds to wait before timing out
77
+ #
78
+ def check_visible(timeout=::PageObject.default_element_wait)
79
+ timed_loop(timeout) do |element|
80
+ element.visible?
81
+ end
82
+ end
83
+
84
+ def check_exists(timeout=::PageObject.default_element_wait)
85
+ timed_loop(timeout) do |element|
86
+ element.exists?
87
+ end
88
+ end
89
+
73
90
  # @private
74
91
  def self.watir_identifier_for identifier
75
92
  if should_build_watir_xpath(identifier)
@@ -245,6 +262,15 @@ module PageObject
245
262
 
246
263
  private
247
264
 
265
+ def timed_loop(timeout)
266
+ end_time = ::Time.now + timeout
267
+ until ::Time.now > end_time
268
+ result = yield(self)
269
+ return result if result
270
+ sleep 0.5
271
+ end
272
+ false
273
+ end
248
274
 
249
275
  def constantize_classname name
250
276
  name.split("::").inject(Object) { |k,n| k.const_get(n) }
@@ -3,71 +3,117 @@ module PageObject
3
3
 
4
4
  BASIC_ELEMENTS = [:abbr,
5
5
  :address,
6
+ :animate,
7
+ :animate_motion,
8
+ :animate_transform,
6
9
  :article,
7
10
  :as,
8
11
  :aside,
12
+ :base,
9
13
  :bdi,
10
14
  :bdo,
11
15
  :blockquote,
12
16
  :body,
13
17
  :br,
14
18
  :caption,
19
+ :circle,
15
20
  :cite,
16
21
  :code,
17
22
  :col,
18
23
  :colgroup,
19
24
  :command,
25
+ :cursor,
20
26
  :data,
21
27
  :datalist,
22
28
  :dd,
29
+ :defs,
23
30
  :del,
31
+ :desc,
24
32
  :details,
25
33
  :dfn,
26
34
  :dialog,
35
+ :discard,
27
36
  :dl,
28
37
  :dt,
38
+ :ellipse,
29
39
  :em,
30
40
  :embed,
31
41
  :fieldset,
32
42
  :figcaption,
33
43
  :figure,
44
+ :font,
34
45
  :footer,
46
+ :foreign_object,
47
+ :g,
35
48
  :head,
36
49
  :header,
37
50
  :hgroup,
38
51
  :hr,
52
+ :html,
39
53
  :ins,
40
54
  :kbd,
41
55
  :keygen,
42
56
  :legend,
57
+ :line,
58
+ :linear_gradient,
59
+ :main,
43
60
  :map,
44
61
  :mark,
62
+ :marker,
45
63
  :menu,
64
+ :menuitem,
65
+ :mesh_gradient,
66
+ :mesh_patch,
67
+ :mesh_row,
46
68
  :meta,
69
+ :metadata,
47
70
  :meter,
71
+ :mpath,
48
72
  :nav,
49
73
  :noscript,
50
74
  :object,
51
75
  :optgroup,
52
76
  :output,
77
+ :p,
53
78
  :param,
79
+ :path,
80
+ :pattern,
81
+ :polygon,
82
+ :polyline,
54
83
  :pre,
55
84
  :progress,
85
+ :q,
86
+ :radial_gradient,
87
+ :rect,
56
88
  :rp,
57
89
  :rt,
58
90
  :ruby,
91
+ :s,
59
92
  :samp,
93
+ :script,
60
94
  :section,
95
+ :set,
61
96
  :small,
97
+ :source,
98
+ :stop,
62
99
  :strong,
63
100
  :style,
64
101
  :sub,
65
102
  :summary,
66
103
  :sup,
104
+ :switch,
105
+ :symbol,
106
+ :template,
107
+ :text_path,
108
+ :thread,
67
109
  :time,
68
110
  :title,
69
111
  :track,
112
+ :tspan,
113
+ :u,
114
+ :use,
70
115
  :var,
116
+ :view,
71
117
  :wbr]
72
118
 
73
119