page-object 0.5.5 → 0.6

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.
@@ -5,98 +5,194 @@ module PageObject
5
5
  @platform.link_for(identifier)
6
6
  end
7
7
 
8
+ def link_elements(identifier={:index => 0})
9
+ @platform.links_for(identifier)
10
+ end
11
+
8
12
  def button_element(identifier={:index => 0})
9
13
  @platform.button_for(identifier)
10
14
  end
11
15
 
16
+ def button_elements(identifier={:index => 0})
17
+ @platform.buttons_for(identifier)
18
+ end
19
+
12
20
  def text_field_element(identifier={:index => 0})
13
21
  @platform.text_field_for(identifier)
14
22
  end
15
23
 
24
+ def text_field_elements(identifier={:index => 0})
25
+ @platform.text_fields_for(identifier)
26
+ end
27
+
16
28
  def hidden_field_element(identifier={:index => 0})
17
29
  @platform.hidden_field_for(identifier)
18
30
  end
19
31
 
32
+ def hidden_field_elements(identifier={:index => 0})
33
+ @platform.hidden_fields_for(identifier)
34
+ end
35
+
20
36
  def text_area_element(identifier={:index => 0})
21
37
  @platform.text_area_for(identifier)
22
38
  end
23
39
 
40
+ def text_area_elements(identifier={:index => 0})
41
+ @platform.text_areas_for(identifier)
42
+ end
43
+
24
44
  def select_list_element(identifier={:index => 0})
25
45
  @platform.select_list_for(identifier)
26
46
  end
27
47
 
48
+ def select_list_elements(identifier={:index => 0})
49
+ @platform.select_lists_for(identifier)
50
+ end
51
+
28
52
  def checkbox_element(identifier={:index => 0})
29
53
  @platform.checkbox_for(identifier)
30
54
  end
31
55
 
56
+ def checkbox_elements(identifier={:index => 0})
57
+ @platform.checkboxs_for(identifier)
58
+ end
59
+
32
60
  def radio_button_element(identifier={:index => 0})
33
61
  @platform.radio_button_for(identifier)
34
62
  end
35
63
 
64
+ def radio_button_elements(identifier={:index => 0})
65
+ @platform.radio_buttons_for(identifier)
66
+ end
67
+
36
68
  def div_element(identifier={:index => 0})
37
69
  @platform.div_for(identifier)
38
70
  end
39
71
 
72
+ def div_elements(identifier={:index => 0})
73
+ @platform.divs_for(identifier)
74
+ end
75
+
40
76
  def span_element(identifier={:index => 0})
41
77
  @platform.span_for(identifier)
42
78
  end
43
79
 
80
+ def span_elements(identifier={:index => 0})
81
+ @platform.spans_for(identifier)
82
+ end
83
+
44
84
  def table_element(identifier={:index => 0})
45
85
  @platform.table_for(identifier)
46
86
  end
47
87
 
88
+ def table_elements(identifier={:index => 0})
89
+ @platform.tables_for(identifier)
90
+ end
91
+
48
92
  def cell_element(identifier={:index => 0})
49
93
  @platform.cell_for(identifier)
50
94
  end
51
95
 
96
+ def cell_elements(identifier={:index => 0})
97
+ @platform.cells_for(identifier)
98
+ end
99
+
52
100
  def image_element(identifier={:index => 0})
53
101
  @platform.image_for(identifier)
54
102
  end
55
103
 
104
+ def image_elements(identifier={:index => 0})
105
+ @platform.images_for(identifier)
106
+ end
107
+
56
108
  def form_element(identifier={:index => 0})
57
109
  @platform.form_for(identifier)
58
110
  end
59
111
 
112
+ def form_elements(identifier={:index => 0})
113
+ @platform.forms_for(identifier)
114
+ end
115
+
60
116
  def ordered_list_element(identifier={:index => 0})
61
117
  @platform.ordered_list_for(identifier)
62
118
  end
63
119
 
120
+ def ordered_list_elements(identifier={:index => 0})
121
+ @platform.ordered_lists_for(identifier)
122
+ end
123
+
64
124
  def unordered_list_element(identifier={:index => 0})
65
125
  @platform.unordered_list_for(identifier)
66
126
  end
67
127
 
128
+ def unordered_list_elements(identifier={:index => 0})
129
+ @platform.unordered_lists_for(identifier)
130
+ end
131
+
68
132
  def list_item_element(identifier={:index => 0})
69
133
  @platform.list_item_for(identifier)
70
134
  end
71
135
 
136
+ def list_item_elements(identifier={:index => 0})
137
+ @platform.list_items_for(identifier)
138
+ end
139
+
72
140
  def h1_element(identifier={:index => 0})
73
141
  @platform.h1_for(identifier)
74
142
  end
75
143
 
144
+ def h1_elements(identifier={:index => 0})
145
+ @platform.h1s_for(identifier)
146
+ end
147
+
76
148
  def h2_element(identifier={:index => 0})
77
149
  @platform.h2_for(identifier)
78
150
  end
151
+
152
+ def h2_elements(identifier={:index => 0})
153
+ @platform.h2s_for(identifier)
154
+ end
79
155
 
80
156
  def h3_element(identifier={:index => 0})
81
157
  @platform.h3_for(identifier)
82
158
  end
83
159
 
160
+ def h3_elements(identifier={:index => 0})
161
+ @platform.h3s_for(identifier)
162
+ end
163
+
84
164
  def h4_element(identifier={:index => 0})
85
165
  @platform.h4_for(identifier)
86
166
  end
87
167
 
168
+ def h4_elements(identifier={:index => 0})
169
+ @platform.h4s_for(identifier)
170
+ end
171
+
88
172
  def h5_element(identifier={:index => 0})
89
173
  @platform.h5_for(identifier)
90
174
  end
175
+
176
+ def h5_elements(identifier={:index => 0})
177
+ @platform.h5s_for(identifier)
178
+ end
91
179
 
