awetestlib 0.1.13-x86-mingw32 → 0.1.14-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,88 @@
1
1
  module Awetestlib
2
2
  module Regression
3
+ # Methods to fetch references to DOM elements for assigning to variables. Includes collections of elements.
4
+ # Primary use is to limit the scope of other commands to the element passed in their *browser* parameter.
5
+ # (example here)
3
6
  module Find
4
7
 
5
- def get_select_list(browser, how, what, desc = '')
6
- list = browser.select_list(how, what)
7
- if validate(browser, @myName, __LINE__)
8
- passed_to_log("Select list #{how}='#{what}' found and returned.")
9
- return list
8
+ # @!group Core
9
+
10
+ # Return a reference to a DOM element specified by its type *element*, attribute *how*, and the
11
+ # contents of that attribute *what*. Some elements may require use of the *:value* attribute in addition
12
+ # to the designated one. The target contents for *:value* are supplied in *value*.
13
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
14
+ # @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
15
+ # Some common values are :link, :button, :image, :div, :span.
16
+ # @param [Symbol] how The element attribute used to identify the specific element.
17
+ # Valid values depend on the kind of element.
18
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
19
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
20
+ # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute that uniquely identifies the element.
21
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
22
+ def get_element(browser, element, how, what, value = nil, desc = '')
23
+ msg = build_message("Return #{element} with :#{how}=#{what}", value, desc)
24
+ target = nil
25
+ what = Regexp.new(Regexp.escape(what)) unless how == :index or what.is_a?(Regexp)
26
+ case element
27
+ when :link
28
+ target = browser.link(how, what)
29
+ when :button
30
+ target = browser.button(how, what)
31
+ when :div
32
+ target = browser.div(how, what)
33
+ when :checkbox
34
+ target = browser.checkbox(how, what, value)
35
+ when :text_field, :textfield
36
+ target = browser.text_field(how, what)
37
+ when :image
38
+ target = browser.image(how, what)
39
+ when :file_field, :filefield
40
+ target = browser.file_field(how, what)
41
+ when :form
42
+ target = browser.form(how, what)
43
+ when :frame
44
+ target = browser.frame(how, what)
45
+ when :radio
46
+ target = browser.radio(how, what, value)
47
+ when :span
48
+ target = browser.span(how, what)
49
+ when :table
50
+ target = browser.table(how, what)
51
+ when :li
52
+ target = browser.li(how, what)
53
+ when :select_list, :selectlist
54
+ target = browser.select_list(how, what)
55
+ when :hidden
56
+ target = browser.hidden(how, what)
57
+ when :area
58
+ target = browser.area(how, what)
59
+ else
60
+ target = browser.element(how, what)
61
+ end
62
+ if target.exists?
63
+ passed_to_log(msg)
64
+ target
65
+ else
66
+ failed_to_log(msg)
67
+ nil
68
+ end
69
+ rescue => e
70
+ if not rescue_me(e, __method__, "browser.#{element}(#{how}, '#{what}')", "#{browser.class}", target)
71
+ raise e
10
72
  end
11
- rescue
12
- failed_to_log("Unable to return select list #{how}='#{what}': '#{$!}' (#{__LINE__})")
13
73
  end
14
74
 
75
+ # Return an array containing the options available for selection in a select_list identifified by
76
+ # its attribute *how*, and the contents of that attribute *what*.
77
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
78
+ # @param [Symbol] how The element attribute used to identify the specific element.
79
+ # Valid values depend on the kind of element.
80
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
81
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute
82
+ # that uniquely identifies the element.
83
+ # @param [Boolean] dump If set to true, a dump of the contents of the options will go to the log.
84
+ # See Utilities#dump_select_list_options
85
+ # @return [Array]
15
86
  def get_select_options(browser, how, what, dump = false)
16
87
  list = browser.select_list(how, what)
17
88
  dump_select_list_options(list) if dump
@@ -20,14 +91,15 @@ module Awetestlib
20
91
  failed_to_log("Unable to get select options for #{how}=>#{what}. '#{$!}'")
