page_object 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (272) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -0
  7. data/ChangeLog +809 -0
  8. data/Gemfile +14 -0
  9. data/Guardfile +20 -0
  10. data/LICENSE +20 -0
  11. data/README.md +111 -0
  12. data/Rakefile +35 -0
  13. data/cucumber.yml +10 -0
  14. data/features/area.feature +35 -0
  15. data/features/async.feature +30 -0
  16. data/features/audio.feature +68 -0
  17. data/features/bold.feature +21 -0
  18. data/features/button.feature +98 -0
  19. data/features/canvas.feature +37 -0
  20. data/features/check_box.feature +55 -0
  21. data/features/div.feature +45 -0
  22. data/features/element.feature +322 -0
  23. data/features/file_field.feature +40 -0
  24. data/features/form.feature +43 -0
  25. data/features/frames.feature +75 -0
  26. data/features/generic_elements.feature +29 -0
  27. data/features/gxt_table_extension.feature +24 -0
  28. data/features/headings.feature +97 -0
  29. data/features/hidden_field.feature +45 -0
  30. data/features/html/04-Death_Becomes_Fur.mp4 +0 -0
  31. data/features/html/04-Death_Becomes_Fur.oga +0 -0
  32. data/features/html/async.html +36 -0
  33. data/features/html/double_click.html +13 -0
  34. data/features/html/failure.html +8 -0
  35. data/features/html/frame_1.html +18 -0
  36. data/features/html/frame_2.html +16 -0
  37. data/features/html/frame_3.html +14 -0
  38. data/features/html/frames.html +12 -0
  39. data/features/html/hover.html +12 -0
  40. data/features/html/iframes.html +12 -0
  41. data/features/html/images/circle.png +0 -0
  42. data/features/html/images/img_pulpit.jpg +0 -0
  43. data/features/html/images/submit.gif +0 -0
  44. data/features/html/indexed_property.html +55 -0
  45. data/features/html/modal.html +17 -0
  46. data/features/html/modal_1.html +38 -0
  47. data/features/html/modal_2.html +27 -0
  48. data/features/html/movie.mp4 +0 -0
  49. data/features/html/movie.ogg +0 -0
  50. data/features/html/multi_elements.html +144 -0
  51. data/features/html/nested_elements.html +77 -0
  52. data/features/html/nested_frame_1.html +1 -0
  53. data/features/html/nested_frame_2.html +11 -0
  54. data/features/html/nested_frame_3.html +14 -0
  55. data/features/html/nested_frames.html +10 -0
  56. data/features/html/planets.gif +0 -0
  57. data/features/html/static_elements.html +207 -0
  58. data/features/html/success.html +8 -0
  59. data/features/html/sun.gif +0 -0
  60. data/features/html/sun.html +7 -0
  61. data/features/image.feature +50 -0
  62. data/features/indexed_property.feature +117 -0
  63. data/features/javascript.feature +28 -0
  64. data/features/label.feature +46 -0
  65. data/features/link.feature +52 -0
  66. data/features/list_item.feature +36 -0
  67. data/features/modal_dialog.feature +15 -0
  68. data/features/multi_elements.feature +492 -0
  69. data/features/nested_elements.feature +117 -0
  70. data/features/ordered_list.feature +56 -0
  71. data/features/page_level_actions.feature +90 -0
  72. data/features/paragraph.feature +35 -0
  73. data/features/radio_button.feature +58 -0
  74. data/features/radio_button_group.feature +29 -0
  75. data/features/sample-app/public/jquery-1.3.2.js +4376 -0
  76. data/features/sample-app/public/jquery.html +30 -0
  77. data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
  78. data/features/sample-app/public/prototype.html +35 -0
  79. data/features/sample-app/sample_app.rb +35 -0
  80. data/features/section.feature +132 -0
  81. data/features/select_list.feature +86 -0
  82. data/features/span.feature +37 -0
  83. data/features/step_definitions/accessor_steps.rb +64 -0
  84. data/features/step_definitions/area_steps.rb +19 -0
  85. data/features/step_definitions/async_steps.rb +83 -0
  86. data/features/step_definitions/audio_steps.rb +27 -0
  87. data/features/step_definitions/bold_steps.rb +12 -0
  88. data/features/step_definitions/button_steps.rb +48 -0
  89. data/features/step_definitions/canvas_steps.rb +15 -0
  90. data/features/step_definitions/check_box_steps.rb +35 -0
  91. data/features/step_definitions/div_steps.rb +19 -0
  92. data/features/step_definitions/element_steps.rb +266 -0
  93. data/features/step_definitions/file_field_steps.rb +19 -0
  94. data/features/step_definitions/form_steps.rb +19 -0
  95. data/features/step_definitions/frames_steps.rb +159 -0
  96. data/features/step_definitions/generic_element_steps.rb +31 -0
  97. data/features/step_definitions/gxt_table_steps.rb +58 -0
  98. data/features/step_definitions/headings_steps.rb +12 -0
  99. data/features/step_definitions/hidden_field_steps.rb +27 -0
  100. data/features/step_definitions/image_steps.rb +27 -0
  101. data/features/step_definitions/indexed_property_steps.rb +163 -0
  102. data/features/step_definitions/javascript_steps.rb +53 -0
  103. data/features/step_definitions/label_steps.rb +19 -0
  104. data/features/step_definitions/link_steps.rb +40 -0
  105. data/features/step_definitions/list_item_steps.rb +19 -0
  106. data/features/step_definitions/modal_dialog_steps.rb +62 -0
  107. data/features/step_definitions/multi_elements_steps.rb +541 -0
  108. data/features/step_definitions/nested_elements_steps.rb +212 -0
  109. data/features/step_definitions/ordered_list_steps.rb +23 -0
  110. data/features/step_definitions/page_level_actions_steps.rb +135 -0
  111. data/features/step_definitions/page_traversal_steps.rb +4 -0
  112. data/features/step_definitions/paragraph_steps.rb +28 -0
  113. data/features/step_definitions/radio_button_group_steps.rb +36 -0
  114. data/features/step_definitions/radio_button_steps.rb +27 -0
  115. data/features/step_definitions/section_steps.rb +268 -0
  116. data/features/step_definitions/select_list_steps.rb +65 -0
  117. data/features/step_definitions/span_steps.rb +19 -0
  118. data/features/step_definitions/table_cell_steps.rb +15 -0
  119. data/features/step_definitions/table_row_steps.rb +23 -0
  120. data/features/step_definitions/table_steps.rb +70 -0
  121. data/features/step_definitions/text_area_steps.rb +35 -0
  122. data/features/step_definitions/text_field_steps.rb +35 -0
  123. data/features/step_definitions/unordered_list_steps.rb +23 -0
  124. data/features/step_definitions/video_steps.rb +45 -0
  125. data/features/support/ajax_text_environment.rb +26 -0
  126. data/features/support/env.rb +8 -0
  127. data/features/support/hooks.rb +8 -0
  128. data/features/support/page.rb +382 -0
  129. data/features/support/persistent_browser.rb +70 -0
  130. data/features/support/targets/firefox14_osx.rb +6 -0
  131. data/features/support/targets/firefox14_windows7.rb +6 -0
  132. data/features/support/url_helper.rb +57 -0
  133. data/features/table.feature +122 -0
  134. data/features/table_cell.feature +45 -0
  135. data/features/table_row.feature +43 -0
  136. data/features/text_area.feature +51 -0
  137. data/features/text_field.feature +70 -0
  138. data/features/unordered_list.feature +56 -0
  139. data/features/video.feature +73 -0
  140. data/lib/page-object.rb +421 -0
  141. data/lib/page-object/accessors.rb +1412 -0
  142. data/lib/page-object/core_ext/string.rb +5 -0
  143. data/lib/page-object/element_locators.rb +21 -0
  144. data/lib/page-object/elements.rb +60 -0
  145. data/lib/page-object/elements/area.rb +31 -0
  146. data/lib/page-object/elements/audio.rb +9 -0
  147. data/lib/page-object/elements/bold.rb +11 -0
  148. data/lib/page-object/elements/button.rb +35 -0
  149. data/lib/page-object/elements/canvas.rb +23 -0
  150. data/lib/page-object/elements/check_box.rb +37 -0
  151. data/lib/page-object/elements/div.rb +19 -0
  152. data/lib/page-object/elements/element.rb +226 -0
  153. data/lib/page-object/elements/file_field.rb +38 -0
  154. data/lib/page-object/elements/form.rb +36 -0
  155. data/lib/page-object/elements/heading.rb +15 -0
  156. data/lib/page-object/elements/hidden_field.rb +22 -0
  157. data/lib/page-object/elements/image.rb +36 -0
  158. data/lib/page-object/elements/label.rb +19 -0
  159. data/lib/page-object/elements/link.rb +46 -0
  160. data/lib/page-object/elements/list_item.rb +19 -0
  161. data/lib/page-object/elements/media.rb +45 -0
  162. data/lib/page-object/elements/option.rb +10 -0
  163. data/lib/page-object/elements/ordered_list.rb +50 -0
  164. data/lib/page-object/elements/paragraph.rb +9 -0
  165. data/lib/page-object/elements/radio_button.rb +37 -0
  166. data/lib/page-object/elements/select_list.rb +42 -0
  167. data/lib/page-object/elements/span.rb +19 -0
  168. data/lib/page-object/elements/table.rb +79 -0
  169. data/lib/page-object/elements/table_cell.rb +28 -0
  170. data/lib/page-object/elements/table_row.rb +50 -0
  171. data/lib/page-object/elements/text_area.rb +38 -0
  172. data/lib/page-object/elements/text_field.rb +42 -0
  173. data/lib/page-object/elements/unordered_list.rb +51 -0
  174. data/lib/page-object/elements/video.rb +18 -0
  175. data/lib/page-object/indexed_properties.rb +40 -0
  176. data/lib/page-object/javascript/angularjs.rb +14 -0
  177. data/lib/page-object/javascript/jquery.rb +14 -0
  178. data/lib/page-object/javascript/prototype.rb +14 -0
  179. data/lib/page-object/javascript/yui.rb +19 -0
  180. data/lib/page-object/javascript_framework_facade.rb +80 -0
  181. data/lib/page-object/loads_platform.rb +45 -0
  182. data/lib/page-object/locator_generator.rb +131 -0
  183. data/lib/page-object/nested_elements.rb +17 -0
  184. data/lib/page-object/page_factory.rb +108 -0
  185. data/lib/page-object/page_populator.rb +83 -0
  186. data/lib/page-object/platforms.rb +18 -0
  187. data/lib/page-object/platforms/selenium_webdriver.rb +30 -0
  188. data/lib/page-object/platforms/selenium_webdriver/button.rb +15 -0
  189. data/lib/page-object/platforms/selenium_webdriver/check_box.rb +29 -0
  190. data/lib/page-object/platforms/selenium_webdriver/element.rb +291 -0
  191. data/lib/page-object/platforms/selenium_webdriver/file_field.rb +16 -0
  192. data/lib/page-object/platforms/selenium_webdriver/form.rb +16 -0
  193. data/lib/page-object/platforms/selenium_webdriver/image.rb +28 -0
  194. data/lib/page-object/platforms/selenium_webdriver/link.rb +23 -0
  195. data/lib/page-object/platforms/selenium_webdriver/ordered_list.rb +39 -0
  196. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +1237 -0
  197. data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +22 -0
  198. data/lib/page-object/platforms/selenium_webdriver/select_list.rb +93 -0
  199. data/lib/page-object/platforms/selenium_webdriver/surrogate_selenium_element.rb +42 -0
  200. data/lib/page-object/platforms/selenium_webdriver/table.rb +42 -0
  201. data/lib/page-object/platforms/selenium_webdriver/table_row.rb +43 -0
  202. data/lib/page-object/platforms/selenium_webdriver/text_area.rb +17 -0
  203. data/lib/page-object/platforms/selenium_webdriver/text_field.rb +17 -0
  204. data/lib/page-object/platforms/selenium_webdriver/unordered_list.rb +39 -0
  205. data/lib/page-object/platforms/watir_webdriver.rb +30 -0
  206. data/lib/page-object/platforms/watir_webdriver/check_box.rb +29 -0
  207. data/lib/page-object/platforms/watir_webdriver/element.rb +249 -0
  208. data/lib/page-object/platforms/watir_webdriver/file_field.rb +16 -0
  209. data/lib/page-object/platforms/watir_webdriver/form.rb +16 -0
  210. data/lib/page-object/platforms/watir_webdriver/image.rb +22 -0
  211. data/lib/page-object/platforms/watir_webdriver/link.rb +15 -0
  212. data/lib/page-object/platforms/watir_webdriver/ordered_list.rb +35 -0
  213. data/lib/page-object/platforms/watir_webdriver/page_object.rb +1082 -0
  214. data/lib/page-object/platforms/watir_webdriver/radio_button.rb +22 -0
  215. data/lib/page-object/platforms/watir_webdriver/select_list.rb +74 -0
  216. data/lib/page-object/platforms/watir_webdriver/table.rb +38 -0
  217. data/lib/page-object/platforms/watir_webdriver/table_row.rb +37 -0
  218. data/lib/page-object/platforms/watir_webdriver/text_area.rb +23 -0
  219. data/lib/page-object/platforms/watir_webdriver/text_field.rb +16 -0
  220. data/lib/page-object/platforms/watir_webdriver/unordered_list.rb +36 -0
  221. data/lib/page-object/sections.rb +29 -0
  222. data/lib/page-object/version.rb +4 -0
  223. data/lib/page-object/widgets.rb +133 -0
  224. data/page_object.gemspec +31 -0
  225. data/pageobject.gems +1 -0
  226. data/spec/page-object/accessors_spec.rb +40 -0
  227. data/spec/page-object/element_locators_spec.rb +1122 -0
  228. data/spec/page-object/elements/area_spec.rb +45 -0
  229. data/spec/page-object/elements/bold_spec.rb +29 -0
  230. data/spec/page-object/elements/button_spec.rb +64 -0
  231. data/spec/page-object/elements/canvas_spec.rb +40 -0
  232. data/spec/page-object/elements/check_box_spec.rb +49 -0
  233. data/spec/page-object/elements/div_spec.rb +28 -0
  234. data/spec/page-object/elements/element_spec.rb +114 -0
  235. data/spec/page-object/elements/file_field_spec.rb +39 -0
  236. data/spec/page-object/elements/form_spec.rb +28 -0
  237. data/spec/page-object/elements/heading_spec.rb +48 -0
  238. data/spec/page-object/elements/hidden_field_spec.rb +28 -0
  239. data/spec/page-object/elements/image_spec.rb +66 -0
  240. data/spec/page-object/elements/label_spec.rb +29 -0
  241. data/spec/page-object/elements/link_spec.rb +49 -0
  242. data/spec/page-object/elements/list_item_spec.rb +29 -0
  243. data/spec/page-object/elements/nested_element_spec.rb +254 -0
  244. data/spec/page-object/elements/option_spec.rb +11 -0
  245. data/spec/page-object/elements/ordered_list_spec.rb +94 -0
  246. data/spec/page-object/elements/paragraph_spec.rb +27 -0
  247. data/spec/page-object/elements/select_list_spec.rb +142 -0
  248. data/spec/page-object/elements/selenium/radio_button_spec.rb +44 -0
  249. data/spec/page-object/elements/selenium/text_field_spec.rb +49 -0
  250. data/spec/page-object/elements/selenium_element_spec.rb +177 -0
  251. data/spec/page-object/elements/span_spec.rb +26 -0
  252. data/spec/page-object/elements/table_cell_spec.rb +21 -0
  253. data/spec/page-object/elements/table_row_spec.rb +70 -0
  254. data/spec/page-object/elements/table_spec.rb +98 -0
  255. data/spec/page-object/elements/text_area_spec.rb +39 -0
  256. data/spec/page-object/elements/unordered_list_spec.rb +94 -0
  257. data/spec/page-object/elements/watir_element_spec.rb +145 -0
  258. data/spec/page-object/javascript_framework_facade_spec.rb +61 -0
  259. data/spec/page-object/loads_platform_spec.rb +53 -0
  260. data/spec/page-object/page-object_spec.rb +407 -0
  261. data/spec/page-object/page_factory_spec.rb +238 -0
  262. data/spec/page-object/page_populator_spec.rb +122 -0
  263. data/spec/page-object/page_section_spec.rb +73 -0
  264. data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +68 -0
  265. data/spec/page-object/platforms/selenium_webdriver_spec.rb +29 -0
  266. data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +29 -0
  267. data/spec/page-object/platforms/watir_webdriver_spec.rb +9 -0
  268. data/spec/page-object/selenium_accessors_spec.rb +609 -0
  269. data/spec/page-object/watir_accessors_spec.rb +1134 -0
  270. data/spec/page-object/widget_spec.rb +226 -0
  271. data/spec/spec_helper.rb +47 -0
  272. metadata +601 -0