92
180
  def h6_element(identifier={:index => 0})
93
181
  @platform.h6_for(identifier)
94
182
  end
183
+
184
+ def h6_elements(identifier={:index => 0})
185
+ @platform.h6s_for(identifier)
186
+ end
95
187
 
96
188
  def paragraph_element(identifier={:index => 0})
97
189
  @platform.paragraph_for(identifier)
98
190
  end
99
191
 
192
+ def paragraph_elements(identifier={:index => 0})
193
+ @platform.paragraphs_for(identifier)
194
+ end
195
+
100
196
  def file_field_element(identifier={:index => 0})
101
197
  @platform.file_field_for(identifier)
102
198
  end
@@ -18,6 +18,17 @@ module PageObject
18
18
  # page.name.should == 'Cheezy'
19
19
  # end
20
20
  #
21
+ # If you plan to use the navigate_to method you will need to ensure
22
+ # you setup the possible routes ahead of time. You must always have
23
+ # a default route in order for this to work. Here is an example of
24
+ # how you define routes:
25
+ #
26
+ # @example Example routes defined in env.rb
27
+ # PageObject::PageFactory.routes = {
28
+ # :default => [[PageOne,:method1], [PageTwoA,:method2], [PageThree,:method3]],
29
+ # :another_route => [[PageOne,:method1], [PageTwoB,:method2b], [PageThree,:method3]]
30
+ # }
31
+ #
21
32
  module PageFactory
22
33
 
23
34
  #
@@ -46,5 +57,82 @@ module PageObject
46
57
  @current_page
47
58
  end
48
59
 
60
+ #
61
+ # Navigate to a specific page following a predefined path.
62
+ #
63
+ # This method requires a lot of setup. See the documentation for
64
+ # this class. Once the setup is complete you can navigate to a
65
+ # page traversing through all other pages along the way. It will
66
+ # call the method you specified in the routes for each
67
+ # page as it navigates. Using the example setup defined in the
68
+ # documentation above you can call the method two ways:
69
+ #
70
+ # @example
71
+ # page.navigate_to(PageThree) # will use the default path
72
+ # page.navigate_to(PageThree, :using => :another_route)
73
+ #
74
+ # @param [PageObject] a class that has included the PageObject
75
+ # module and which has the navigation_method defined
76
+ # @param [Hash] a hash that contains an element with the key
77
+ # :using. This will be used to lookup the route. It has a
78
+ # default value of :default.
79
+ # @param [block] an optional block to be called
80
+ # @return [PageObject] the page you are navigating to
81
+ #
82
+ def navigate_to(page_cls, how = {:using => :default}, &block)
83
+ path = path_for how
84
+ to_index = find_index_for(path, page_cls)-1
85
+ navigate_through_pages(path[0..to_index])
86
+ on_page(page_cls, &block)
87
+ end
88
+
89
+ #
90
+ # Same as navigate_to except it will start at the @current_page
91
+ # instead the beginning of the path.
92
+ #
93
+ # @param [PageObject] a class that has included the PageObject
94
+ # module and which has the navigation_method defined
95
+ # @param [Hash] a hash that contains an element with the key
96
+ # :using. This will be used to lookup the route. It has a
97
+ # default value of :default.
98
+ # @param [block] an optional block to be called
99
+ # @return [PageObject] the page you are navigating to
100
+ #
101
+ def continue_navigation_to(page_cls, how = {:using => :default}, &block)
102
+ path = path_for how
103
+ from_index = find_index_for(path, @current_page.class)+1
104
+ to_index = find_index_for(path, page_cls)-1
105
+ navigate_through_pages(path[from_index..to_index])
106
+ on_page(page_cls, &block)
107
+ end
108
+
109
+ private
110
+
111
+ def path_for(how)
112
+ path = PageObject::PageFactory.page_object_routes[how[:using]]
113
+ fail("PageFactory route :#{how[:using].to_s} not found") unless path
114
+ path
115
+ end
116
+
117
+ def navigate_through_pages(pages)
118
+ pages.each do |cls, method|
119
+ page = on_page(cls)
120
+ fail("Navigation method not specified on #{cls}. Please call the ") unless page.respond_to? method
121
+ page.send method
122
+ end
123
+ end
124
+
125
+ def find_index_for(path, item)
126
+ path.each_with_index { |each, index| return index if each[0] == item}
127
+ end
128
+
129
+ class << self
130
+ attr_accessor :page_object_routes
131
+
132
+ def routes=(routes)
133
+ raise("You must provide a :default route for PageFactory routes") unless routes[:default]
134
+ @page_object_routes = routes
135
+ end
136
+ end
49
137
  end
50
- end
138
+ end
@@ -168,23 +168,21 @@ module PageObject
168
168
  # See PageObject::Accessors#text_field
169
169
  #
170
170
  def text_field_value_for(identifier)
171
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextField, 'input', :type => 'text')
172
- switch_to_frame(frame_identifiers)
173
- text = @browser.find_element(how, what).attribute('value')
174
- @browser.switch_to.default_content unless frame_identifiers.nil?
175
- text
171
+ process_selenium_call(identifier, Elements::TextField, 'input', :type => 'text') do |how, what|
172
+ @browser.find_element(how, what).attribute('value')
173
+ end
176
174
  end
177
175
 
176
+
178
177
  #
179
178
  # platform method to set the value for a text field
180
179
  # See PageObject::Accessors#text_field
181
180
  #
182
181
  def text_field_value_set(identifier, value)
183
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextField, 'input', :type => 'text')
184
- switch_to_frame(frame_identifiers)
185
- @browser.find_element(how, what).clear
186
- @browser.find_element(how, what).send_keys(value)
187
- @browser.switch_to.default_content unless frame_identifiers.nil?
182
+ process_selenium_call(identifier, Elements::TextField, 'input', :type => 'text') do |how, what|
183
+ @browser.find_element(how, what).clear
184
+ @browser.find_element(how, what).send_keys(value)
185
+ end
188
186
  end