21
92
  end
22
93
 
23
- def get_select_options_by_id(browser, strg, dump = false)
24
- get_select_options(browser, :id, strg, dump)
25
- end
26
-
27
- def get_select_options_by_name(browser, strg, dump = false)
28
- get_select_options(browser, :name, strg, dump)
29
- end
30
-
94
+ # Return an array containing the _selected_ options in a select_list identified by
95
+ # its attribute *how*, and the contents of that attribute *what*.
96
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
97
+ # @param [Symbol] how The element attribute used to identify the specific element.
98
+ # Valid values depend on the kind of element.
99
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
100
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute
101
+ # that uniquely identifies the element.
102
+ # @return [Array]
31
103
  def get_selected_options(browser, how, what)
32
104
  begin
33
105
  list = browser.select_list(how, what)
@@ -36,318 +108,120 @@ module Awetestlib
36
108
  raise e
37
109
  end
38
110
  end
39
- list.selected_options
40
- end
41
-
42
- def get_selected_options_by_id(browser, strg)
43
- get_selected_options(browser, :id, strg)
111
+ list.selected_options if list
44
112
  end
45
113
 
46
- alias get_selected_option_by_id get_selected_options_by_id
47
-
48
- def get_selected_options_by_name(browser, strg)
49
- get_selected_options(browser, :name, strg)
50
- end
51
-
52
- alias get_selected_option_by_name get_selected_options_by_name
53
-
54
- =begin rdoc
55
- :category: A_rdoc_test
56
- Returns a reference to a division element. Used to assign a div element to a variable
57
- which can then be passed to methods that require a *browser* parameter.
58
-
59
- _Parameters_::
60
-
61
- *browser* - a reference to the browser window or container element to be tested
62
-
63
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
64
- Common values: :text, :id, :title, :name, :class, :href (:link only)
65
-
66
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
67
-
68
- *desc* - a string containing a message or description intended to appear in the log and/or report output
69
-
70
- _Example_
71
-
72
- mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com
73
- click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
74
- popup = attach_browser(mainwindow, :url, '[url of new window]') *or*
75
- popup = attach_browser(mainwindow, :title, '[title of new window]')
76
-
77
- =end
78
-
114
+ # Return a reference to a div element identified by the contents *what* of its attribute *how*.
115
+ # This differs from get_element in that it waits for the element to exist before trying to return it.
116
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
117
+ # @param [Symbol] how The element attribute used to identify the specific element.
118
+ # Valid values depend on the kind of element.
119
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
120
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute
121
+ # that uniquely identifies the element.
122
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
123
+ # @param [Boolean] dbg If set to true additional debug logging is performed.
124
+ # @return [Watir::Div]
79
125
  def get_div(browser, how, what, desc = '', dbg = false)
80
- msg = "Get division #{how}=>#{what}."
81
- msg << " #{desc}" if desc.length > 0
126
+ msg = build_message("Get :div #{how}=>#{what}.", desc)
82
127
  Watir::Wait.until { browser.div(how, what).exists? }
83
128
  div = browser.div(how, what)
84
129
  debug_to_log(div.inspect) if dbg
85
- if validate(browser, @myName, __LINE__)
86
- if div
87
- passed_to_log(msg)
88
- return div
89
- else
90
- failed_to_log(msg)
91
- end
130
+ if div
131
+ passed_to_log(msg)
132
+ return div
133
+ else
134
+ failed_to_log(msg)
92
135
  end
93
136
  rescue
94
137
  failed_to_log("Unable to '#{msg}' '#{$!}'")
95
138
  end
96
139
 