@@ -0,0 +1,1134 @@
1
+ require 'spec_helper'
2
+
3
+ class WatirAccessorsTestPageObject
4
+ include PageObject
5
+
6
+ page_url "http://apple.com"
7
+ expected_title "Expected Title"
8
+ expected_element :google_search
9
+ link(:google_search, :link => 'Google Search')
10
+ text_field(:first_name, :id => 'first_name')
11
+ hidden_field(:social_security_number, :id => 'ssn')
12
+ text_area(:address, :id => 'address')
13
+ select_list(:state, :id => 'state')
14
+ checkbox(:active, :id => 'is_active_id')
15
+ radio_button(:first, :id => 'first_choice')
16
+ button(:click_me, :id => 'button_submit')
17
+ div(:message, :id => 'message_id')
18
+ table(:cart, :id => 'cart_id')
19
+ cell(:total, :id => 'total')
20
+ span(:alert_span, :id => 'alert_id')
21
+ image(:logo, :id => 'logo')
22
+ form(:login, :id => 'login')
23
+ list_item(:item_one, :id => 'one')
24
+ unordered_list(:menu, :id => 'main_menu')
25
+ ordered_list(:top_five, :id => 'top')
26
+ h1(:heading1, :id => 'main_heading')
27
+ h2(:heading2, :id => 'main_heading')
28
+ h3(:heading3, :id => 'main_heading')
29
+ h4(:heading4, :id => 'main_heading')
30
+ h5(:heading5, :id => 'main_heading')
31
+ h6(:heading6, :id => 'main_heading')
32
+ paragraph(:first_para, :id => 'first')
33
+ file_field(:upload_me, :id => 'the_file')
34
+ area(:img_area, :id => 'area')
35
+ canvas(:my_canvas, :id => 'canvas_id')
36
+ audio(:acdc, :id => 'audio_id')
37
+ video(:movie, :id => 'video_id')
38
+ b(:bold,:id=>'bold')
39
+ end
40
+
41
+ class WatirBlockPageObject
42
+ include PageObject
43
+
44
+ attr_reader :value
45
+
46
+ text_field :first_name do |element|
47
+ "text_field"
48
+ end
49
+ hidden_field :secret do |element|
50
+ "hidden_field"
51
+ end
52
+ text_area :address do |element|
53
+ "text_area"
54
+ end
55
+ select_list :state do |element|
56
+ "select_list"
57
+ end
58
+ link :continue do |element|
59
+ "link"
60
+ end
61
+ checkbox :active do |element|
62
+ "checkbox"
63
+ end
64
+ radio_button :first do |element|
65
+ "radio_button"
66
+ end
67
+ button :click_me do |element|
68
+ "button"
69
+ end
70
+ div :footer do |element|
71
+ "div"
72
+ end
73
+ span :alert_span do |element|
74
+ "span"
75
+ end
76
+ table :cart do |element|
77
+ "table"
78
+ end
79
+ cell :total do |element|
80
+ "cell"
81
+ end
82
+ image :logo do |element|
83
+ "image"
84
+ end
85
+ form :login do |element|
86
+ "form"
87
+ end
88
+ list_item :item_one do |element|
89
+ "list_item"
90
+ end
91
+ unordered_list :menu do |element|
92
+ "unordered_list"
93
+ end
94
+ ordered_list :top_five do |element|
95
+ "ordered_list"
96
+ end
97
+ h1 :heading1 do |element|
98
+ "h1"
99
+ end
100
+ h2 :heading2 do |element|
101
+ "h2"
102
+ end
103
+ h3 :heading3 do |element|
104
+ "h3"
105
+ end
106
+ h4 :heading4 do |element|
107
+ "h4"
108
+ end
109
+ h5 :heading5 do |element|
110
+ "h5"
111
+ end
112
+ h6 :heading6 do |element|
113
+ "h6"
114
+ end
115
+ paragraph :first_para do |element|
116
+ "p"
117
+ end
118
+ file_field :a_file do |element|
119
+ "file_field"
120
+ end
121
+ area :img_area do |element|
122
+ "area"
123
+ end
124
+ canvas :my_canvas do |element|
125
+ "canvas"
126
+ end
127
+ audio :acdc do |element|
128
+ "audio"
129
+ end
130
+ video :movie do |element|
131
+ "video"
132
+ end
133
+ b :bold do |element|
134
+ "b"
135
+ end
136
+ end
137
+
138
+ describe PageObject::Accessors do
139
+ let(:watir_browser) { mock_watir_browser }
140
+ let(:watir_page_object) { WatirAccessorsTestPageObject.new(watir_browser) }
141
+ let(:block_page_object) { WatirBlockPageObject.new(watir_browser) }
142
+
143
+ context "goto a page" do
144
+
145
+ it "should navigate to a page when requested" do
146
+ expect(watir_browser).to receive(:goto)
147
+ WatirAccessorsTestPageObject.new(watir_browser, true)
148
+ end
149
+
150
+ it "should call a method when page_url called with a symbol" do
151
+ class SymbolPageUrl
152
+ include PageObject
153
+ page_url :custom_url
154
+
155
+ attr_reader :custom_url
156
+ def initialize(b, v, url)
157
+ @custom_url = url
158
+ super(b, v)
159
+ end
160
+ end
161
+ expect(watir_browser).to receive(:goto).with('custom')
162
+ SymbolPageUrl.new(watir_browser, true, 'custom')
163
+
164
+ expect(watir_browser).to receive(:goto).with('different')
165
+ SymbolPageUrl.new(watir_browser, true, 'different')
166
+ end
167
+
168
+ it "should not navigate to a page when not requested" do
169
+ expect(watir_browser).not_to receive(:goto)
170
+ WatirAccessorsTestPageObject.new(watir_browser)
171
+ end
172
+
173
+ it "should not navigate to a page when 'page_url' not specified" do
174
+ expect(watir_browser).not_to receive(:goto)
175
+ WatirBlockPageObject.new(watir_browser, true)
176
+ end
177
+
178
+ it "should provide the page url" do
179
+ expect(watir_page_object.page_url_value).to eql 'http://apple.com'
180
+ end
181
+ end
182
+
183
+ context "validating the page title" do
184
+ it "should validate the title" do
185
+ expect(watir_browser).to receive(:title).and_return("Expected Title")
186
+ expect(watir_page_object).to have_expected_title
187
+ end
188
+
189
+ it "should validate the by regexp" do
190
+ class RegexpExpectedTitle
191
+ include PageObject
192
+ expected_title /\w+ \w+/
193
+ end
194
+ expect(watir_browser).to receive(:title).and_return("Expected Title")
195
+ expect(RegexpExpectedTitle.new(watir_browser)).to have_expected_title
196
+ end
197
+
198
+ it "should raise error when it does not have expected title" do
199
+ expect(watir_browser).to receive(:title).once.and_return("Not Expected")
200
+ expect { watir_page_object.has_expected_title? }.to raise_error
201
+ end
202
+ end
203
+
204
+ context "validating the existence of an element" do
205
+ it "should validate an element exists" do
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)
208
+ watir_page_object.has_expected_element?
209
+ end
210
+
211
+ it "should handle non-existent elements gracefully" do
212
+ class FakePage
213
+ include PageObject
214
+ expected_element :foo
215
+ end
216
+ expect(FakePage.new(watir_browser)).not_to have_expected_element
217
+ end
218
+ end
219
+
220
+ context "using default identifiers" do
221
+ class WatirDefaultIdentifier
222
+ include PageObject
223
+ text_field(:default_tf)
224
+ hidden_field(:default_hf)
225
+ text_area(:default_ta)
226
+ select_list(:default_sl)
227
+ link(:default_link)
228
+ checkbox(:default_cb)
229
+ radio_button(:default_rb)
230
+ button(:default_but)
231
+ div(:default_div)
232
+ span(:default_span)
233
+ table(:default_tab)
234
+ cell(:default_cell)
235
+ image(:default_im)
236
+ form(:default_form)
237
+ list_item(:default_li)
238
+ unordered_list(:default_ul)
239
+ ordered_list(:default_ol)
240
+ h1(:default_h1)
241
+ h2(:default_h2)
242
+ h3(:default_h3)
243
+ h4(:default_h4)
244
+ h5(:default_h5)
245
+ h6(:default_h6)
246
+ paragraph(:default_p)
247
+ file_field(:default_ff)
248
+ label(:default_lab)
249
+ element(:default_el, :audio)
250
+ end
251
+
252
+ let(:default_identifier) { WatirDefaultIdentifier.new(watir_browser) }
253
+
254
+ def mock_driver_for(tag)
255
+ expect(watir_browser).to receive(tag).with(:index => 0).and_return(watir_browser)
256
+ end
257
+
258
+ it "should work with a text_field" do
259
+ mock_driver_for :text_field
260
+ default_identifier.default_tf?
261
+ end
262
+
263
+ it "should work with a hidden field" do
264
+ mock_driver_for :hidden
265
+ default_identifier.default_hf?
266
+ end
267
+
268
+ it "should work with a text area" do
269
+ mock_driver_for :textarea
270
+ default_identifier.default_ta?
271
+ end
272
+
273
+ it "should work with a select list" do
274
+ mock_driver_for :select_list
275
+ default_identifier.default_sl?
276
+ end
277
+
278
+ it "should work with a link" do
279
+ mock_driver_for :link
280
+ default_identifier.default_link?
281
+ end
282
+
283
+ it "should work with a checkbox" do
284
+ mock_driver_for :checkbox
285
+ default_identifier.default_cb?
286
+ end
287
+
288
+ it "should work with a radio button" do
289
+ mock_driver_for :radio
290
+ default_identifier.default_rb?
291
+ end
292
+
293
+ it "should work with a button" do
294
+ mock_driver_for :button
295
+ default_identifier.default_but?
296
+ end
297
+
298
+ it "should work with a div" do
299
+ mock_driver_for :div
300
+ default_identifier.default_div?
301
+ end
302
+
303
+ it "should work with a span" do
304
+ mock_driver_for :span
305
+ default_identifier.default_span?
306
+ end
307
+
308
+ it "should work for a table" do
309
+ mock_driver_for :table
310
+ expect(default_identifier.default_tab_element).not_to be_nil
311
+ end
312
+
313
+ it "should work for a cell" do
314
+ mock_driver_for :td
315
+ default_identifier.default_cell?
316
+ end
317
+
318
+ it "should work for an image" do
319
+ mock_driver_for :image
320
+ default_identifier.default_im?
321
+ end
322
+
323
+ it "should work for a form" do
324
+ mock_driver_for :form
325
+ default_identifier.default_form?
326
+ end
327
+
328
+ it "should work for a list item" do
329
+ mock_driver_for :li
330
+ default_identifier.default_li?
331
+ end
332
+
333
+ it "should work for unordered lists" do
334
+ mock_driver_for :ul
335
+ default_identifier.default_ul?
336
+ end
337
+
338
+ it "should work for ordered lists" do
339
+ mock_driver_for :ol
340
+ default_identifier.default_ol?
341
+ end
342
+
343
+ it "should work for h1" do
344
+ mock_driver_for :h1
345
+ default_identifier.default_h1?
346
+ end
347
+
348
+ it "should work for h2" do
349
+ mock_driver_for :h2
350
+ default_identifier.default_h2?
351
+ end
352
+
353
+ it "should work for h3" do
354
+ mock_driver_for :h3
355
+ default_identifier.default_h3?
356
+ end
357
+
358
+ it "should work for a h4" do
359
+ mock_driver_for :h4
360
+ default_identifier.default_h4?
361
+ end
362
+
363
+ it "should work for a h5" do
364
+ mock_driver_for :h5
365
+ default_identifier.default_h5?
366
+ end
367
+
368
+ it "should work for a h6" do
369
+ mock_driver_for :h6
370
+ default_identifier.default_h6?
371
+ end
372
+
373
+ it "should work with a paragraph" do
374
+ mock_driver_for :p
375
+ default_identifier.default_p?
376
+ end
377
+
378
+ it "should work with a file_field" do
379
+ mock_driver_for :file_field
380
+ default_identifier.default_ff?
381
+ end
382
+
383
+ it "should work with a label" do
384
+ mock_driver_for :label
385
+ default_identifier.default_lab?
386
+ end
387
+
388
+ it "should work with an element" do
389
+ mock_driver_for :audio
390
+ default_identifier.default_el?
391
+ end
392
+
393
+ end
394
+
395
+ context "link accessors" do
396
+ context "when called on a page object" do
397
+ it "should generate accessor methods" do
398
+ expect(watir_page_object).to respond_to(:google_search)
399
+ expect(watir_page_object).to respond_to(:google_search_element)
400
+ end
401
+
402
+ it "should call a block on the element method when present" do
403
+ expect(block_page_object.continue_element).to eql "link"
404
+ end
405
+ end
406
+
407
+ it "should select a link" do
408
+ expect(watir_browser).to receive_messages(link: watir_browser, click: watir_browser)
409
+ watir_page_object.google_search
410
+ end
411
+
412
+ it "should return a link element" do
413
+ expect(watir_browser).to receive(:link).and_return(watir_browser)
414
+ element = watir_page_object.google_search_element
415
+ expect(element).to be_instance_of PageObject::Elements::Link
416
+ end
417
+ end
418
+
419
+
420
+ describe "text_field accessors" do
421
+ context "when called on a page object" do
422
+ it "should generate accessor methods" do
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?)
427
+ end
428
+
429
+ it "should call a block on the element method when present" do
430
+ expect(block_page_object.first_name_element).to eql "text_field"
431
+ end
432
+ end
433
+
434
+ it "should get the text from the text field element" do
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'
438
+ end
439
+
440
+ it "should set some text on a text field element" do
441
+ expect(watir_browser).to receive(:text_field).and_return(watir_browser)
442
+ expect(watir_browser).to receive(:set).with('Kim')
443
+ watir_page_object.first_name = 'Kim'
444
+ end
445
+
446
+ it "should retrieve a text field element" do
447
+ expect(watir_browser).to receive(:text_field).and_return(watir_browser)
448
+ element = watir_page_object.first_name_element
449
+ expect(element).to be_instance_of PageObject::Elements::TextField
450
+ end
451
+ end
452
+
453
+
454
+ describe "hidden field accessors" do
455
+ context "when called on a page object" do
456
+ it "should generate accessor methods" do
457
+ expect(watir_page_object).to respond_to(:social_security_number)
458
+ expect(watir_page_object).to respond_to(:social_security_number_element)
459
+ end
460
+
461
+ it "should call a block on the element method when present" do
462
+ expect(block_page_object.secret_element).to eql "hidden_field"
463
+ end
464
+ end
465
+
466
+ it "should get the text from a hidden field" do
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"
470
+ end
471
+
472
+ it "should retrieve a hidden field element" do
473
+ expect(watir_browser).to receive(:hidden).and_return(watir_browser)
474
+ element = watir_page_object.social_security_number_element
475
+ expect(element).to be_instance_of(PageObject::Elements::HiddenField)
476
+ end
477
+ end
478
+
479
+ describe "text area accessors" do
480
+ context "when called on a page object" do
481
+ it "should generate accessor methods" do
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)
485
+ end
486
+
487
+ it "should call a block on the element method when present" do
488
+ expect(block_page_object.address_element).to eql "text_area"
489
+ end
490
+ end
491
+
492
+ it "should set some text on the text area" do
493
+ expect(watir_browser).to receive(:textarea).and_return(watir_browser)
494
+ expect(watir_browser).to receive(:set).with("123 main street")
495
+ watir_page_object.address = "123 main street"
496
+ end
497
+
498
+ it "should get the text from the text area" do
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"
502
+ end
503
+
504
+ it "should retrieve a text area element" do
505
+ expect(watir_browser).to receive(:textarea).and_return(watir_browser)
506
+ element = watir_page_object.address_element
507
+ expect(element).to be_instance_of PageObject::Elements::TextArea
508
+ end
509
+ end
510
+
511
+ describe "select_list accessors" do
512
+ context "when called on a page object" do
513
+ it "should generate accessor methods" do
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)
517
+ end
518
+
519
+ it "should call a block on the element method when present" do
520
+ expect(block_page_object.state_element).to eql "select_list"
521
+ end
522
+ end
523
+
524
+ it "should get the current item from a select list" do
525
+ selected = "OH"
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"
531
+ end
532
+
533
+ it "should set the current item of a select list" do
534
+ expect(watir_browser).to receive(:select_list).and_return watir_browser
535
+ expect(watir_browser).to receive(:select).with("OH")
536
+ watir_page_object.state = "OH"
537
+ end
538
+
539
+ it "should retreive the select list element" do
540
+ expect(watir_browser).to receive(:select_list).and_return(watir_browser)
541
+ element = watir_page_object.state_element
542
+ expect(element).to be_instance_of PageObject::Elements::SelectList
543
+ end
544
+
545
+ it "should return list of selection options" do
546
+ option1 = double('option')
547
+ option2 = double('option')
548
+ expect(option1).to receive(:text).and_return("CA")
549
+ expect(option2).to receive(:text).and_return("OH")
550
+
551
+ select_element = double("select")
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"]
556
+ end
557
+ end
558
+
559
+ describe "check_box accessors" do
560
+ context "when called on a page object" do
561
+ it "should generate accessor methods" do
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
566
+ end
567
+
568
+ it "should call a block on the element method when present" do
569
+ expect(block_page_object.active_element).to eql "checkbox"
570
+ end
571
+ end
572
+
573
+ it "should check a check box element" do
574
+ expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
575
+ expect(watir_browser).to receive(:set)
576
+ watir_page_object.check_active
577
+ end
578
+
579
+ it "should clear a check box element" do
580
+ expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
581
+ expect(watir_browser).to receive(:clear)
582
+ watir_page_object.uncheck_active
583
+ end
584
+
585
+ it "should know if a check box element is selected" do
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
589
+ end
590
+
591
+ it "should retrieve a checkbox element" do
592
+ expect(watir_browser).to receive(:checkbox).and_return(watir_browser)
593
+ element = watir_page_object.active_element
594
+ expect(element).to be_instance_of PageObject::Elements::CheckBox
595
+ end
596
+ end
597
+
598
+
599
+ describe "radio accessors" do
600
+ context "when called on a page object" do
601
+ it "should generate accessor methods" do
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
+ end
606
+
607
+ it "should call a block on the element method when present" do
608
+ expect(block_page_object.first_element).to eql "radio_button"
609
+ end
610
+ end
611
+
612
+ it "should select a radio button" do
613
+ expect(watir_browser).to receive(:radio).and_return(watir_browser)
614
+ expect(watir_browser).to receive(:set)
615
+ watir_page_object.select_first
616
+ end
617
+
618
+ it "should determine if a radio is selected" do
619
+ expect(watir_browser).to receive(:radio).and_return(watir_browser)
620
+ expect(watir_browser).to receive(:set?)
621
+ watir_page_object.first_selected?
622
+ end
623
+
624
+ it "should retrieve a radio button element" do
625
+ expect(watir_browser).to receive(:radio).and_return(watir_browser)
626
+ element = watir_page_object.first_element
627
+ expect(element).to be_instance_of PageObject::Elements::RadioButton
628
+ end
629
+ end
630
+
631
+ describe "button accessors" do
632
+ context "when called on a page object" do
633
+ it "should generate accessor methods" do
634
+ expect(watir_page_object).to respond_to :click_me
635
+ expect(watir_page_object).to respond_to :click_me_element
636
+ end
637
+
638
+ it "should call a block on the element method when present" do
639
+ expect(block_page_object.click_me_element).to eql "button"
640
+ end
641
+ end
642
+
643
+ it "should be able to click a button" do
644
+ expect(watir_browser).to receive(:button).and_return(watir_browser)
645
+ expect(watir_browser).to receive(:click)
646
+ watir_page_object.click_me
647
+ end
648
+
649
+ it "should retrieve a button element" do
650
+ expect(watir_browser).to receive(:button).and_return(watir_browser)
651
+ element = watir_page_object.click_me_element
652
+ expect(element).to be_instance_of PageObject::Elements::Button
653
+ end
654
+ end
655
+
656
+ describe "div accessors" do
657
+ context "when called on a page object" do
658
+ it "should generate accessor methods" do
659
+ expect(watir_page_object).to respond_to(:message)
660
+ expect(watir_page_object).to respond_to(:message_element)
661
+ end
662
+
663
+ it "should call a block on the element method when present" do
664
+ expect(block_page_object.footer_element).to eql "div"
665
+ end
666
+ end
667
+
668
+ it "should retrieve the text from a div" do
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"
672
+ end
673
+
674
+ it "should retrieve the div element from the page" do
675
+ expect(watir_browser).to receive(:div).and_return(watir_browser)
676
+ element = watir_page_object.message_element
677
+ expect(element).to be_instance_of PageObject::Elements::Div
678
+ end
679
+ end
680
+
681
+ describe "span accessors" do
682
+ context "when called on a page object" do
683
+ it "should generate accessor methods" do
684
+ expect(watir_page_object).to respond_to(:alert_span)
685
+ expect(watir_page_object).to respond_to(:alert_span_element)
686
+ end
687
+
688
+ it "should call a block on the element method when present" do
689
+ expect(block_page_object.alert_span_element).to eql "span"
690
+ end
691
+ end
692
+
693
+ it "should retrieve the text from a span" do
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"
697
+ end
698
+
699
+ it "should retrieve the span element from the page" do
700
+ expect(watir_browser).to receive(:span).and_return(watir_browser)
701
+ element = watir_page_object.alert_span_element
702
+ expect(element).to be_instance_of PageObject::Elements::Span
703
+ end
704
+ end
705
+
706
+ describe "table accessors" do
707
+ context "when called on a page object" do
708
+ it "should generate accessor methods" do
709
+ expect(watir_page_object).to respond_to(:cart)
710
+ expect(watir_page_object).to respond_to(:cart_element)
711
+ end
712
+
713
+ it "should call a block on the element method when present" do
714
+ expect(block_page_object.cart_element).to eql "table"
715
+ end
716
+ end
717
+
718
+ it "should retrieve the table element from the page" do
719
+ expect(watir_browser).to receive(:table).and_return(watir_browser)
720
+ element = watir_page_object.cart_element
721
+ expect(element).to be_instance_of PageObject::Elements::Table
722
+ end
723
+ end
724
+
725
+ describe "table cell accessors" do
726
+ context "when called on a page object" do
727
+ it "should generate accessor methods" do
728
+ expect(watir_page_object).to respond_to(:total)
729
+ expect(watir_page_object).to respond_to(:total_element)
730
+ end
731
+
732
+ it "should call a block on the element method when present" do
733
+ expect(block_page_object.total_element).to eql "cell"
734
+ end
735
+ end
736
+
737
+ it "should retrieve the text for the cell" do
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'
741
+ end
742
+
743
+ it "should retrieve the cell element from the page" do
744
+ expect(watir_browser).to receive(:td).and_return(watir_browser)
745
+ element = watir_page_object.total_element
746
+ expect(element).to be_instance_of PageObject::Elements::TableCell
747
+ end
748
+ end
749
+
750
+ describe "image accessors" do
751
+ context "when called on a page object" do
752
+ it "should generate accessor methods" do
753
+ expect(watir_page_object).to respond_to(:logo_element)
754
+ end
755
+
756
+ it "should call a block on the element method when present" do
757
+ expect(block_page_object.logo_element).to eql "image"
758
+ end
759
+ end
760
+
761
+ it "should retrieve the image element from the page" do
762
+ expect(watir_browser).to receive(:image).and_return(watir_browser)
763
+ element = watir_page_object.logo_element
764
+ expect(element).to be_instance_of PageObject::Elements::Image
765
+ end
766
+ end
767
+
768
+ describe "form accessors" do
769
+ context "when called on a page object" do
770
+ it "should generate accessor methods" do
771
+ expect(watir_page_object).to respond_to(:login_element)
772
+ end
773
+
774
+ it "should call a block on the element method when present" do
775
+ expect(block_page_object.login_element).to eql "form"
776
+ end
777
+ end
778
+
779
+ it "should retrieve the form element from the page" do
780
+ expect(watir_browser).to receive(:form).and_return(watir_browser)
781
+ element = watir_page_object.login_element
782
+ expect(element).to be_instance_of PageObject::Elements::Form
783
+ end
784
+ end
785
+
786
+ describe "list item accessors" do
787
+ context "when called on a page object" do
788
+ it "should generate accessor methods" do
789
+ expect(watir_page_object).to respond_to(:item_one)
790
+ expect(watir_page_object).to respond_to(:item_one_element)
791
+ end
792
+
793
+ it "should call a block on the element method when present" do
794
+ expect(block_page_object.item_one_element).to eql "list_item"
795
+ end
796
+ end
797
+
798
+ it "should retrieve the text from the list item" do
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"
802
+ end
803
+
804
+ it "should retrieve the list item element from the page" do
805
+ expect(watir_browser).to receive(:li).and_return(watir_browser)
806
+ element = watir_page_object.item_one_element
807
+ expect(element).to be_instance_of PageObject::Elements::ListItem
808
+ end
809
+ end
810
+
811
+ describe "unordered list accessors" do
812
+ context "when called on a page object" do
813
+ it "should generate accessor methods" do
814
+ expect(watir_page_object).to respond_to(:menu_element)
815
+ end
816
+
817
+ it "should call a block on the element method when present" do
818
+ expect(block_page_object.menu_element).to eql "unordered_list"
819
+ end
820
+ end
821
+
822
+ it "should retrieve the element from the page" do
823
+ expect(watir_browser).to receive(:ul).and_return(watir_browser)
824
+ element = watir_page_object.menu_element
825
+ expect(element).to be_instance_of PageObject::Elements::UnorderedList
826
+ end
827
+ end
828
+
829
+ describe "ordered list accessors" do
830
+ context "when called on a page object" do
831
+ it "should generate accessor methods" do
832
+ expect(watir_page_object).to respond_to(:top_five_element)
833
+ end
834
+
835
+ it "should call a block on the element method when present" do
836
+ expect(block_page_object.top_five_element).to eql "ordered_list"
837
+ end
838
+ end
839
+
840
+ it "should retrieve the element from the page" do
841
+ expect(watir_browser).to receive(:ol).and_return(watir_browser)
842
+ element = watir_page_object.top_five_element
843
+ expect(element).to be_instance_of PageObject::Elements::OrderedList
844
+ end
845
+ end
846
+
847
+ describe "h1 accessors" do
848
+ context "when called on a page object" do
849
+ it "should generate accessor methods" do
850
+ expect(watir_page_object).to respond_to(:heading1)
851
+ expect(watir_page_object).to respond_to(:heading1_element)
852
+ end
853
+
854
+ it "should call a block on the element method when present" do
855
+ expect(block_page_object.heading1_element).to eql "h1"
856
+ end
857
+ end
858
+
859
+ it "should retrieve the text from the h1" do
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"
863
+ end
864
+
865
+ it "should retrieve the element from the page" do
866
+ expect(watir_browser).to receive(:h1).and_return(watir_browser)
867
+ element = watir_page_object.heading1_element
868
+ expect(element).to be_instance_of PageObject::Elements::Heading
869
+ end
870
+ end
871
+
872
+ describe "h2 accessors" do
873
+ context "when called on a page object" do
874
+ it "should generate accessor methods" do
875
+ expect(watir_page_object).to respond_to(:heading2)
876
+ expect(watir_page_object).to respond_to(:heading2_element)
877
+ end
878
+
879
+ it "should call a block on the element method when present" do
880
+ expect(block_page_object.heading2_element).to eql "h2"
881
+ end
882
+ end
883
+
884
+ it "should retrieve the text from the h2" do
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"
888
+ end
889
+
890
+ it "should retrieve the element from the page" do
891
+ expect(watir_browser).to receive(:h2).and_return(watir_browser)
892
+ element = watir_page_object.heading2_element
893
+ expect(element).to be_instance_of PageObject::Elements::Heading
894
+ end
895
+ end
896
+
897
+ describe "h3 accessors" do
898
+ context "when called on a page object" do
899
+ it "should generate accessor methods" do
900
+ expect(watir_page_object).to respond_to(:heading3)
901
+ expect(watir_page_object).to respond_to(:heading3_element)
902
+ end
903
+
904
+ it "should call a block on the element method when present" do
905
+ expect(block_page_object.heading3_element).to eql "h3"
906
+ end
907
+ end
908
+
909
+ it "should retrieve the text from the h3" do
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"
913
+ end
914
+
915
+ it "should retrieve the element from the page" do
916
+ expect(watir_browser).to receive(:h3).and_return(watir_browser)
917
+ element = watir_page_object.heading3_element
918
+ expect(element).to be_instance_of PageObject::Elements::Heading
919
+ end
920
+ end
921
+
922
+ describe "h4 accessors" do
923
+ context "when called on a page object" do
924
+ it "should generate accessor methods" do
925
+ expect(watir_page_object).to respond_to(:heading4)
926
+ expect(watir_page_object).to respond_to(:heading4_element)
927
+ end
928
+
929
+ it "should call a block on the element method when present" do
930
+ expect(block_page_object.heading4_element).to eql "h4"
931
+ end
932
+ end
933
+
934
+ it "should retrieve the text from the h4" do
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"
938
+ end
939
+
940
+ it "should retrieve the element from the page" do
941
+ expect(watir_browser).to receive(:h4).and_return(watir_browser)
942
+ element = watir_page_object.heading4_element
943
+ expect(element).to be_instance_of PageObject::Elements::Heading
944
+ end
945
+ end
946
+
947
+ describe "h5 accessors" do
948
+ context "when called on a page object" do
949
+ it "should generate accessor methods" do
950
+ expect(watir_page_object).to respond_to(:heading5)
951
+ expect(watir_page_object).to respond_to(:heading5_element)
952
+ end
953
+
954
+ it "should call a block on the element method when present" do
955
+ expect(block_page_object.heading5_element).to eql "h5"
956
+ end
957
+ end
958
+
959
+ it "should retrieve the text from the h5" do
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"
963
+ end
964
+
965
+ it "should retrieve the element from the page" do
966
+ expect(watir_browser).to receive(:h5).and_return(watir_browser)
967
+ element = watir_page_object.heading5_element
968
+ expect(element).to be_instance_of PageObject::Elements::Heading
969
+ end
970
+ end
971
+
972
+ describe "h6 accessors" do
973
+ context "when called on a page object" do
974
+ it "should generate accessor methods" do
975
+ expect(watir_page_object).to respond_to(:heading6)
976
+ expect(watir_page_object).to respond_to(:heading6_element)
977
+ end
978
+
979
+ it "should call a block on the element method when present" do
980
+ expect(block_page_object.heading6_element).to eql "h6"
981
+ end
982
+ end
983
+
984
+ it "should retrieve the text from the h6" do
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"
988
+ end
989
+
990
+ it "should retrieve the element from the page" do
991
+ expect(watir_browser).to receive(:h6).and_return(watir_browser)
992
+ element = watir_page_object.heading6_element
993
+ expect(element).to be_instance_of PageObject::Elements::Heading
994
+ end
995
+ end
996
+
997
+
998
+ describe "p accessors" do
999
+ context "when called on a page object" do
1000
+ it "should generate accessor methods" do
1001
+ expect(watir_page_object).to respond_to(:first_para)
1002
+ expect(watir_page_object).to respond_to(:first_para_element)
1003
+ end
1004
+
1005
+ it "should call a block on the element method when present" do
1006
+ expect(block_page_object.first_para_element).to eql "p"
1007
+ end
1008
+ end
1009
+
1010
+ it "should retrieve the text from the p" do
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"
1014
+ end
1015
+
1016
+ it "should retrieve the element from the page" do
1017
+ expect(watir_browser).to receive(:p).and_return(watir_browser)
1018
+ element = watir_page_object.first_para_element
1019
+ expect(element).to be_instance_of PageObject::Elements::Paragraph
1020
+ end
1021
+ end
1022
+
1023
+ describe "file_field accessors" do
1024
+ context "when called on a page object" do
1025
+ it "should generate accessor methods" do
1026
+ expect(watir_page_object).to respond_to(:upload_me=)
1027
+ expect(watir_page_object).to respond_to(:upload_me_element)
1028
+ end
1029
+
1030
+ it "should call a block on the element method when present" do
1031
+ expect(block_page_object.a_file_element).to eql "file_field"
1032
+ end
1033
+ end
1034
+
1035
+ it "should set the file name" do
1036
+ expect(watir_browser).to receive(:file_field).and_return(watir_browser)
1037
+ expect(watir_browser).to receive(:set).with('some_file')
1038
+ watir_page_object.upload_me = 'some_file'
1039
+ end
1040
+
1041
+ it "should retrieve a text field element" do
1042
+ expect(watir_browser).to receive(:file_field).and_return(watir_browser)
1043
+ element = watir_page_object.upload_me_element
1044
+ expect(element).to be_instance_of PageObject::Elements::FileField
1045
+ end
1046
+ end
1047
+
1048
+ describe "area accessors" do
1049
+ context "when called on a page object" do
1050
+ it "should generate accessor methods" do
1051
+ expect(watir_page_object).to respond_to(:img_area)
1052
+ expect(watir_page_object).to respond_to(:img_area_element)
1053
+ end
1054
+
1055
+ it "should call a block on the element method when present" do
1056
+ expect(block_page_object.img_area_element).to eql "area"
1057
+ end
1058
+ end
1059
+
1060
+ it "should click on the area" do
1061
+ expect(watir_browser).to receive(:area).and_return(watir_browser)
1062
+ expect(watir_browser).to receive(:click)
1063
+ watir_page_object.img_area
1064
+ end
1065
+
1066
+ it "should retrieve the element from the page" do
1067
+ expect(watir_browser).to receive(:area).and_return(watir_browser)
1068
+ element = watir_page_object.img_area_element
1069
+ expect(element).to be_instance_of PageObject::Elements::Area
1070
+ end
1071
+ end
1072
+
1073
+ describe "canvas accessors" do
1074
+ context "when called on a page object" do
1075
+ it "should generate accessor methods" do
1076
+ expect(watir_page_object).to respond_to(:my_canvas_element)
1077
+ end
1078
+
1079
+ it "should call a block on the element method when present" do
1080
+ expect(block_page_object.my_canvas_element).to eql "canvas"
1081
+ end
1082
+ end
1083
+ end
1084
+
1085
+ describe "audio accessors" do
1086
+ context "when called on a page object" do
1087
+ it "should generate accessor methods" do
1088
+ expect(watir_page_object).to respond_to(:acdc_element)
1089
+ end
1090
+
1091
+ it "should call a block on the element method when present" do
1092
+ expect(block_page_object.acdc_element).to eql "audio"
1093
+ end
1094
+ end
1095
+ end
1096
+
1097
+ describe "video accessors" do
1098
+ context "when called on a page object" do
1099
+ it "should generate accessor methods" do
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)
1114
+ end
1115
+
1116
+ it "should call a block on the element method when present" do
1117
+ expect(block_page_object.bold_element).to eql "b"
1118
+ end
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
1132
+ end
1133
+
1134
+ end