189
187
 
190
188
  #
@@ -192,11 +190,14 @@ module PageObject
192
190
  # See PageObject::Accessors#text_field
193
191
  #
194
192
  def text_field_for(identifier)
195
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextField, 'input', :type => 'text')
196
- switch_to_frame(frame_identifiers)
197
- element = @browser.find_element(how, what)
198
- @browser.switch_to.default_content unless frame_identifiers.nil?
199
- ::PageObject::Elements::TextField.new(element, :platform => :selenium_webdriver)
193
+ find_selenium_element(identifier, Elements::TextField, 'input', :type => 'text')
194
+ end
195
+
196
+ #
197
+ # platform method to retrieve all text field elements
198
+ #
199
+ def text_fields_for(identifier)
200
+ find_selenium_elements(identifier, Elements::TextField, 'input', :type => 'text')
200
201
  end
201
202
 
202
203
  #
@@ -204,11 +205,9 @@ module PageObject
204
205
  # See PageObject::Accessors#hidden_field
205
206
  #
206
207
  def hidden_field_value_for(identifier)
207
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField, 'input', :type => 'hidden')
208
- switch_to_frame(frame_identifiers)
209
- value = @browser.find_element(how, what).attribute('value')
210
- @browser.switch_to.default_content unless frame_identifiers.nil?
211
- value
208
+ process_selenium_call(identifier, Elements::HiddenField, 'input', :type => 'hidden') do |how, what|
209
+ @browser.find_element(how, what).attribute('value')
210
+ end
212
211
  end
213
212
 
214
213
  #
@@ -216,11 +215,14 @@ module PageObject
216
215
  # See PageObject::Accessors#hidden_field
217
216
  #
218
217
  def hidden_field_for(identifier)
219
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField, 'input', :type => 'hidden')
220
- switch_to_frame(frame_identifiers)
221
- element = @browser.find_element(how, what)
222
- @browser.switch_to.default_content unless frame_identifiers.nil?
223
- Elements::HiddenField.new(element, :platform => :selenium_webdriver)
218
+ find_selenium_element(identifier, Elements::HiddenField, 'input', :type => 'hidden')
219
+ end
220
+
221
+ #
222
+ # platform method to retrieve all hidden field elements
223
+ #
224
+ def hidden_fields_for(identifier)
225
+ find_selenium_elements(identifier, Elements::HiddenField, 'input', :type => 'hidden')
224
226
  end
225
227
 
226
228
  #
@@ -228,10 +230,9 @@ module PageObject
228
230
  # See PageObject::Accessors#text_area
229
231
  #
230
232
  def text_area_value_set(identifier, value)
231
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextArea, 'textarea')
232
- switch_to_frame(frame_identifiers)
233
- @browser.find_element(how, what).send_keys(value)
234
- @browser.switch_to.default_content unless frame_identifiers.nil?
233
+ process_selenium_call(identifier, Elements::TextArea, 'textarea') do |how, what|
234
+ @browser.find_element(how, what).send_keys(value)
235
+ end
235
236
  end
236
237
 
237
238
  #
@@ -239,11 +240,9 @@ module PageObject
239
240
  # See PageObject::Accessors#text_area
240
241
  #
241
242
  def text_area_value_for(identifier)
242
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextArea, 'textarea')
243
- switch_to_frame(frame_identifiers)
244
- value = @browser.find_element(how, what).attribute('value')
245
- @browser.switch_to.default_content unless frame_identifiers.nil?
246
- value
243
+ process_selenium_call(identifier, Elements::TextArea, 'textarea') do |how, what|
244
+ @browser.find_element(how, what).attribute('value')
245
+ end
247
246
  end
248
247
 
249
248
  #
@@ -251,11 +250,14 @@ module PageObject
251
250
  # See PageObject::Accessors#text_area
252
251
  #
253
252
  def text_area_for(identifier)
254
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TextArea, 'textarea')
255
- switch_to_frame(frame_identifiers)
256
- element = @browser.find_element(how, what)
257
- @browser.switch_to.default_content unless frame_identifiers.nil?
258
- Elements::TextArea.new(element, :platform => :selenium_webdriver)
253
+ find_selenium_element(identifier, Elements::TextArea, 'textarea')
254
+ end
255
+
256
+ #
257
+ # platform method to retrieve all text area elements
258
+ #
259
+ def text_areas_for(identifier)
260
+ find_selenium_elements(identifier, Elements::TextArea, 'textarea')
259
261
  end
260
262
 
261
263
  #
@@ -263,11 +265,9 @@ module PageObject
263
265
  # See PageObject::Accessors#select_list
264
266
  #
265
267
  def select_list_value_for(identifier)
266
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::SelectList, 'select')
267
- switch_to_frame(frame_identifiers)
268
- value = @browser.find_element(how, what).attribute('value')
269
- @browser.switch_to.default_content unless frame_identifiers.nil?
270
- value
268
+ process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what|
269
+ @browser.find_element(how, what).attribute('value')
270
+ end
271
271
  end
272
272
 
273
273
  #
@@ -275,10 +275,9 @@ module PageObject
275
275
  # See PageObject::Accessors#select_list
276
276
  #
277
277
  def select_list_value_set(identifier, value)
278
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::SelectList, 'select')
279
- switch_to_frame(frame_identifiers)
280
- @browser.find_element(how, what).send_keys(value)
281
- @browser.switch_to.default_content unless frame_identifiers.nil?
278
+ process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what|
279
+ @browser.find_element(how, what).send_keys(value)
280
+ end
282
281
  end
283
282
 
284
283
  #
@@ -286,11 +285,14 @@ module PageObject
286
285
  # See PageObject::Accessors#select_list
287
286
  #