97
- def get_div_by_id(browser, strg, desc = '', dbg = false)
98
- get_div(browser, :id, strg, desc, dbg)
99
- end
100
-
101
- =begin rdoc
102
- :category: A_rdoc_test
103
- Returns a reference to a division element identified by the value in its class attribute. Calls get_div()
104
-
105
- _Parameters_::
106
-
107
- *browser* - a reference to the browser window or container element to be tested
108
-
109
- *strg* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
110
-
111
- *desc* - a string containing a message or description intended to appear in the log and/or report output
112
-
113
- _Example_
114
-
115
- mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com
116
- click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
117
- popup = attach_browser(mainwindow, :url, '[url of new window]') *or*
118
- popup = attach_browser(mainwindow, :title, '[title of new window]')
119
-
120
- =end
121
-
122
- def get_div_by_class(browser, strg, desc = '', dbg = false)
123
- get_div(browser, :class, strg, desc, dbg)
124
- end
125
-
126
- def get_div_by_text(browser, strg, desc = '', dbg = false)
127
- get_div(browser, :text, strg, desc, dbg)
128
- end
129
-
130
- def get_form(browser, how, strg)
140
+ # Return a reference to a _span_ element identified by the contents *what* of its attribute *how*.
141
+ # This differs from get_element in that it waits for the element to exist before trying to return it.
142
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
143
+ # @param [Symbol] how The element attribute used to identify the specific element.
144
+ # Valid values depend on the kind of element.
145
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
146
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute
147
+ # that uniquely identifies the element.
148
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
149
+ # @return [Watir::Span]
150
+ def get_span(browser, how, what, desc = '')
131
151
  begin
132
- # Watir::Wait.until( browser.form(how, strg).exists? ) # fails in wait_until
152
+ Watir::Wait.until { browser.span(how, what).exists? }
133
153
  rescue => e
134
- if not rescue_me(e, __method__, "browser.form(#{how}, '#{strg}').exists?", "#{browser.class}")
154
+ if not rescue_me(e, __method__, "browser.span(#{how}, '#{what}').exists?", "#{browser.class}")
135
155
  raise e
136
156
  end
137
157
  end
138
- myForm = browser.form(how, strg)
139
- if validate(browser, @myName, __LINE__)
140
- passed_to_log("Form #{how}='#{strg}' found and returned.")
141
- return myForm
142
- end
143
- rescue
144
- failed_to_log("Unable to return form #{how}='#{strg}': '#{$!}' (#{__LINE__})")
145
- end
146
-
147
- def get_form_by_id(browser, strg)
148
- get_form(browser, :id, strg)
149
- end
150
-
151
- def get_frame(browser, how, strg, desc = '')
152
- # begin
153
- # Watir::Wait.until(browser.frame(how, strg).exists?) # fails in wait_until
154
- # rescue => e
155
- # if not rescue_me(e, __method__, "browser.frame(#{how}, '#{strg}').exists?", "#{browser.class}")
156
- # raise e
157
- # end
158
- # end
159
158
  begin
160
- frame = browser.frame(how, strg)
159
+ span = browser.span(how, what)
161
160
  rescue => e
162
- if not rescue_me(e, __method__, "browser.frame(#{how}, '#{strg}').exists?", "#{browser.class}")
161
+ if not rescue_me(e, __method__, "browser.span(#{how}, '#{what}').exists?", "#{browser.class}")
163
162
  raise e
164
163
  end
165
164
  end
166
- if validate(browser, @myName, __LINE__)
167
- passed_to_log("Frame #{how}='#{strg}' found and returned. #{desc}")
168
- return frame
169
- end
165
+ passed_to_log("Span #{how}='#{what}' found and returned. #{desc}")
166
+ return span
170
167
  rescue
171
- failed_to_log("Unable to return frame #{how}='#{strg}'. #{desc}: '#{$!}' (#{__LINE__})")
172
- end
173
-
174
- def get_frame_by_id(browser, strg, desc = '')
175
- get_frame(browser, :id, strg, desc)
176
- end
177
-
178
- def get_frame_by_index(browser, index, desc = '')
179
- get_frame(browser, :index, index, desc)
180
- end
181
-
182
- def get_frame_by_name(browser, strg, desc = '')
183
- get_frame(browser, :name, strg, desc)
168
+ failed_to_log("Unable to return span #{how}='#{what}'. #{desc}: '#{$!}' (#{__LINE__})")
184
169
  end
185
170
 