288
287
  def select_list_for(identifier)
289
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::SelectList, 'select')
290
- switch_to_frame(frame_identifiers)
291
- element = @browser.find_element(how, what)
292
- @browser.switch_to.default_content unless frame_identifiers.nil?
293
- Elements::SelectList.new(element, :platform => :selenium_webdriver)
288
+ find_selenium_element(identifier, Elements::SelectList, 'select')
289
+ end
290
+
291
+ #
292
+ # platform method to retrieve all select list elements
293
+ #
294
+ def select_lists_for(identifier)
295
+ find_selenium_elements(identifier, Elements::SelectList, 'select')
294
296
  end
295
297
 
296
298
  #
@@ -298,10 +300,9 @@ module PageObject
298
300
  # See PageObject::Accessors#link
299
301
  #
300
302
  def click_link_for(identifier)
301
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Link, 'a')
302
- switch_to_frame frame_identifiers
303
- @browser.find_element(how, what).click
304
- @browser.switch_to.default_content unless frame_identifiers.nil?
303
+ process_selenium_call(identifier, Elements::Link, 'a') do |how, what|
304
+ @browser.find_element(how, what).click
305
+ end
305
306
  end
306
307
 
307
308
  #
@@ -309,11 +310,14 @@ module PageObject
309
310
  # see PageObject::Accessors#link
310
311
  #
311
312
  def link_for(identifier)
312
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Link, 'a')
313
- switch_to_frame(frame_identifiers)
314
- element = @browser.find_element(how, what)
315
- @browser.switch_to.default_content unless frame_identifiers.nil?
316
- Elements::Link.new(element, :platform => :selenium_webdriver)
313
+ find_selenium_element(identifier, Elements::Link, 'a')
314
+ end
315
+
316
+ #
317
+ # platform method to retrieve all link elements
318
+ #
319
+ def links_for(identifier)
320
+ find_selenium_elements(identifier, Elements::Link, 'a')
317
321
  end
318
322
 
319
323
  #
@@ -321,10 +325,9 @@ module PageObject
321
325
  # See PageObject::Accessors#checkbox
322
326
  #
323
327
  def check_checkbox(identifier)
324
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
325
- switch_to_frame(frame_identifiers)
326
- @browser.find_element(how, what).click unless @browser.find_element(how, what).selected?
327
- @browser.switch_to.default_content unless frame_identifiers.nil?
328
+ process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what|
329
+ @browser.find_element(how, what).click unless @browser.find_element(how, what).selected?
330
+ end
328
331
  end
329
332
 
330
333
  #
@@ -332,10 +335,9 @@ module PageObject
332
335
  # See PageObject::Accessors#checkbox
333
336
  #
334
337
  def uncheck_checkbox(identifier)
335
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
336
- switch_to_frame(frame_identifiers)
337
- @browser.find_element(how, what).click if @browser.find_element(how, what).selected?
338
- @browser.switch_to.default_content unless frame_identifiers.nil?
338
+ process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what|
339
+ @browser.find_element(how, what).click if @browser.find_element(how, what).selected?
340
+ end
339
341
  end
340
342
 
341
343
  #
@@ -343,11 +345,9 @@ module PageObject
343
345
  # See PageObject::Accessors#checkbox
344
346
  #
345
347
  def checkbox_checked?(identifier)
346
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
347
- switch_to_frame(frame_identifiers)
348
- value = @browser.find_element(how, what).selected?
349
- @browser.switch_to.default_content unless frame_identifiers.nil?
350
- value
348
+ process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what|
349
+ @browser.find_element(how, what).selected?
350
+ end
351
351
  end
352
352
 
353
353
  #
@@ -355,11 +355,14 @@ module PageObject
355
355
  # See PageObject::Accessors#checkbox
356
356
  #
357
357
  def checkbox_for(identifier)
358
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
359
- switch_to_frame(frame_identifiers)
360
- element = @browser.find_element(how, what)
361
- @browser.switch_to.default_content unless frame_identifiers.nil?
362
- Elements::CheckBox.new(element, :platform => :selenium_webdriver)
358
+ find_selenium_element(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
359
+ end
360
+
361
+ #
362
+ # platform method to retrieve all checkbox elements
363
+ #
364
+ def checkboxes_for(identifier)
365
+ find_selenium_elements(identifier, Elements::CheckBox, 'input', :type => 'checkbox')
363
366
  end
364
367
 
365
368
  #
@@ -367,10 +370,9 @@ module PageObject
367
370
  # See PageObject::Accessors#radio_button
368
371
  #
369
372
  def select_radio(identifier)
370
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton, 'input', :type => 'radio')
371
- switch_to_frame(frame_identifiers)
372
- @browser.find_element(how, what).click unless @browser.find_element(how, what).selected?
373
- @browser.switch_to.default_content unless frame_identifiers.nil?
373
+ process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what|
374
+ @browser.find_element(how, what).click unless @browser.find_element(how, what).selected?
375
+ end
374
376
  end
375
377
 
376
378
  #
@@ -378,10 +380,9 @@ module PageObject
378
380
  # See PageObject::Accessors#radio_button
379
381
  #
380
382
  def clear_radio(identifier)
381
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton, 'input', :type => 'radio')
382
- switch_to_frame(frame_identifiers)
383
- @browser.find_element(how, what).click if @browser.find_element(how, what).selected?
384
- @browser.switch_to.default_content unless frame_identifiers.nil?
383
+ process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what|
384
+ @browser.find_element(how, what).click if @browser.find_element(how, what).selected?
385
+ end
385
386
  end
386
387
 
387
388
  #
@@ -389,11 +390,9 @@ module PageObject
389
390
  # See PageObject::Accessors#radio_button
390
391
  #
391
392
  def radio_selected?(identifier)