186
- def get_span(browser, how, strg, desc = '')
187
- begin
188
- #TODO: use LegacyExtensions#wait_until
189
- Watir::Wait.until { browser.span(how, strg).exists? }
190
- rescue => e
191
- if not rescue_me(e, __method__, "browser.span(#{how}, '#{strg}').exists?", "#{browser.class}")
192
- raise e
193
- end
194
- end
195
- begin
196
- span = browser.span(how, strg)
197
- rescue => e
198
- if not rescue_me(e, __method__, "browser.span(#{how}, '#{strg}').exists?", "#{browser.class}")
199
- raise e
200
- end
201
- end
202
- if validate(browser, @myName, __LINE__)
203
- passed_to_log("Span #{how}='#{strg}' found and returned. #{desc}")
204
- return span
205
- end
206
- rescue
207
- failed_to_log("Unable to return span #{how}='#{strg}'. #{desc}: '#{$!}' (#{__LINE__})")
171
+ # Return a reference to a _form_ element identified by the contents *what* of its attribute *how*.
172
+ # @param (see #get_span)
173
+ # @return [Watir::Form]
174
+ def get_form(browser, how, what, desc = '')
175
+ get_element(browser, :form, how, what, desc)
208
176
  end
209
177
 
210
- def get_span_by_id(browser, strg, desc = '')
211
- get_span(browser, :id, strg, desc)
178
+ # Return a reference to a _frame_ element identified by the contents *what* of its attribute *how*.
179
+ # @param (see #get_span)
180
+ # @return [Watir::Frame]
181
+ def get_frame(browser, how, what, desc = '')
182
+ get_element(browser, :frame, how, what, desc)
212
183
  end
213
184
 
214
- =begin rdoc
215
- :category: A_rdoc_test
216
- Returns a reference to a table element. Used to assign a table element to a variable
217
- which can then be used directly or passed to methods that require a *browser* or *table* parameter.
218
-
219
- _Parameters_::
220
-
221
- *browser* - a reference to the browser window or container element to be tested
222
-
223
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
224
- Common values: :text, :id, :title, :name, :class, :href (:link only)
225
-
226
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
227
-
228
- *desc* - a string containing a message or description intended to appear in the log and/or report output
229
-
230
- _Example_
231
-
232
- a_table = get_table(browser, :id, 'table1')
233
- a_table_cell = a_table[2][1] # The cell in the first column of the second row of the table
234
-
235
- =end
236
-
237
- def get_table(browser, how, what, desc = '')
238
- msg = "Return table :#{how}='#{what}'. #{desc}"
239
- tbl = browser.table(how, what)
240
- if validate(browser, @myName, __LINE__)
241
- passed_to_log(msg)
242
- tbl
243
- end
244
- rescue
245
- failed_to_log("#{msg}': '#{$!}'")
246
- end
247
-
248
- def get_table_by_id(browser, strg, desc = '')
249
- get_table(browser, :id, strg, desc)
250
- end
251
-
252
- def get_table_by_index(browser, idx)
253
- get_table(browser, :index, idx, desc)
254
- end
255
-
256
- def get_table_by_text(browser, strg)
257
- get_table(browser, :text, strg, desc)
258
- end
259
-
260
- def get_table_headers(table, header_index = 1)
261
- headers = Hash.new
262
- headers['index'] = Hash.new
263
- headers['name'] = Hash.new
264
- count = 1
265
- table[header_index].each do |cell|
266
- if cell.text.length > 0
267
- name = cell.text.gsub(/\s+/, ' ')
268
- headers['index'][count] = name
269
- headers['name'][name] = count
270
- end
271
- count += 1
272
- end
273
- #debug_to_log("#{__method__}:****** headers:\n#{headers.to_yaml}")
274
- headers
275
- rescue
276
- failed_to_log("Unable to get content headers. '#{$!}'")
277
- end
278
-
279
- def get_element(browser, element, how, what, value = nil)
280
- target = nil
281
- what = Regexp.new(Regexp.escape(what)) unless how == :index or what.is_a?(Regexp)
282
- case element
283
- when :link
284
- target = browser.link(how, what)
285
- when :button
286
- target = browser.button(how, what)
287
- when :div
288
- target = browser.div(how, what)
289
- when :checkbox
290
- target = browser.checkbox(how, what, value)
291
- when :text_field, :textfield
292
- target = browser.text_field(how, what)
293
- when :image
294
- target = browser.image(how, what)
295
- when :file_field, :filefield
296
- target = browser.file_field(how, what)
297
- when :form
298
- target = browser.form(how, what)
299
- when :frame
300
- target = browser.frame(how, what)
301
- when :radio
302
- target = browser.radio(how, what, value)
303
- when :span
304
- target = browser.span(how, what)
305
- when :table
306
- target = browser.table(how, what)
307
- when :li
308
- target = browser.li(how, what)
309
- when :select_list, :selectlist
310
- target = browser.select_list(how, what)
311
- when :hidden
312
- target = browser.hidden(how, what)
313
- when :area
314
- target = browser.area(how, what)
315
- end
316
- if target.exists?
317
- target
318
- else
319
- nil
320
- end
321
- rescue => e
322
- if not rescue_me(e, __method__, "browser.#{element}(#{how}, '#{what}')", "#{browser.class}", target)
323
- raise e
324
- end
185
+ # Return a reference to a _select_list_ element identified by the contents *what* of its attribute *how*.
186
+ # @param (see #get_span)
187
+ # @return [Watir::SelectList]
188
+ def get_select_list(browser, how, what, desc = '')
189
+ get_element(browser, :select_list, how, what, desc)
325
190
  end
326
191
 
327
- def get_objects(browser, which, dbg=false)
192
+ # Return an array (collection) of all the elements of the type *which* contained in the browser or container
193
+ # supplied in *browser*.
194
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
195
+ # @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
196
+ # Some common values are :link, :button, :image, :div, :span.
197
+ # @param [Boolean] dbg If set to true additional debug logging is performed.
198
+ # @return [Array]
199
+ def get_element_collection(browser, element, dbg = false)
328
200
  cnt = 0
329
- case which
330
- when :links
201
+ case element
202
+ when :links, :link
331
203
  list = browser.links
332
204
  sleep(1)
333
- when :tables
205
+ when :tables, :table
334
206
  list = browser.tables
335
- when :divs
207
+ when :divs, :div
336
208
  list = browser.divs
337
- when :buttons
209
+ when :buttons, :button
338
210
  list = browser.buttons
339
- when :checkboxes
211
+ when :checkboxes, :checkbox
340
212
  list = browser.checkboxes
341
- when :radios
213
+ when :radios, :radio
342
214
  list = browser.radios
343
- when :selectlists
215
+ when :selectlists, :select_lists, :selectlist, :select_list
344
216
  list = browser.selectlists
345
- when :textfields
217
+ when :textfields, :text_fields, :textareas, :text_fields, :textfield, :text_field, :textarea, :text_area
346
218
  list = browser.textfields
347
- when :lis
219
+ when :lis, :li
348
220
  list = browser.lis
221
+ when :uls, :ul
222
+ list = browser.uls
349
223
  else
350
- debug_to_log("Unrecognized dom object '#{which}'")
224
+ debug_to_log("Unsupported DOM object '#{which}'")
351
225
  end
352
226
  if dbg
353
227
  list.each do |obj|
@@ -358,6 +232,12 @@ _Example_
358
232
  list
359
233
  end
360
234
 
235
+ alias get_objects get_element_collection
236
+
237
+ # Return the ole object for the specified element.
238
+ # @note Usable only with classic Watir.
239
+ # @todo Detect $watir_script variable and disable if not set to true
240
+ # @param [Symbol] element A reference to the already identified element.
361
241
  def get_ole(element)
362
242
  ole = element.ole_object
363
243
  if ole
@@ -370,6 +250,10 @@ _Example_
370
250
  failed_to_log("Unable to find ole_object for #{element}. #{$!}")
371
251
  end
372
252
 