392
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton, 'input', :type => 'radio')
393
- switch_to_frame(frame_identifiers)
394
- value = @browser.find_element(how, what).selected?
395
- @browser.switch_to.default_content unless frame_identifiers.nil?
396
- value
393
+ process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what|
394
+ @browser.find_element(how, what).selected?
395
+ end
397
396
  end
398
397
 
399
398
  #
@@ -401,11 +400,14 @@ module PageObject
401
400
  # See PageObject::Accessors#radio_button
402
401
  #
403
402
  def radio_button_for(identifier)
404
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton, 'input', :type => 'radio')
405
- switch_to_frame(frame_identifiers)
406
- element = @browser.find_element(how, what)
407
- @browser.switch_to.default_content unless frame_identifiers.nil?
408
- ::PageObject::Elements::RadioButton.new(element, :platform => :selenium_webdriver)
403
+ find_selenium_element(identifier, Elements::RadioButton, 'input', :type => 'radio')
404
+ end
405
+
406
+ #
407
+ # platform method to retrieve all radio button elements
408
+ #
409
+ def radio_buttons_for(identifier)
410
+ find_selenium_elements(identifier, Elements::RadioButton, 'input', :type => 'radio')
409
411
  end
410
412
 
411
413
  #
@@ -413,11 +415,9 @@ module PageObject
413
415
  # See PageObject::Accessors#div
414
416
  #
415
417
  def div_text_for(identifier)
416
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
417
- switch_to_frame(frame_identifiers)
418
- value = @browser.find_element(how, what).text
419
- @browser.switch_to.default_content unless frame_identifiers.nil?
420
- value
418
+ process_selenium_call(identifier, Elements::Div, 'div') do |how, what|
419
+ @browser.find_element(how, what).text
420
+ end
421
421
  end
422
422
 
423
423
  #
@@ -425,11 +425,14 @@ module PageObject
425
425
  # See PageObject::Accessors#div
426
426
  #
427
427
  def div_for(identifier)
428
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
429
- switch_to_frame(frame_identifiers)
430
- element = @browser.find_element(how, what)
431
- @browser.switch_to.default_content unless frame_identifiers.nil?
432
- ::PageObject::Elements::Div.new(element, :platform => :selenium_webdriver)
428
+ find_selenium_element(identifier, Elements::Div, 'div')
429
+ end
430
+
431
+ #
432
+ # platform method to retrieve all div elements
433
+ #
434
+ def divs_for(identifier)
435
+ find_selenium_elements(identifier, Elements::Div, 'div')
433
436
  end
434
437
 
435
438
  #
@@ -437,11 +440,9 @@ module PageObject
437
440
  # See PageObject::Accessors#span
438
441
  #
439
442
  def span_text_for(identifier)
440
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
441
- switch_to_frame(frame_identifiers)
442
- value = @browser.find_element(how, what).text
443
- @browser.switch_to.default_content unless frame_identifiers.nil?
444
- value
443
+ process_selenium_call(identifier, Elements::Span, 'span') do |how, what|
444
+ @browser.find_element(how, what).text
445
+ end
445
446
  end
446
447
 
447
448
  #
@@ -449,11 +450,14 @@ module PageObject
449
450
  # See PageObject::Accessors#span
450
451
  #
451
452
  def span_for(identifier)
452
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
453
- switch_to_frame(frame_identifiers)
454
- element = @browser.find_element(how, what)
455
- @browser.switch_to.default_content unless frame_identifiers.nil?
456
- ::PageObject::Elements::Span.new(element, :platform => :selenium_webdriver)
453
+ find_selenium_element(identifier, Elements::Span, 'span')
454
+ end
455
+
456
+ #
457
+ # platform method to retrieve all span elements
458
+ #
459
+ def spans_for(identifier)
460
+ find_selenium_elements(identifier, Elements::Span, 'span')
457
461
  end
458
462
 
459
463
  #
@@ -461,10 +465,9 @@ module PageObject
461
465
  # See PageObject::Accessors#button
462
466
  #
463
467
  def click_button_for(identifier)
464
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Button, 'input', :type => 'submit')
465
- switch_to_frame(frame_identifiers)
466
- @browser.find_element(how, what).click
467
- @browser.switch_to.default_content unless frame_identifiers.nil?
468
+ process_selenium_call(identifier, Elements::Button, 'input', :type => 'submit') do |how, what|
469
+ @browser.find_element(how, what).click
470
+ end
468
471
  end
469
472
 
470
473
  #
@@ -472,23 +475,29 @@ module PageObject
472
475
  # See PageObject::Accessors#button
473
476
  #
474
477
  def button_for(identifier)
475
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Button, 'input', :type => 'submit')
476
- switch_to_frame(frame_identifiers)
477
- element = @browser.find_element(how, what)
478
- @browser.switch_to.default_content unless frame_identifiers.nil?
479
- ::PageObject::Elements::Button.new(element, :platform => :selenium_webdriver)
478
+ find_selenium_element(identifier, Elements::Button, 'input', :type => 'submit')
480
479
  end
481
480
 
481
+ #
482
+ # platform method to retrieve an array of button elements
483
+ #
484
+ def buttons_for(identifier)
485
+ find_selenium_elements(identifier, Elements::Button, 'input', :type => 'submit')
486
+ end
487
+
482
488
  #
483
489
  # platform method to retrieve a table element
484
490
  # See PageObject::Accessors#table
485
491
  #
486
492
  def table_for(identifier)
487
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Table, 'table')
488
- switch_to_frame(frame_identifiers)
489
- element = @browser.find_element(how, what)
490
- @browser.switch_to.default_content unless frame_identifiers.nil?
491
- ::PageObject::Elements::Table.new(element, :platform => :selenium_webdriver)
493
+ find_selenium_element(identifier, Elements::Table, 'table')
494
+ end
495
+
496
+ #
497
+ # platform method to retrieve all table elements
498
+ #
499
+ def tables_for(identifier)
500
+ find_selenium_elements(identifier, Elements::Table, 'table')
492
501
  end
493
502
 
494
503
  #
@@ -496,11 +505,9 @@ module PageObject
496
505
  # See PageObject::Accessors#cell
497
506
  #
498
507
  def cell_text_for(identifier)
499
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
500
- switch_to_frame(frame_identifiers)
501
- value = @browser.find_element(how, what).text
502
- @browser.switch_to.default_content unless frame_identifiers.nil?
503
- value
508
+ process_selenium_call(identifier, Elements::TableCell, 'td') do |how, what|
509
+ @browser.find_element(how, what).text
510
+ end
504
511
  end
505
512
 
506
513
  #
@@ -508,11 +515,14 @@ module PageObject
508
515
  # See PageObject::Accessors#cell
509
516
  #
510
517
  def cell_for(identifier)
511
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
512
- switch_to_frame(frame_identifiers)
513
- element = @browser.find_element(how, what)
514
- @browser.switch_to.default_content unless frame_identifiers.nil?
515
- ::PageObject::Elements::TableCell.new(element, :platform => :selenium_webdriver)
518
+ find_selenium_element(identifier, Elements::TableCell, 'td')
519
+ end
520
+
521
+ #
522
+ # platform method to retrieve all table cell elements
523
+ #
524
+ def cells_for(identifier)
525
+ find_selenium_elements(identifier, Elements::TableCell, 'td')
516
526
  end
517
527
 
518
528
  #
@@ -520,11 +530,14 @@ module PageObject
520
530
  # See PageObject::Accessors#image
521
531
  #
522
532
  def image_for(identifier)
523
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Image, 'img')
524
- switch_to_frame(frame_identifiers)
525
- element = @browser.find_element(how, what)
526
- @browser.switch_to.default_content unless frame_identifiers.nil?
527
- ::PageObject::Elements::Image.new(element, :platform => :selenium_webdriver)
533
+ find_selenium_element(identifier, Elements::Image, 'img')
534
+ end
535
+
536
+ #
537
+ # platform method to retrieve all image elements
538
+ #
539
+ def images_for(identifier)
540
+ find_selenium_elements(identifier, Elements::Image, 'img')
528
541
  end
529
542
 
530
543
  #
@@ -532,11 +545,14 @@ module PageObject
532
545
  # See PageObject::Accessors#form
533
546
  #
534
547
  def form_for(identifier)
535
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Form, 'form')
536
- switch_to_frame(frame_identifiers)
537
- element = @browser.find_element(how, what)
538
- @browser.switch_to.default_content unless frame_identifiers.nil?
539
- ::PageObject::Elements::Form.new(element, :platform => :selenium_webdriver)
548
+ find_selenium_element(identifier, Elements::Form, 'form')
549
+ end
550
+
551
+ #
552
+ # platform method to retrieve all forms
553
+ #
554
+ def forms_for(identifier)
555
+ find_selenium_elements(identifier, Elements::Form, 'form')
540
556
  end
541
557
 
542
558
  #
@@ -544,11 +560,9 @@ module PageObject
544
560
  # See PageObject::Accessors#list_item
545
561
  #
546
562
  def list_item_text_for(identifier)
547
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
548
- switch_to_frame(frame_identifiers)
549
- value = @browser.find_element(how, what).text
550
- @browser.switch_to.default_content
551
- value
563
+ process_selenium_call(identifier, Elements::ListItem, 'li') do |how, what|
564
+ @browser.find_element(how, what).text
565
+ end
552
566
  end
553
567
 
554
568
  #
@@ -556,11 +570,14 @@ module PageObject
556
570
  # See PageObject::Accessors#list_item
557
571
  #
558
572
  def list_item_for(identifier)
559
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
560
- switch_to_frame(frame_identifiers)
561
- element = @browser.find_element(how, what)
562
- @browser.switch_to.default_content unless frame_identifiers.nil?
563
- ::PageObject::Elements::ListItem.new(element, :platform => :selenium_webdriver)
573
+ find_selenium_element(identifier, Elements::ListItem, 'li')
574
+ end
575
+
576
+ #
577
+ # platform method to retrieve all list items
578
+ #
579
+ def list_items_for(identifier)
580
+ find_selenium_elements(identifier, Elements::ListItem, 'li')
564
581
  end
565
582
 
566
583
  #
@@ -568,11 +585,14 @@ module PageObject
568
585
  # See PageObject::Accessors#unordered_list
569
586
  #
570
587
  def unordered_list_for(identifier)
571
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::UnorderedList, 'ul')
572
- switch_to_frame(frame_identifiers)
573
- element = @browser.find_element(how, what)
574
- @browser.switch_to.default_content unless frame_identifiers.nil?
575
- ::PageObject::Elements::UnorderedList.new(element, :platform => :selenium_webdriver)
588
+ find_selenium_element(identifier, Elements::UnorderedList, 'ul')
589
+ end
590
+
591
+ #
592
+ # platform method to retrieve all unordered lists
593
+ #
594
+ def unordered_lists_for(identifier)
595
+ find_selenium_elements(identifier, Elements::UnorderedList, 'ul')
576
596
  end
577
597
 
578
598
  #
@@ -580,23 +600,24 @@ module PageObject
580
600
  # See PageObject::Accessors#ordered_list
581
601
  #
582
602
  def ordered_list_for(identifier)
583
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::OrderedList, 'ol')
584
- switch_to_frame(frame_identifiers)
585
- element = @browser.find_element(how, what)
586
- @browser.switch_to.default_content unless frame_identifiers.nil?
587
- ::PageObject::Elements::OrderedList.new(element, :platform => :selenium_webdriver)
603
+ find_selenium_element(identifier, Elements::OrderedList, 'ol')
588
604
  end
589
605
 
606
+ #
607
+ # platform method to retrieve all ordered lists
608
+ #
609
+ def ordered_lists_for(identifier)
610
+ find_selenium_elements(identifier, Elements::OrderedList, 'ol')
611
+ end
612
+
590
613
  #