253
+ # Return a hash of all links in *browser* with *:href* attribute containing the exact url in *href*.
254
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
255
+ # @param [String] href The exact url to be located.
256
+ # @return [Hash] The hash is indexed by the order in which the links were located in *browser*.
373
257
  def find_all_links_with_exact_href(browser, href)
374
258
  links = browser.links
375
259
  hash = Hash.new
@@ -386,6 +270,10 @@ _Example_
386
270
  hash
387
271
  end
388
272
 
273
+ # Return a reference to the first link in *browser* with *:href* attribute containing the exact url in *href*.
274
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
275
+ # @param [String] href The exact url to be located.
276
+ # @return [Watir::Link]
389
277
  def find_link_with_exact_href(browser, href)
390
278
  links = browser.links
391
279
  link = nil
@@ -396,18 +284,159 @@ _Example_
396
284
  my_href = l.href
397
285
  if my_href == an_href
398
286
  link = l
399
- # debug_to_log("#{__method__}:#{__LINE__}\n********\n#{l.to_s}\n\n#{l.to_yaml}")
287
+ # debug_to_log("#{__method__}:#{__LINE__}\n********\n#{l.to_s}\n\n#{l.to_yaml}")
400
288
  break
401
289
  end
402
290
  end
403
291
  link
404
292
  end
405
293
 