591
614
  # platform method to retrieve the text from a h1
592
615
  # See PageObject::Accessors#h1
593
616
  #
594
617
  def h1_text_for(identifier)
595
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h1')
596
- switch_to_frame(frame_identifiers)
597
- value = @browser.find_element(how, what).text
598
- @browser.switch_to.default_content
599
- value
618
+ process_selenium_call(identifier, Elements::Heading, 'h1') do |how, what|
619
+ @browser.find_element(how, what).text
620
+ end
600
621
  end
601
622
 
602
623
  #
@@ -604,11 +625,14 @@ module PageObject
604
625
  # See PageObject::Accessors#h1
605
626
  #
606
627
  def h1_for(identifier)
607
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h1')
608
- switch_to_frame(frame_identifiers)
609
- element = @browser.find_element(how, what)
610
- @browser.switch_to.default_content unless frame_identifiers.nil?
611
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
628
+ find_selenium_element(identifier, Elements::Heading, 'h1')
629
+ end
630
+
631
+ #
632
+ # platform method to retrieve all h1 elements
633
+ #
634
+ def h1s_for(identifier)
635
+ find_selenium_elements(identifier, Elements::Heading, 'h1')
612
636
  end
613
637
 
614
638
  #
@@ -616,11 +640,9 @@ module PageObject
616
640
  # See PageObject::Accessors#h2
617
641
  #
618
642
  def h2_text_for(identifier)
619
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h2')
620
- switch_to_frame(frame_identifiers)
621
- value = @browser.find_element(how, what).text
622
- @browser.switch_to.default_content
623
- value
643
+ process_selenium_call(identifier, Elements::Heading, 'h2') do |how, what|
644
+ @browser.find_element(how, what).text
645
+ end
624
646
  end
625
647
 
626
648
  #
@@ -628,11 +650,14 @@ module PageObject
628
650
  # See PageObject::Accessors#h2
629
651
  #
630
652
  def h2_for(identifier)
631
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h2')
632
- switch_to_frame(frame_identifiers)
633
- element = @browser.find_element(how, what)
634
- @browser.switch_to.default_content unless frame_identifiers.nil?
635
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
653
+ find_selenium_element(identifier, Elements::Heading, 'h2')
654
+ end
655
+
656
+ #
657
+ # platform method to retrieve all h2 elements
658
+ #
659
+ def h2s_for(identifier)
660
+ find_selenium_elements(identifier, Elements::Heading, 'h2')
636
661
  end
637
662
 
638
663
  #
@@ -640,11 +665,9 @@ module PageObject
640
665
  # See PageObject::Accessors#h3
641
666
  #
642
667
  def h3_text_for(identifier)
643
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h3')
644
- switch_to_frame(frame_identifiers)
645
- value = @browser.find_element(how, what).text
646
- @browser.switch_to.default_content
647
- value
668
+ process_selenium_call(identifier, Elements::Heading, 'h3') do |how, what|
669
+ @browser.find_element(how, what).text
670
+ end
648
671
  end
649
672
 
650
673
  #
@@ -652,11 +675,14 @@ module PageObject
652
675
  # See PageObject::Accessors#h3
653
676
  #
654
677
  def h3_for(identifier)
655
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h3')
656
- switch_to_frame(frame_identifiers)
657
- element = @browser.find_element(how, what)
658
- @browser.switch_to.default_content unless frame_identifiers.nil?
659
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
678
+ find_selenium_element(identifier, Elements::Heading, 'h3')
679
+ end
680
+
681
+ #
682
+ # platform method to retrieve all h3 elements
683
+ #
684
+ def h3s_for(identifier)
685
+ find_selenium_elements(identifier, Elements::Heading, 'h3')
660
686
  end
661
687
 
662
688
  #
@@ -664,11 +690,9 @@ module PageObject
664
690
  # See PageObject::Accessors#h4
665
691
  #
666
692
  def h4_text_for(identifier)
667
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h4')
668
- switch_to_frame(frame_identifiers)
669
- value = @browser.find_element(how, what).text
670
- @browser.switch_to.default_content
671
- value
693
+ process_selenium_call(identifier, Elements::Heading, 'h4') do |how, what|
694
+ @browser.find_element(how, what).text
695
+ end
672
696
  end
673
697
 
674
698
  #
@@ -676,11 +700,14 @@ module PageObject
676
700
  # See PageObject::Accessors#h4
677
701
  #
678
702
  def h4_for(identifier)
679
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h4')
680
- switch_to_frame(frame_identifiers)
681
- element = @browser.find_element(how, what)
682
- @browser.switch_to.default_content unless frame_identifiers.nil?
683
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
703
+ find_selenium_element(identifier, Elements::Heading, 'h4')
704
+ end
705
+
706
+ #
707
+ # platform method to retrieve all h4 elements
708
+ #
709
+ def h4s_for(identifier)
710
+ find_selenium_elements(identifier, Elements::Heading, 'h4')
684
711
  end
685
712
 
686
713
  #
@@ -688,11 +715,9 @@ module PageObject
688
715
  # See PageObject::Accessors#h5
689
716
  #
690
717
  def h5_text_for(identifier)
691
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h5')
692
- switch_to_frame(frame_identifiers)
693
- value = @browser.find_element(how, what).text
694
- @browser.switch_to.default_content
695
- value
718
+ process_selenium_call(identifier, Elements::Heading, 'h5') do |how, what|
719
+ @browser.find_element(how, what).text
720
+ end
696
721
  end
697
722
 
698
723
  #
@@ -700,11 +725,14 @@ module PageObject
700
725
  # See PageObject::Accessors#h5
701
726
  #
702
727
  def h5_for(identifier)
703
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h5')
704
- switch_to_frame(frame_identifiers)
705
- element = @browser.find_element(how, what)
706
- @browser.switch_to.default_content unless frame_identifiers.nil?
707
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
728
+ find_selenium_element(identifier, Elements::Heading, 'h5')
729
+ end
730
+
731
+ #
732
+ # platform method to retrieve all h5 elements
733
+ #
734
+ def h5s_for(identifier)
735
+ find_selenium_elements(identifier, Elements::Heading, 'h5')
708
736
  end
709
737
 
710
738
  #
@@ -712,11 +740,9 @@ module PageObject
712
740
  # See PageObject::Accessors#h6
713
741
  #
714
742
  def h6_text_for(identifier)
715
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h6')
716
- switch_to_frame(frame_identifiers)
717
- value = @browser.find_element(how, what).text
718
- @browser.switch_to.default_content
719
- value
743
+ process_selenium_call(identifier, Elements::Heading, 'h6') do |how, what|
744
+ @browser.find_element(how, what).text
745
+ end
720
746
  end
721
747
 
722
748
  #
@@ -724,11 +750,14 @@ module PageObject
724
750
  # See PageObject::Accessors#h6
725
751
  #
726
752
  def h6_for(identifier)
727
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h6')
728
- switch_to_frame(frame_identifiers)
729
- element = @browser.find_element(how, what)
730
- @browser.switch_to.default_content unless frame_identifiers.nil?
731
- ::PageObject::Elements::Heading.new(element, :platform => :selenium_webdriver)
753
+ find_selenium_element(identifier, Elements::Heading, 'h6')
754
+ end
755
+
756
+ #
757
+ # platform method to retrieve all h6 elements
758
+ #
759
+ def h6s_for(identifier)
760
+ find_selenium_elements(identifier, Elements::Heading, 'h6')
732
761
  end
733
762
 
734
763
  #
@@ -736,11 +765,9 @@ module PageObject
736
765
  # See PageObject::Accessors#paragraph
737
766
  #
738
767
  def paragraph_text_for(identifier)
739
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Paragraph, 'p')
740
- switch_to_frame(frame_identifiers)
741
- value = @browser.find_element(how, what).text
742
- @browser.switch_to.default_content unless frame_identifiers.nil?
743
- value
768
+ process_selenium_call(identifier, Elements::Paragraph, 'p') do |how, what|
769
+ @browser.find_element(how, what).text
770
+ end
744
771
  end
745
772
 
746
773
  #
@@ -748,11 +775,14 @@ module PageObject
748
775
  # See PageObject::Accessors#paragraph
749
776
  #
750
777
  def paragraph_for(identifier)
751
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'p')
752
- switch_to_frame(frame_identifiers)
753
- element = @browser.find_element(how, what)
754
- @browser.switch_to.default_content unless frame_identifiers.nil?
755
- ::PageObject::Elements::Paragraph.new(element, :platform => :selenium_webdriver)
778
+ find_selenium_element(identifier, Elements::Paragraph, 'p')
779
+ end
780
+
781
+ #
782
+ # platform method to retrieve all paragraph elements
783
+ #
784
+ def paragraphs_for(identifier)
785
+ find_selenium_elements(identifier, Elements::Paragraph, 'p')
756
786
  end
757
787
 
758
788
  #
@@ -760,10 +790,9 @@ module PageObject
760
790
  # See PageObject::Accessors#file_field
761
791
  #
762
792
  def file_field_value_set(identifier, value)
763
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::FileField, 'input', :type => 'file')
764
- switch_to_frame(frame_identifiers)
765
- @browser.find_element(how, what).send_keys(value)
766
- @browser.switch_to.default_content unless frame_identifiers.nil?
793
+ process_selenium_call(identifier, Elements::FileField, 'input', :type => 'file') do |how, what|
794
+ @browser.find_element(how, what).send_keys(value)
795
+ end
767
796
  end
768
797
 
769
798
  #
@@ -771,15 +800,35 @@ module PageObject
771
800
  # See PageObject::Accessors#file_field
772
801
  #
773
802
  def file_field_for(identifier)
774
- how, what, frame_identifiers = parse_identifiers(identifier, Elements::FileField, 'input', :type => 'file')
803
+ find_selenium_element(identifier, Elements::FileField, 'input', :type => 'file')
804
+ end
805
+
806
+ private
807
+
808
+ def process_selenium_call(identifier, type, tag, other=nil)
809
+ how, what, frame_identifiers = parse_identifiers(identifier, type, tag, other)
810
+ switch_to_frame(frame_identifiers)
811
+ value = yield how, what
812
+ @browser.switch_to.default_content unless frame_identifiers.nil?
813
+ value
814
+ end
815
+
816
+ def find_selenium_element(identifier, type, tag, other=nil)
817
+ how, what, frame_identifiers = parse_identifiers(identifier, type, tag, other)
775
818
  switch_to_frame(frame_identifiers)
776
819
  element = @browser.find_element(how, what)
777
820
  @browser.switch_to.default_content unless frame_identifiers.nil?
778
- ::PageObject::Elements::FileField.new(element, :platform => :selenium_webdriver)
821
+ type.new(element, :platform => :selenium_webdriver)
822
+ end
823
+
824
+ def find_selenium_elements(identifier, type, tag, other=nil)
825
+ how, what, frame_identifiers = parse_identifiers(identifier, type, tag, other)
826
+ switch_to_frame(frame_identifiers)
827
+ elements = @browser.find_elements(how, what)
828
+ @browser.switch_to.default_content unless frame_identifiers.nil?
829
+ elements.map { |element| type.new(element, :platform => :selenium_webdriver) }
779
830
  end
780
831
 
781
- private
782
-
783
832
  def parse_identifiers(identifier, element, tag_name=nil, additional=nil)
784
833
  frame_identifiers = identifier.delete(:frame)
785
834
  identifier = add_tagname_if_needed identifier, tag_name, additional if tag_name