406
- def find_index_for_object(browser, obj, how, ord, strg)
407
- obj_sym = (obj.to_s.pluralize).to_sym
294
+ # @!endgroup Core
295
+
296
+ # @!group Legacy (Backward compatible usages)
297
+
298
+ # Return the list of options in a select list identified by its *:id* attribute.
299
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
300
+ # @param [String, Regexp] what A string or a regular expression to be found in the designated attribute that uniquely identifies the element.
301
+ # @param [Boolean] dbg Triggers additional debug logging when set to true.
302
+ # @return [Array]
303
+ def get_select_options_by_id(browser, what, dbg = false)
304
+ get_select_options(browser, :id, what, dbg)
305
+ end
306
+
307
+ # Return the list of options in a select list identified by its *:name* attribute.
308
+ # @param (see #get_select_options_by_id)
309
+ # @return [Array]
310
+ def get_select_options_by_name(browser, what, dbg = false)
311
+ get_select_options(browser, :name, what, dbg)
312
+ end
313
+
314
+ # Return the list of _selected_ options in a select list identified by its *:id* attribute.
315
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
316
+ # @param [String, Regexp] what A string or a regular expression to be found in the designated attribute that uniquely identifies the element.
317
+ # @return [Array]
318
+ def get_selected_options_by_id(browser, what)
319
+ get_selected_options(browser, :id, what)
320
+ end
321
+
322
+ alias get_selected_option_by_id get_selected_options_by_id
323
+
324
+ # Return the list of _selected_ options in a select list identified by its *:name* attribute.
325
+ # @param (see #get_select_options_by_id)
326
+ # @return [Array]
327
+ def get_selected_options_by_name(browser, what)
328
+ get_selected_options(browser, :name, what)
329
+ end
330
+
331
+ alias get_selected_option_by_name get_selected_options_by_name
332
+
333
+ # Return a reference to a div element identified by its *:id* attribute.
334
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
335
+ # @param [String, Regexp] what A string or a regular expression to be found in the designated attribute that uniquely identifies the element.
336
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
337
+ # @param [Boolean] dbg Triggers additional debug logging when set to true.
338
+ # @return [Water::Div]
339
+ def get_div_by_id(browser, what, desc = '', dbg = false)
340
+ get_div(browser, :id, what, desc, dbg)
341
+ end
342
+
343
+ # Return a reference to a div element identified by its *:class* attribute.
344
+ # @param (see #get_div_by_id)
345
+ # @return [Water::Div]
346
+ def get_div_by_class(browser, what, desc = '', dbg = false)
347
+ get_div(browser, :class, what, desc, dbg)
348
+ end
349
+
350
+ # Return a reference to a div element identified by its *:text* attribute.
351
+ # @param (see #get_div_by_id)
352
+ # @return [Water::Div]
353
+ def get_div_by_text(browser, what, desc = '', dbg = false)
354
+ get_div(browser, :text, what, desc, dbg)
355
+ end
356
+
357
+ # Return a reference to a form element identified by its *:id* attribute.
358
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
359
+ # @param [String, Regexp] what A string or a regular expression to be found in the designated attribute that uniquely identifies the element.
360
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
361
+ # @return [Water::Form]
362
+ def get_form_by_id(browser, what, desc = '')
363
+ get_form(browser, :id, what, desc)
364
+ end
365
+
366
+ # Return a reference to a frame element identified by its *:id* attribute.
367
+ # @param (see #get_form_by_id)
368
+ # @return [Water::Frame]
369
+ def get_frame_by_id(browser, what, desc = '')
370
+ get_frame(browser, :id, what, desc)
371
+ end
372
+
373
+ # Return a reference to a frame element identified by its *:index* within *browser*.
374
+ # @param (see #get_form_by_id)
375
+ # @return [Water::Frame]
376
+ def get_frame_by_index(browser, what, desc = '')
377
+ get_frame(browser, :index, what, desc)
378
+ end
379
+
380
+ # Return a reference to a frame element identified by its *:name* attribute.
381
+ # @param (see #get_form_by_id)
382
+ # @return [Water::Frame]
383
+ def get_frame_by_name(browser, what, desc = '')
384
+ get_frame(browser, :name, what, desc)
385
+ end
386
+
387
+ # Return a reference to a span element identified by its *:id* attribute.
388
+ # @param (see #get_form_by_id)
389
+ # @return [Water::Span]
390
+ def get_span_by_id(browser, what, desc = '')
391
+ get_span(browser, :id, what, desc)
392
+ end
393
+
394
+ # Return a reference to a table element identified by its attribute *how* containing *what*.
395
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
396
+ # @param [Symbol] how The element attribute used to identify the specific element.
397
+ # Valid values depend on the kind of element.
398
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
399
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
400
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
401
+ # @return [Watir::Table]
402
+ def get_table(browser, how, what, desc = '')
403
+ get_element(browser, :table, how, what, nil, desc)
404
+ end
405
+
406
+ # Return a reference to a table element identified by its *:id* attribute.
407
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
408
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
409
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
410
+ # @return [Watir::Table]
411
+ def get_table_by_id(browser, what, desc = '')
412
+ get_element(browser, :table, :id, what, nil, desc)
413
+ end
414
+
415
+ # Return a reference to a table element identified by its *:index* within *browser*.
416
+ # @param (see #get_table)
417
+ # @return [Watir::Table]
418
+ def get_table_by_index(browser, what, desc = '')
419
+ get_element(browser, :table, :index, what, nil, desc)
420
+ end
421
+
422
+ # Return a reference to a table element identified by its *:text* attribute.
423
+ # @param (see #get_table)
424
+ # @return [Watir::Table]
425
+ def get_table_by_text(browser, what)
426
+ get_element(browser, :table, :text, what, nil, desc)
427
+ end
428
+
429
+ # @!endgroup Legacy
430
+
431
+ # @!group Deprecated
432
+
433
+ # Find the index of an element within *browser* which has attribute *how* containing *what*
434
+ # @deprecated
435
+ def find_index_for_element(browser, element, how, ord, what)
436
+ element_sym = (element.to_s.pluralize).to_sym
408
437
  how_str = how.to_s
409
- ptrn = /#{how}:\s+#{strg}/i
410
- list = get_objects(browser, obj_sym, true)
438
+ ptrn = /#{how}:\s+#{what}/i
439
+ list = get_element_collection(browser, element_sym, true)
411
440
  cnt = 0
412
441
  idx = 0
413
442
  list.each do |nty|
@@ -424,6 +453,9 @@ _Example_
424
453
  idx
425
454
  end
426
455
 
456
+ alias find_index_for_object find_index_for_element
457
+
458
+ # @!endgroup Deprecated
427
459
 
428
460
  end
429
461
  end