firewatir 1.6.2 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +32 -0
- data/lib/firewatir.rb +40 -50
- data/lib/firewatir/container.rb +491 -534
- data/lib/firewatir/document.rb +239 -0
- data/lib/firewatir/element.rb +1365 -0
- data/lib/firewatir/element_collections.rb +314 -0
- data/lib/firewatir/elements/button.rb +15 -0
- data/lib/firewatir/elements/file_field.rb +29 -0
- data/lib/firewatir/elements/form.rb +40 -0
- data/lib/firewatir/elements/frame.rb +55 -0
- data/lib/firewatir/elements/hidden.rb +56 -0
- data/lib/firewatir/elements/image.rb +139 -0
- data/lib/firewatir/elements/input_element.rb +44 -0
- data/lib/firewatir/elements/link.rb +76 -0
- data/lib/firewatir/elements/non_control_element.rb +53 -0
- data/lib/firewatir/elements/non_control_elements.rb +108 -0
- data/lib/firewatir/elements/not_used.rb +278 -0
- data/lib/firewatir/elements/option.rb +131 -0
- data/lib/firewatir/elements/radio_check_common.rb +163 -0
- data/lib/firewatir/elements/select_list.rb +188 -0
- data/lib/firewatir/elements/table.rb +218 -0
- data/lib/firewatir/elements/table_cell.rb +54 -0
- data/lib/firewatir/elements/table_row.rb +100 -0
- data/lib/firewatir/elements/text_field.rb +218 -0
- data/lib/firewatir/exceptions.rb +10 -10
- data/lib/firewatir/firefox.rb +1040 -1127
- data/lib/firewatir/jssh_socket.rb +101 -0
- data/lib/firewatir/version.rb +5 -5
- data/unittests/attach_to_new_window_test.rb +49 -42
- data/unittests/bug_fixes_test.rb +195 -198
- data/unittests/buttons_xpath_test.rb +88 -88
- data/unittests/checkbox_test.rb +158 -155
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/div_test.rb +275 -276
- data/unittests/filefield_test.rb +49 -45
- data/unittests/filefield_xpath_test.rb +35 -35
- data/unittests/form_test.rb +296 -308
- data/unittests/frame_test.rb +159 -152
- data/unittests/hidden_test.rb +85 -85
- data/unittests/hidden_xpath_test.rb +72 -72
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +61 -61
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/div.html +72 -72
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +45 -45
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/iframeTest.html +14 -14
- data/unittests/html/iframeTest1.html +13 -13
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/links1.html +42 -42
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +1 -0
- data/unittests/html/new_browser_popup.html +8 -0
- data/unittests/html/pass.html +9 -9
- data/unittests/html/pre.html +27 -27
- data/unittests/html/redirect.html +10 -10
- data/unittests/html/redirect1.html +8 -8
- data/unittests/html/redirect2.html +8 -8
- data/unittests/html/redirect3.html +8 -8
- data/unittests/html/simple_table_columns.html +74 -74
- data/unittests/html/table1.html +165 -165
- data/unittests/html/textfields1.html +62 -62
- data/unittests/images_test.rb +198 -205
- data/unittests/images_xpath_test.rb +118 -119
- data/unittests/javascript_test.rb +75 -75
- data/unittests/links_test.rb +231 -232
- data/unittests/links_xpath_test.rb +79 -79
- data/unittests/mozilla_all_tests.rb +7 -7
- data/unittests/pre_test.rb +75 -76
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/redirect_test.rb +41 -41
- data/unittests/selectbox_test.rb +142 -142
- data/unittests/selectbox_xpath_test.rb +129 -129
- data/unittests/setup.rb +29 -30
- data/unittests/table_test.rb +385 -373
- data/unittests/table_xpath_test.rb +185 -185
- data/unittests/textfields_test.rb +234 -233
- data/unittests/textfields_xpath_test.rb +113 -113
- metadata +33 -11
- data/lib/firewatir/MozillaBaseElement.rb +0 -1863
- data/lib/firewatir/htmlelements.rb +0 -1911
- data/unittests/iostring.rb +0 -30
- data/unittests/iostring_test.rb +0 -48
@@ -1,1911 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#
|
3
|
-
# Contains class definition of each HTML element that FireWatir can address.
|
4
|
-
# All classes inehrit from Element base class defined in MozillaBaseElement.rb
|
5
|
-
# User should not create instance of these classes. As they are created by using
|
6
|
-
# container#element methods. For e.g. container#button, container#link etc.
|
7
|
-
#
|
8
|
-
# All the methods in the classes first checks if element exists or not. If not then
|
9
|
-
# raises UnknownObjectException.
|
10
|
-
#
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'active_support'
|
14
|
-
module FireWatir
|
15
|
-
|
16
|
-
class Frame < Element
|
17
|
-
|
18
|
-
attr_accessor :element_name
|
19
|
-
#
|
20
|
-
# Description:
|
21
|
-
# Initializes the instance of frame or iframe object.
|
22
|
-
#
|
23
|
-
# Input:
|
24
|
-
# - how - Attribute to identify the frame element.
|
25
|
-
# - what - Value of that attribute.
|
26
|
-
#
|
27
|
-
def initialize(container, how, what)
|
28
|
-
@how = how
|
29
|
-
@what = what
|
30
|
-
@container = container
|
31
|
-
end
|
32
|
-
|
33
|
-
def locate
|
34
|
-
if(@how == :jssh_name)
|
35
|
-
@element_name = @what
|
36
|
-
else
|
37
|
-
@element_name = locate_frame(@how, @what)
|
38
|
-
end
|
39
|
-
#puts @element_name
|
40
|
-
@o = self
|
41
|
-
|
42
|
-
unless @element_name
|
43
|
-
raise UnknownFrameException, "Unable to locate a frame using #{@how} and #{@what}. "
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def html
|
48
|
-
assert_exists
|
49
|
-
get_frame_html
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class Form < Element
|
54
|
-
|
55
|
-
attr_accessor :element_name
|
56
|
-
#
|
57
|
-
# Description:
|
58
|
-
# Initializes the instance of form object.
|
59
|
-
#
|
60
|
-
# Input:
|
61
|
-
# - how - Attribute to identify the form element.
|
62
|
-
# - what - Value of that attribute.
|
63
|
-
#
|
64
|
-
def initialize(container, how, what)
|
65
|
-
@how = how
|
66
|
-
@what = what
|
67
|
-
@container = container
|
68
|
-
end
|
69
|
-
|
70
|
-
def locate
|
71
|
-
# Get form using xpath.
|
72
|
-
if @how == :jssh_name
|
73
|
-
@element_name = @what
|
74
|
-
elsif @how == :xpath
|
75
|
-
@element_name = element_by_xpath(container, @what)
|
76
|
-
else
|
77
|
-
@element_name = locate_tagged_element("form", @how, @what)
|
78
|
-
end
|
79
|
-
@o = self
|
80
|
-
end
|
81
|
-
|
82
|
-
# Submit the form. Equivalent to pressing Enter or Return to submit a form.
|
83
|
-
def submit
|
84
|
-
assert_exists
|
85
|
-
submit_form
|
86
|
-
@o.wait
|
87
|
-
end
|
88
|
-
|
89
|
-
end # class Form
|
90
|
-
|
91
|
-
# Base class containing items that are common between the span, div, label, p and pre classes.
|
92
|
-
class NonControlElement < Element
|
93
|
-
def self.inherited subclass
|
94
|
-
class_name = subclass.to_s.demodulize
|
95
|
-
method_name = class_name.underscore
|
96
|
-
FireWatir::Container.module_eval "def #{method_name}(how, what=nil)
|
97
|
-
locate if defined?(locate)
|
98
|
-
return #{class_name}.new(self, how, what); end"
|
99
|
-
end
|
100
|
-
|
101
|
-
attr_accessor :element_name
|
102
|
-
#def get_element_name
|
103
|
-
# return @element_name
|
104
|
-
#end
|
105
|
-
#
|
106
|
-
# Description:
|
107
|
-
# Locate the element on the page. Element can be a span, div, label, p or pre HTML tag.
|
108
|
-
#
|
109
|
-
def locate
|
110
|
-
if(@how == :jssh_name)
|
111
|
-
@element_name = @what
|
112
|
-
elsif @how == :xpath
|
113
|
-
@element_name = element_by_xpath(@container, @what)
|
114
|
-
else
|
115
|
-
@element_name = locate_tagged_element(self.class::TAG, @how, @what)
|
116
|
-
end
|
117
|
-
@o = self
|
118
|
-
end
|
119
|
-
|
120
|
-
# - how - Attribute to identify the element.
|
121
|
-
# - what - Value of that attribute.
|
122
|
-
def initialize(container, how, what)
|
123
|
-
#@element = Element.new(nil)
|
124
|
-
@how = how
|
125
|
-
@what = what
|
126
|
-
@container = container
|
127
|
-
@o = nil
|
128
|
-
end
|
129
|
-
|
130
|
-
# Returns a string of properties of the object.
|
131
|
-
def to_s(attributes = nil)
|
132
|
-
assert_exists
|
133
|
-
hash_properties = {"text"=>"innerHTML"}
|
134
|
-
hash_properties.update(attributes) if attributes != nil
|
135
|
-
r = super(hash_properties)
|
136
|
-
#r = string_creator
|
137
|
-
#r += span_div_string_creator
|
138
|
-
return r.join("\n")
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
class Pre < NonControlElement
|
144
|
-
TAG = 'PRE'
|
145
|
-
end
|
146
|
-
|
147
|
-
class P < NonControlElement
|
148
|
-
TAG = 'P'
|
149
|
-
end
|
150
|
-
|
151
|
-
class Div < NonControlElement
|
152
|
-
TAG = 'DIV'
|
153
|
-
end
|
154
|
-
|
155
|
-
class Span < NonControlElement
|
156
|
-
TAG = 'SPAN'
|
157
|
-
end
|
158
|
-
|
159
|
-
class Label < NonControlElement
|
160
|
-
TAG = 'LABEL'
|
161
|
-
|
162
|
-
#
|
163
|
-
# Description:
|
164
|
-
# Used to populate the properties in the to_s method.
|
165
|
-
#
|
166
|
-
#def label_string_creator
|
167
|
-
# n = []
|
168
|
-
# n << "for:".ljust(TO_S_SIZE) + self.for
|
169
|
-
# n << "inner text:".ljust(TO_S_SIZE) + self.text
|
170
|
-
# return n
|
171
|
-
#end
|
172
|
-
#private :label_string_creator
|
173
|
-
|
174
|
-
#
|
175
|
-
# Description:
|
176
|
-
# Creates string of properties of the object.
|
177
|
-
#
|
178
|
-
def to_s
|
179
|
-
assert_exists
|
180
|
-
super({"for" => "htmlFor","text" => "innerHTML"})
|
181
|
-
# r=r + label_string_creator
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
class Table < Element
|
186
|
-
attr_accessor :element_name
|
187
|
-
TAG = 'TABLE'
|
188
|
-
|
189
|
-
# - how - Attribute to identify the table element.
|
190
|
-
# - what - Value of that attribute.
|
191
|
-
def initialize(container, how, what)
|
192
|
-
@how = how
|
193
|
-
@what = what
|
194
|
-
@container = container
|
195
|
-
@o = nil
|
196
|
-
#super nil
|
197
|
-
end
|
198
|
-
|
199
|
-
#
|
200
|
-
# Description:
|
201
|
-
# Locate the table element.
|
202
|
-
#
|
203
|
-
def locate
|
204
|
-
if @how == :jssh_name
|
205
|
-
@element_name = @what
|
206
|
-
elsif @how == :xpath
|
207
|
-
@element_name = element_by_xpath(@container, @what)
|
208
|
-
else
|
209
|
-
@element_name = locate_tagged_element('TABLE', @how, @what)
|
210
|
-
end
|
211
|
-
@o = self
|
212
|
-
end
|
213
|
-
|
214
|
-
#
|
215
|
-
# Description:
|
216
|
-
# Override the highlight method, as if the tables rows are set to have a background color,
|
217
|
-
# this will override the table background color, and the normal flash method wont work
|
218
|
-
#
|
219
|
-
def highlight(set_or_clear )
|
220
|
-
|
221
|
-
if set_or_clear == :set
|
222
|
-
begin
|
223
|
-
@original_border = @o.border.to_i
|
224
|
-
if @o.border.to_i==1
|
225
|
-
@o.border = 2
|
226
|
-
else
|
227
|
-
@o.border=1
|
228
|
-
end
|
229
|
-
rescue
|
230
|
-
@original_border = nil
|
231
|
-
end
|
232
|
-
else
|
233
|
-
begin
|
234
|
-
@o.border= @original_border unless @original_border == nil
|
235
|
-
@original_border = nil
|
236
|
-
rescue
|
237
|
-
# we could be here for a number of reasons...
|
238
|
-
ensure
|
239
|
-
@original_border = nil
|
240
|
-
end
|
241
|
-
end
|
242
|
-
super
|
243
|
-
end
|
244
|
-
|
245
|
-
#
|
246
|
-
# Description:
|
247
|
-
# Used to populate the properties in the to_s method.
|
248
|
-
#
|
249
|
-
#def table_string_creator
|
250
|
-
# n = []
|
251
|
-
# n << "rows:".ljust(TO_S_SIZE) + self.row_count.to_s
|
252
|
-
# n << "cols:".ljust(TO_S_SIZE) + self.column_count.to_s
|
253
|
-
# return n
|
254
|
-
#end
|
255
|
-
#private :table_string_creator
|
256
|
-
|
257
|
-
# returns the properties of the object in a string
|
258
|
-
# raises an ObjectNotFound exception if the object cannot be found
|
259
|
-
# TODO: Implement to_s method for this class.
|
260
|
-
|
261
|
-
def to_s
|
262
|
-
assert_exists
|
263
|
-
r = super({"rows" => "rows.length","columns" => "columnLength", "cellspacing" => "cellspacing", "cellpadding" => "cellpadding", "border" => "border"})
|
264
|
-
# r += self.column_count.to_s
|
265
|
-
end
|
266
|
-
|
267
|
-
#
|
268
|
-
# Description:
|
269
|
-
# Gets the number of rows in the table.
|
270
|
-
#
|
271
|
-
# Output:
|
272
|
-
# Number of rows.
|
273
|
-
#
|
274
|
-
def row_count
|
275
|
-
assert_exists
|
276
|
-
return rows.length
|
277
|
-
end
|
278
|
-
|
279
|
-
#
|
280
|
-
# Description:
|
281
|
-
# Gets the table as a 2 dimensional array. Dont expect too much if there are nested tables, colspan etc.
|
282
|
-
#
|
283
|
-
# Output:
|
284
|
-
# 2D array with rows and column text of the table.
|
285
|
-
#
|
286
|
-
def to_a
|
287
|
-
assert_exists
|
288
|
-
y = []
|
289
|
-
table_rows = rows
|
290
|
-
for row in table_rows
|
291
|
-
x = []
|
292
|
-
row.each do |td|
|
293
|
-
x << td.to_s.strip
|
294
|
-
end
|
295
|
-
y << x
|
296
|
-
end
|
297
|
-
return y
|
298
|
-
end
|
299
|
-
|
300
|
-
#
|
301
|
-
# Description:
|
302
|
-
# Gets the array of rows in the table.
|
303
|
-
#
|
304
|
-
# Output:
|
305
|
-
# Array of rows.
|
306
|
-
#
|
307
|
-
def rows
|
308
|
-
assert_exists
|
309
|
-
arr_rows = get_rows
|
310
|
-
table_rows = Array.new(arr_rows.length)
|
311
|
-
for i in 0..arr_rows.length - 1 do
|
312
|
-
table_rows[i] = TableRow.new(@container, :jssh_name, arr_rows[i])
|
313
|
-
end
|
314
|
-
return table_rows
|
315
|
-
end
|
316
|
-
|
317
|
-
#
|
318
|
-
# Description:
|
319
|
-
# Get row at particular index in table.
|
320
|
-
#
|
321
|
-
# Input:
|
322
|
-
# key - row index
|
323
|
-
#
|
324
|
-
# Output:
|
325
|
-
# Table Row element
|
326
|
-
#
|
327
|
-
def [](key)
|
328
|
-
assert_exists
|
329
|
-
arr_rows = rows
|
330
|
-
return arr_rows[key - 1]
|
331
|
-
end
|
332
|
-
|
333
|
-
#
|
334
|
-
# Desription:
|
335
|
-
# Iterate over each table row element.
|
336
|
-
#
|
337
|
-
def each
|
338
|
-
assert_exists
|
339
|
-
arr_rows = rows
|
340
|
-
for i in 0..arr_rows.length - 1 do
|
341
|
-
yield arr_rows[i]
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
#
|
346
|
-
# Description:
|
347
|
-
# Get column count of first row in the table.
|
348
|
-
#
|
349
|
-
# Output:
|
350
|
-
# Number of columns in first row.
|
351
|
-
#
|
352
|
-
def column_count
|
353
|
-
assert_exists
|
354
|
-
arr_rows = rows
|
355
|
-
return arr_rows[0].column_count
|
356
|
-
end
|
357
|
-
|
358
|
-
#
|
359
|
-
# Description:
|
360
|
-
# Get values of specified column in each row.
|
361
|
-
#
|
362
|
-
# Input:
|
363
|
-
# Column number
|
364
|
-
#
|
365
|
-
# Output:
|
366
|
-
# Values of column (specified as input) in each row
|
367
|
-
#
|
368
|
-
def column_values(column)
|
369
|
-
assert_exists
|
370
|
-
arr_rows = rows
|
371
|
-
values = Array.new(arr_rows.length)
|
372
|
-
for i in 0..arr_rows.length - 1 do
|
373
|
-
values[i] = arr_rows[i][column].to_s
|
374
|
-
end
|
375
|
-
return values
|
376
|
-
end
|
377
|
-
|
378
|
-
#
|
379
|
-
# Description:
|
380
|
-
# Get values of all the column in specified row.
|
381
|
-
#
|
382
|
-
# Input:
|
383
|
-
# Row number.
|
384
|
-
#
|
385
|
-
# Output:
|
386
|
-
# Value of all columns present in the row.
|
387
|
-
#
|
388
|
-
def row_values(row)
|
389
|
-
assert_exists
|
390
|
-
arr_rows = rows
|
391
|
-
cells = arr_rows[row - 1].cells
|
392
|
-
values = Array.new(cells.length)
|
393
|
-
for i in 0..cells.length - 1 do
|
394
|
-
values[i] = cells[i].to_s
|
395
|
-
end
|
396
|
-
return values
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
# this class is a collection of the table body objects that exist in the table
|
401
|
-
# it wouldnt normally be created by a user, but gets returned by the bodies method of the Table object
|
402
|
-
# many of the methods available to this object are inherited from the Element class
|
403
|
-
# TODO: Implement TableBodies class.
|
404
|
-
#class TableBodies < Element
|
405
|
-
#
|
406
|
-
# Description:
|
407
|
-
# Initializes the form element.
|
408
|
-
#
|
409
|
-
# Input:
|
410
|
-
# - how - Attribute to identify the form element.
|
411
|
-
# - what - Value of that attribute.
|
412
|
-
#
|
413
|
-
#def initialize( parent_table)
|
414
|
-
# element = container
|
415
|
-
# @o = parent_table # in this case, @o is the parent table
|
416
|
-
#end
|
417
|
-
|
418
|
-
# returns the number of TableBodies that exist in the table
|
419
|
-
#def length
|
420
|
-
# assert_exists
|
421
|
-
# return @o.tBodies.length
|
422
|
-
#end
|
423
|
-
|
424
|
-
# returns the n'th Body as a FireWatir TableBody object
|
425
|
-
#def []n
|
426
|
-
# assert_exists
|
427
|
-
# return TableBody.new(element, :direct, ole_table_body_at_index(n))
|
428
|
-
#end
|
429
|
-
|
430
|
-
# returns an ole table body
|
431
|
-
#def ole_table_body_at_index(n)
|
432
|
-
# return @o.tBodies[(n-1).to_s]
|
433
|
-
#end
|
434
|
-
|
435
|
-
# iterates through each of the TableBodies in the Table. Yields a TableBody object
|
436
|
-
#def each
|
437
|
-
# 1.upto( @o.tBodies.length ) { |i| yield TableBody.new(element, :direct, ole_table_body_at_index(i)) }
|
438
|
-
#end
|
439
|
-
|
440
|
-
#end
|
441
|
-
|
442
|
-
# this class is a table body
|
443
|
-
# TODO: Implement TableBody class
|
444
|
-
#class TableBody < Element
|
445
|
-
#def locate
|
446
|
-
# @o = nil
|
447
|
-
# if @how == :direct
|
448
|
-
# @o = @what # in this case, @o is the table body
|
449
|
-
# elsif @how == :index
|
450
|
-
# @o = @parent_table.bodies.ole_table_body_at_index(@what)
|
451
|
-
# end
|
452
|
-
# @rows = []
|
453
|
-
# if @o
|
454
|
-
# @o.rows.each do |oo|
|
455
|
-
# @rows << TableRow.new(element, :direct, oo)
|
456
|
-
# end
|
457
|
-
# end
|
458
|
-
#end
|
459
|
-
|
460
|
-
#
|
461
|
-
# Description:
|
462
|
-
# Initializes the form element.
|
463
|
-
#
|
464
|
-
# Input:
|
465
|
-
# - how - Attribute to identify the form element.
|
466
|
-
# - what - Value of that attribute.
|
467
|
-
#
|
468
|
-
#def initialize( how, what, parent_table = nil)
|
469
|
-
# element = container
|
470
|
-
# @how = how
|
471
|
-
# @what = what
|
472
|
-
# @parent_table = parent_table
|
473
|
-
# super nil
|
474
|
-
#end
|
475
|
-
|
476
|
-
# returns the specified row as a TableRow object
|
477
|
-
#def [](n)
|
478
|
-
# assert_exists
|
479
|
-
# return @rows[n - 1]
|
480
|
-
#end
|
481
|
-
|
482
|
-
# iterates through all the rows in the table body
|
483
|
-
#def each
|
484
|
-
# locate
|
485
|
-
# 0.upto(@rows.length - 1) { |i| yield @rows[i] }
|
486
|
-
#end
|
487
|
-
|
488
|
-
# returns the number of rows in this table body.
|
489
|
-
#def length
|
490
|
-
# return @rows.length
|
491
|
-
#end
|
492
|
-
#end
|
493
|
-
|
494
|
-
|
495
|
-
#
|
496
|
-
# Description:
|
497
|
-
# Class for Table row element.
|
498
|
-
#
|
499
|
-
class TableRow < Element
|
500
|
-
attr_accessor :element_name
|
501
|
-
|
502
|
-
#
|
503
|
-
# Description:
|
504
|
-
# Locate the table row element on the page.
|
505
|
-
#
|
506
|
-
def locate
|
507
|
-
@o = nil
|
508
|
-
if @how == :jssh_name
|
509
|
-
@element_name = @what
|
510
|
-
elsif @how == :xpath
|
511
|
-
@element_name = element_by_xpath(@container, @what)
|
512
|
-
else
|
513
|
-
@element_name = locate_tagged_element("TR", @how, @what)
|
514
|
-
end
|
515
|
-
@o = self
|
516
|
-
end
|
517
|
-
|
518
|
-
#
|
519
|
-
# Description:
|
520
|
-
# Initializes the instance of table row object.
|
521
|
-
#
|
522
|
-
# Input:
|
523
|
-
# - how - Attribute to identify the table row element.
|
524
|
-
# - what - Value of that attribute.
|
525
|
-
#
|
526
|
-
def initialize(container, how, what)
|
527
|
-
@how = how
|
528
|
-
@what = what
|
529
|
-
@container = container
|
530
|
-
#super nil
|
531
|
-
end
|
532
|
-
|
533
|
-
#
|
534
|
-
# Description:
|
535
|
-
# Gets the length of columns in table row.
|
536
|
-
#
|
537
|
-
# Output:
|
538
|
-
# Length of columns in table row.
|
539
|
-
#
|
540
|
-
def column_count
|
541
|
-
assert_exists
|
542
|
-
arr_cells = cells
|
543
|
-
return arr_cells.length
|
544
|
-
end
|
545
|
-
|
546
|
-
#
|
547
|
-
# Description:
|
548
|
-
# Get cell at specified index in a row.
|
549
|
-
#
|
550
|
-
# Input:
|
551
|
-
# key - column index.
|
552
|
-
#
|
553
|
-
# Output:
|
554
|
-
# Table cell element at specified index.
|
555
|
-
#
|
556
|
-
def [] (key)
|
557
|
-
assert_exists
|
558
|
-
arr_cells = cells
|
559
|
-
return arr_cells[key - 1]
|
560
|
-
end
|
561
|
-
|
562
|
-
#
|
563
|
-
# Description:
|
564
|
-
# Iterate over each cell in a row.
|
565
|
-
#
|
566
|
-
def each
|
567
|
-
assert_exists
|
568
|
-
arr_cells = cells
|
569
|
-
for i in 0..arr_cells.length - 1 do
|
570
|
-
yield arr_cells[i]
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
#
|
575
|
-
# Description:
|
576
|
-
# Get array of all cells in Table Row
|
577
|
-
#
|
578
|
-
# Output:
|
579
|
-
# Array containing Table Cell elements.
|
580
|
-
#
|
581
|
-
def cells
|
582
|
-
assert_exists
|
583
|
-
arr_cells = get_cells
|
584
|
-
row_cells = Array.new(arr_cells.length)
|
585
|
-
for i in 0..arr_cells.length - 1 do
|
586
|
-
row_cells[i] = TableCell.new(@container, :jssh_name, arr_cells[i])
|
587
|
-
end
|
588
|
-
return row_cells
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
#
|
593
|
-
# Description:
|
594
|
-
# Class for Table Cell.
|
595
|
-
#
|
596
|
-
class TableCell < Element
|
597
|
-
attr_accessor :element_name
|
598
|
-
|
599
|
-
# Description:
|
600
|
-
# Locate the table cell element on the page.
|
601
|
-
#
|
602
|
-
def locate
|
603
|
-
if @how == :jssh_name
|
604
|
-
@element_name = @what
|
605
|
-
elsif @how == :xpath
|
606
|
-
@element_name = element_by_xpath(@container, @what)
|
607
|
-
else
|
608
|
-
@element_name = locate_tagged_element("TD", @how, @what)
|
609
|
-
end
|
610
|
-
@o = self
|
611
|
-
end
|
612
|
-
|
613
|
-
#
|
614
|
-
# Description:
|
615
|
-
# Initializes the instance of table cell object.
|
616
|
-
#
|
617
|
-
# Input:
|
618
|
-
# - how - Attribute to identify the table cell element.
|
619
|
-
# - what - Value of that attribute.
|
620
|
-
#
|
621
|
-
def initialize(container, how, what)
|
622
|
-
@how = how
|
623
|
-
@what = what
|
624
|
-
@container = container
|
625
|
-
#super nil
|
626
|
-
end
|
627
|
-
|
628
|
-
alias to_s text
|
629
|
-
|
630
|
-
#
|
631
|
-
# Description:
|
632
|
-
# Gets the col span of table cell.
|
633
|
-
#
|
634
|
-
# Output:
|
635
|
-
# Colspan of table cell.
|
636
|
-
#
|
637
|
-
def colspan
|
638
|
-
assert_exists
|
639
|
-
@o.colSpan
|
640
|
-
end
|
641
|
-
|
642
|
-
end
|
643
|
-
|
644
|
-
#
|
645
|
-
# Description:
|
646
|
-
# Class for Image element.
|
647
|
-
#
|
648
|
-
class Image < Element
|
649
|
-
attr_accessor :element_name
|
650
|
-
TAG = 'IMG'
|
651
|
-
#
|
652
|
-
# Description:
|
653
|
-
# Initializes the instance of image object.
|
654
|
-
#
|
655
|
-
# Input:
|
656
|
-
# - how - Attribute to identify the image element.
|
657
|
-
# - what - Value of that attribute.
|
658
|
-
#
|
659
|
-
def initialize(container, how, what)
|
660
|
-
@how = how
|
661
|
-
@what = what
|
662
|
-
@container = container
|
663
|
-
end
|
664
|
-
|
665
|
-
# Description:
|
666
|
-
# Locate the image element on the page.
|
667
|
-
#
|
668
|
-
def locate
|
669
|
-
if @how == :jssh_name
|
670
|
-
@element_name = @what
|
671
|
-
elsif @how == :xpath
|
672
|
-
@element_name = element_by_xpath(@container, @what)
|
673
|
-
else
|
674
|
-
@element_name = locate_tagged_element('IMG', @how, @what)
|
675
|
-
end
|
676
|
-
@o = self
|
677
|
-
end
|
678
|
-
|
679
|
-
#
|
680
|
-
# Description:
|
681
|
-
# Used to populate the properties in to_s method. Not used anymore
|
682
|
-
#
|
683
|
-
def image_string_creator
|
684
|
-
n = []
|
685
|
-
n << "src:".ljust(TO_S_SIZE) + self.src.to_s
|
686
|
-
n << "file date:".ljust(TO_S_SIZE) + self.fileCreatedDate.to_s
|
687
|
-
n << "file size:".ljust(TO_S_SIZE) + self.fileSize.to_s
|
688
|
-
n << "width:".ljust(TO_S_SIZE) + self.width.to_s
|
689
|
-
n << "height:".ljust(TO_S_SIZE) + self.height.to_s
|
690
|
-
n << "alt:".ljust(TO_S_SIZE) + self.alt.to_s
|
691
|
-
return n
|
692
|
-
end
|
693
|
-
private :image_string_creator
|
694
|
-
|
695
|
-
# returns a string representation of the object
|
696
|
-
def to_s
|
697
|
-
assert_exists
|
698
|
-
super({"src" => "src","width" => "width","height" => "height","alt" => "alt"})
|
699
|
-
end
|
700
|
-
|
701
|
-
# this method returns the file created date of the image
|
702
|
-
#def fileCreatedDate
|
703
|
-
# assert_exists
|
704
|
-
# return @o.invoke("fileCreatedDate")
|
705
|
-
#end
|
706
|
-
|
707
|
-
# this method returns the filesize of the image
|
708
|
-
#def fileSize
|
709
|
-
# assert_exists
|
710
|
-
# return @o.invoke("fileSize").to_s
|
711
|
-
#end
|
712
|
-
|
713
|
-
#
|
714
|
-
# Description:
|
715
|
-
# Gets the width of the image in pixels, as a string.
|
716
|
-
#
|
717
|
-
# Output:
|
718
|
-
# Width of image (in pixels).
|
719
|
-
#
|
720
|
-
def width
|
721
|
-
assert_exists
|
722
|
-
return @o.invoke("width").to_s
|
723
|
-
end
|
724
|
-
|
725
|
-
#
|
726
|
-
# Description:
|
727
|
-
# Gets the height of the image in pixels, as a string.
|
728
|
-
#
|
729
|
-
# Output:
|
730
|
-
# Height of image (in pixels).
|
731
|
-
#
|
732
|
-
def height
|
733
|
-
assert_exists
|
734
|
-
return @o.invoke("height").to_s
|
735
|
-
end
|
736
|
-
|
737
|
-
# This method attempts to find out if the image was actually loaded by the web browser.
|
738
|
-
# If the image was not loaded, the browser is unable to determine some of the properties.
|
739
|
-
# We look for these missing properties to see if the image is really there or not.
|
740
|
-
# If the Disk cache is full ( tools menu -> Internet options -> Temporary Internet Files) , it may produce incorrect responses.
|
741
|
-
#def hasLoaded?
|
742
|
-
# locate
|
743
|
-
# raise UnknownObjectException, "Unable to locate image using #{@how} and #{@what}" if @o == nil
|
744
|
-
# return false if @o.fileCreatedDate == "" and @o.fileSize.to_i == -1
|
745
|
-
# return true
|
746
|
-
#end
|
747
|
-
|
748
|
-
#
|
749
|
-
# Description:
|
750
|
-
# Highlights the image ( in fact it adds or removes a border around the image)
|
751
|
-
#
|
752
|
-
# Input:
|
753
|
-
# - set_or_clear - :set to set the border, :clear to remove it
|
754
|
-
#
|
755
|
-
def highlight( set_or_clear )
|
756
|
-
if set_or_clear == :set
|
757
|
-
begin
|
758
|
-
@original_border = @o.border
|
759
|
-
@o.border = 1
|
760
|
-
rescue
|
761
|
-
@original_border = nil
|
762
|
-
end
|
763
|
-
else
|
764
|
-
begin
|
765
|
-
@o.border = @original_border
|
766
|
-
@original_border = nil
|
767
|
-
rescue
|
768
|
-
# we could be here for a number of reasons...
|
769
|
-
ensure
|
770
|
-
@original_border = nil
|
771
|
-
end
|
772
|
-
end
|
773
|
-
end
|
774
|
-
private :highlight
|
775
|
-
end
|
776
|
-
|
777
|
-
|
778
|
-
#
|
779
|
-
# Description:
|
780
|
-
# Class for Link element.
|
781
|
-
#
|
782
|
-
class Link < Element
|
783
|
-
attr_accessor :element_name
|
784
|
-
TAG = 'A'
|
785
|
-
#
|
786
|
-
# Description:
|
787
|
-
# Initializes the instance of link element.
|
788
|
-
#
|
789
|
-
# Input:
|
790
|
-
# - how - Attribute to identify the link element.
|
791
|
-
# - what - Value of that attribute.
|
792
|
-
#
|
793
|
-
def initialize(container, how, what)
|
794
|
-
@how = how
|
795
|
-
@what = what
|
796
|
-
@container = container
|
797
|
-
end
|
798
|
-
|
799
|
-
#
|
800
|
-
# Description:
|
801
|
-
# Locate the link element on the page.
|
802
|
-
#
|
803
|
-
def locate
|
804
|
-
if @how == :jssh_name
|
805
|
-
@element_name = @what
|
806
|
-
elsif @how == :xpath
|
807
|
-
@element_name = element_by_xpath(@container, @what)
|
808
|
-
else
|
809
|
-
@element_name = locate_tagged_element('A', @how, @what)
|
810
|
-
end
|
811
|
-
@o = self
|
812
|
-
end
|
813
|
-
|
814
|
-
#TODO: if an image is used as part of the link, this will return true
|
815
|
-
#def link_has_image
|
816
|
-
# assert_exists
|
817
|
-
# return true if @o.getElementsByTagName("IMG").length > 0
|
818
|
-
# return false
|
819
|
-
#end
|
820
|
-
|
821
|
-
#TODO: this method returns the src of an image, if an image is used as part of the link
|
822
|
-
#def src # BUG?
|
823
|
-
# assert_exists
|
824
|
-
# if @o.getElementsByTagName("IMG").length > 0
|
825
|
-
# return @o.getElementsByTagName("IMG")[0.to_s].src
|
826
|
-
# else
|
827
|
-
# return ""
|
828
|
-
# end
|
829
|
-
#end
|
830
|
-
|
831
|
-
#
|
832
|
-
# Description:
|
833
|
-
# Used to populate the properties in to_s method.
|
834
|
-
#
|
835
|
-
#def link_string_creator
|
836
|
-
# n = []
|
837
|
-
# n << "href:".ljust(TO_S_SIZE) + self.href
|
838
|
-
# n << "inner text:".ljust(TO_S_SIZE) + self.text
|
839
|
-
# n << "img src:".ljust(TO_S_SIZE) + self.src if self.link_has_image
|
840
|
-
# return n
|
841
|
-
# end
|
842
|
-
|
843
|
-
# returns a textual description of the link
|
844
|
-
|
845
|
-
def to_s
|
846
|
-
assert_exists
|
847
|
-
super({"href" => "href","inner text" => "text"})
|
848
|
-
end
|
849
|
-
end
|
850
|
-
|
851
|
-
#
|
852
|
-
# Description:
|
853
|
-
# Base class containing items that are common between select list, text field, button, hidden, file field classes.
|
854
|
-
#
|
855
|
-
class InputElement < Element
|
856
|
-
attr_accessor :element_name
|
857
|
-
#
|
858
|
-
# Description:
|
859
|
-
# Locate the element on the page. Element can be a select list, text field, button, hidden, file field.
|
860
|
-
#
|
861
|
-
def locate
|
862
|
-
if @how == :jssh_name
|
863
|
-
@element_name = @what
|
864
|
-
elsif @how == :xpath
|
865
|
-
@element_name = element_by_xpath(@container, @what)
|
866
|
-
else
|
867
|
-
if(self.class::INPUT_TYPES.include?("select-one"))
|
868
|
-
@element_name = locate_tagged_element("select", @how, @what, self.class::INPUT_TYPES)
|
869
|
-
else
|
870
|
-
@element_name = locate_tagged_element("input", @how, @what, self.class::INPUT_TYPES)
|
871
|
-
end
|
872
|
-
end
|
873
|
-
@o = self
|
874
|
-
end
|
875
|
-
#
|
876
|
-
# Description:
|
877
|
-
# Initializes the instance of element.
|
878
|
-
#
|
879
|
-
# Input:
|
880
|
-
# - how - Attribute to identify the element.
|
881
|
-
# - what - Value of that attribute.
|
882
|
-
#
|
883
|
-
def initialize(container, how, what)
|
884
|
-
@how = how
|
885
|
-
@what = what
|
886
|
-
@container = container
|
887
|
-
@element_name = ""
|
888
|
-
#super(nil)
|
889
|
-
end
|
890
|
-
end
|
891
|
-
|
892
|
-
#
|
893
|
-
# Description:
|
894
|
-
# Class for SelectList element.
|
895
|
-
#
|
896
|
-
class SelectList < InputElement
|
897
|
-
INPUT_TYPES = ["select-one", "select-multiple"]
|
898
|
-
|
899
|
-
attr_accessor :o
|
900
|
-
|
901
|
-
#
|
902
|
-
# Description:
|
903
|
-
# Clears the selected items in the select box.
|
904
|
-
#
|
905
|
-
def clearSelection
|
906
|
-
assert_exists
|
907
|
-
#highlight( :set)
|
908
|
-
wait = false
|
909
|
-
@o.each do |selectBoxItem|
|
910
|
-
if selectBoxItem.selected
|
911
|
-
selectBoxItem.selected = false
|
912
|
-
wait = true
|
913
|
-
end
|
914
|
-
end
|
915
|
-
@o.wait if wait
|
916
|
-
#highlight( :clear)
|
917
|
-
end
|
918
|
-
|
919
|
-
def each
|
920
|
-
assert_exists
|
921
|
-
arr_options = options
|
922
|
-
#puts arr_options[0]#.length
|
923
|
-
for i in 0..arr_options.length - 1 do
|
924
|
-
yield Option.new(self, :jssh_name, arr_options[i])
|
925
|
-
end
|
926
|
-
end
|
927
|
-
|
928
|
-
#
|
929
|
-
# Description:
|
930
|
-
# Get option element at specified index in select list.
|
931
|
-
#
|
932
|
-
# Input:
|
933
|
-
# key - option index
|
934
|
-
#
|
935
|
-
# Output:
|
936
|
-
# Option element at specified index
|
937
|
-
#
|
938
|
-
def [] (key)
|
939
|
-
assert_exists
|
940
|
-
arr_options = options
|
941
|
-
return Option.new(self, :jssh_name, arr_options[key - 1])
|
942
|
-
end
|
943
|
-
|
944
|
-
#
|
945
|
-
# Description:
|
946
|
-
# Selects an item by text. If you need to select multiple items you need to call this function for each item.
|
947
|
-
#
|
948
|
-
# Input:
|
949
|
-
# - item - Text of item to be selected.
|
950
|
-
#
|
951
|
-
def select( item )
|
952
|
-
select_item_in_select_list(:text, item)
|
953
|
-
end
|
954
|
-
|
955
|
-
#
|
956
|
-
# Description:
|
957
|
-
# Selects an item by value. If you need to select multiple items you need to call this function for each item.
|
958
|
-
#
|
959
|
-
# Input:
|
960
|
-
# - item - Value of the item to be selected.
|
961
|
-
#
|
962
|
-
def select_value( item )
|
963
|
-
select_item_in_select_list( :value , item )
|
964
|
-
end
|
965
|
-
|
966
|
-
# Description:
|
967
|
-
# Selects item from the select box.
|
968
|
-
#
|
969
|
-
# Input:
|
970
|
-
# - name - :value or :text - how we find an item in the select box
|
971
|
-
# - item - value of either item text or item value.
|
972
|
-
#
|
973
|
-
def select_item_in_select_list(attribute, value)
|
974
|
-
assert_exists
|
975
|
-
highlight( :set )
|
976
|
-
doBreak = false
|
977
|
-
#element.log "Setting box #{@o.name} to #{attribute} #{value} "
|
978
|
-
@o.each do |option| # items in the list
|
979
|
-
if value.matches( option.invoke(attribute.to_s))
|
980
|
-
if option.selected
|
981
|
-
doBreak = true
|
982
|
-
break
|
983
|
-
else
|
984
|
-
option.selected = true
|
985
|
-
@o.fireEvent("onChange")
|
986
|
-
@o.wait
|
987
|
-
doBreak = true
|
988
|
-
break
|
989
|
-
end
|
990
|
-
end
|
991
|
-
end
|
992
|
-
unless doBreak
|
993
|
-
raise NoValueFoundException,
|
994
|
-
"No option with #{attribute.to_s} of #{value} in this select element"
|
995
|
-
end
|
996
|
-
highlight( :clear )
|
997
|
-
end
|
998
|
-
private :select_item_in_select_list
|
999
|
-
|
1000
|
-
#
|
1001
|
-
# Description:
|
1002
|
-
# Gets all the items in the select list as an array.
|
1003
|
-
# An empty array is returned if the select box has no contents.
|
1004
|
-
#
|
1005
|
-
# Output:
|
1006
|
-
# Array containing the items of the select list.
|
1007
|
-
#
|
1008
|
-
def getAllContents() # BUG: camel_case.rb
|
1009
|
-
assert_exists
|
1010
|
-
#element.log "There are #{@o.length} items"
|
1011
|
-
returnArray = []
|
1012
|
-
@o.each { |thisItem| returnArray << thisItem.text }
|
1013
|
-
return returnArray
|
1014
|
-
end
|
1015
|
-
|
1016
|
-
#
|
1017
|
-
# Description:
|
1018
|
-
# Gets all the selected items in the select list as an array.
|
1019
|
-
# An empty array is returned if the select box has no selected item.
|
1020
|
-
#
|
1021
|
-
# Output:
|
1022
|
-
# Array containing the selected items of the select list.
|
1023
|
-
#
|
1024
|
-
def getSelectedItems
|
1025
|
-
assert_exists
|
1026
|
-
returnArray = []
|
1027
|
-
#element.log "There are #{@o.length} items"
|
1028
|
-
@o.each do |thisItem|
|
1029
|
-
#puts "#{thisItem.selected}"
|
1030
|
-
if thisItem.selected
|
1031
|
-
#element.log "Item ( #{thisItem.text} ) is selected"
|
1032
|
-
returnArray << thisItem.text
|
1033
|
-
end
|
1034
|
-
end
|
1035
|
-
return returnArray
|
1036
|
-
end
|
1037
|
-
|
1038
|
-
#
|
1039
|
-
# Description:
|
1040
|
-
# Get the option using attribute and its value.
|
1041
|
-
#
|
1042
|
-
# Input:
|
1043
|
-
# - attribute - Attribute used to find the option.
|
1044
|
-
# - value - value of that attribute.
|
1045
|
-
#
|
1046
|
-
def option (attribute, value)
|
1047
|
-
assert_exists
|
1048
|
-
Option.new(self, attribute, value)
|
1049
|
-
end
|
1050
|
-
end
|
1051
|
-
|
1052
|
-
#
|
1053
|
-
# Description:
|
1054
|
-
# Class for Option element.
|
1055
|
-
#
|
1056
|
-
class Option < SelectList
|
1057
|
-
#
|
1058
|
-
# Description:
|
1059
|
-
# Initializes the instance of option object.
|
1060
|
-
#
|
1061
|
-
# Input:
|
1062
|
-
# - select_list - instance of select list element.
|
1063
|
-
# - attribute - Attribute to identify the option.
|
1064
|
-
# - value - Value of that attribute.
|
1065
|
-
#
|
1066
|
-
def initialize (select_list, attribute, value)
|
1067
|
-
@select_list = @container = select_list
|
1068
|
-
@how = attribute
|
1069
|
-
@what = value
|
1070
|
-
@option = nil
|
1071
|
-
@element_name = ""
|
1072
|
-
|
1073
|
-
unless [:text, :value, :jssh_name].include? attribute
|
1074
|
-
raise MissingWayOfFindingObjectException,
|
1075
|
-
"Option does not support attribute #{@how}"
|
1076
|
-
end
|
1077
|
-
#puts @select_list.o.length
|
1078
|
-
#puts "what is : #{@what}, how is #{@how}, list name is : #{@select_list.element_name}"
|
1079
|
-
if(attribute == :jssh_name)
|
1080
|
-
@element_name = @what
|
1081
|
-
@option = self
|
1082
|
-
else
|
1083
|
-
@select_list.o.each do |option| # items in the list
|
1084
|
-
#puts "option is : #{option}"
|
1085
|
-
if(attribute == :value)
|
1086
|
-
match_value = option.value
|
1087
|
-
else
|
1088
|
-
match_value = option.text
|
1089
|
-
end
|
1090
|
-
#puts "value is #{match_value}"
|
1091
|
-
if value.matches( match_value) #option.invoke(attribute))
|
1092
|
-
@option = option
|
1093
|
-
@element_name = option.element_name
|
1094
|
-
break
|
1095
|
-
end
|
1096
|
-
end
|
1097
|
-
end
|
1098
|
-
end
|
1099
|
-
|
1100
|
-
#
|
1101
|
-
# Description:
|
1102
|
-
# Checks if option exists or not.
|
1103
|
-
#
|
1104
|
-
def assert_exists
|
1105
|
-
unless @option
|
1106
|
-
raise UnknownObjectException,
|
1107
|
-
"Unable to locate an option using #{@how} and #{@what}"
|
1108
|
-
end
|
1109
|
-
end
|
1110
|
-
private :assert_exists
|
1111
|
-
|
1112
|
-
#
|
1113
|
-
# Description:
|
1114
|
-
# Selects the option.
|
1115
|
-
#
|
1116
|
-
def select
|
1117
|
-
assert_exists
|
1118
|
-
if(@how == :text)
|
1119
|
-
@select_list.select(@what)
|
1120
|
-
elsif(@how == :value)
|
1121
|
-
@select_list.select_value(@what)
|
1122
|
-
end
|
1123
|
-
end
|
1124
|
-
|
1125
|
-
#
|
1126
|
-
# Description:
|
1127
|
-
# Gets the class name of the option.
|
1128
|
-
#
|
1129
|
-
# Output:
|
1130
|
-
# Class name of the option.
|
1131
|
-
#
|
1132
|
-
def class_name
|
1133
|
-
assert_exists
|
1134
|
-
option_class_name
|
1135
|
-
end
|
1136
|
-
|
1137
|
-
#
|
1138
|
-
# Description:
|
1139
|
-
# Gets the text of the option.
|
1140
|
-
#
|
1141
|
-
# Output:
|
1142
|
-
# Text of the option.
|
1143
|
-
#
|
1144
|
-
def text
|
1145
|
-
assert_exists
|
1146
|
-
option_text
|
1147
|
-
end
|
1148
|
-
|
1149
|
-
#
|
1150
|
-
# Description:
|
1151
|
-
# Gets the value of the option.
|
1152
|
-
#
|
1153
|
-
# Output:
|
1154
|
-
# Value of the option.
|
1155
|
-
#
|
1156
|
-
def value
|
1157
|
-
assert_exists
|
1158
|
-
option_value
|
1159
|
-
end
|
1160
|
-
|
1161
|
-
#
|
1162
|
-
# Description:
|
1163
|
-
# Gets the status of the option; whether it is selected or not.
|
1164
|
-
#
|
1165
|
-
# Output:
|
1166
|
-
# True if option is selected, false otherwise.
|
1167
|
-
#
|
1168
|
-
def selected
|
1169
|
-
assert_exists
|
1170
|
-
#@option.selected
|
1171
|
-
option_selected
|
1172
|
-
end
|
1173
|
-
end
|
1174
|
-
|
1175
|
-
#
|
1176
|
-
# Description:
|
1177
|
-
# Class for Button element.
|
1178
|
-
#
|
1179
|
-
class Button < InputElement
|
1180
|
-
INPUT_TYPES = ["button", "submit", "image", "reset"]
|
1181
|
-
def locate
|
1182
|
-
super
|
1183
|
-
@o = @element.locate_tagged_element("button", @how, @what, self.class::INPUT_TYPES) unless @o
|
1184
|
-
end
|
1185
|
-
end
|
1186
|
-
|
1187
|
-
#
|
1188
|
-
# Description:
|
1189
|
-
# Class for Text Field element.
|
1190
|
-
#
|
1191
|
-
class TextField < InputElement
|
1192
|
-
INPUT_TYPES = ["text", "password", "textarea"]
|
1193
|
-
|
1194
|
-
# Gets the size of the text field element.
|
1195
|
-
def_wrap :size
|
1196
|
-
# Gets max length of the text field element.
|
1197
|
-
def_wrap :maxlength_string, :maxlength
|
1198
|
-
def maxlength
|
1199
|
-
maxlength_string.to_i
|
1200
|
-
end
|
1201
|
-
# Returns true if the text field is read only, false otherwise.
|
1202
|
-
def_wrap :readonly?, :readOnly
|
1203
|
-
|
1204
|
-
#
|
1205
|
-
# Description:
|
1206
|
-
# Used to populate the properties in to_s method
|
1207
|
-
#
|
1208
|
-
#def text_string_creator
|
1209
|
-
# n = []
|
1210
|
-
# n << "length:".ljust(TO_S_SIZE) + self.size.to_s
|
1211
|
-
# n << "max length:".ljust(TO_S_SIZE) + self.maxlength.to_s
|
1212
|
-
# n << "read only:".ljust(TO_S_SIZE) + self.readonly?.to_s
|
1213
|
-
#
|
1214
|
-
# return n
|
1215
|
-
#end
|
1216
|
-
#private :text_string_creator
|
1217
|
-
|
1218
|
-
# TODO: Impelement the to_s method.
|
1219
|
-
def to_s
|
1220
|
-
assert_exists
|
1221
|
-
super({"length" => "size","max length" => "maxlength","read only" => "readOnly" })
|
1222
|
-
end
|
1223
|
-
|
1224
|
-
#
|
1225
|
-
# Description:
|
1226
|
-
# Checks if object is read-only or not.
|
1227
|
-
#
|
1228
|
-
def assert_not_readonly
|
1229
|
-
raise ObjectReadOnlyException, "Textfield #{@how} and #{@what} is read only." if self.readonly?
|
1230
|
-
end
|
1231
|
-
|
1232
|
-
#
|
1233
|
-
# Description:
|
1234
|
-
# Checks if the provided text matches with the contents of text field. Text can be a string or regular expression.
|
1235
|
-
#
|
1236
|
-
# Input:
|
1237
|
-
# - containsThis - Text to verify.
|
1238
|
-
#
|
1239
|
-
# Output:
|
1240
|
-
# True if provided text matches with the contents of text field, false otherwise.
|
1241
|
-
#
|
1242
|
-
def verify_contains( containsThis )
|
1243
|
-
assert_exists
|
1244
|
-
if containsThis.kind_of? String
|
1245
|
-
return true if self.value == containsThis
|
1246
|
-
elsif containsThis.kind_of? Regexp
|
1247
|
-
return true if self.value.match(containsThis) != nil
|
1248
|
-
end
|
1249
|
-
return false
|
1250
|
-
end
|
1251
|
-
|
1252
|
-
# this method is used to drag the entire contents of the text field to another text field
|
1253
|
-
# 19 Jan 2005 - It is added as prototype functionality, and may change
|
1254
|
-
# * destination_how - symbol, :id, :name how we identify the drop target
|
1255
|
-
# * destination_what - string or regular expression, the name, id, etc of the text field that will be the drop target
|
1256
|
-
# TODO: Can we have support for this in Firefox.
|
1257
|
-
#def dragContentsTo( destination_how , destination_what)
|
1258
|
-
# assert_exists
|
1259
|
-
# destination = element.text_field(destination_how, destination_what)
|
1260
|
-
# raise UnknownObjectException , "Unable to locate destination using #{destination_how } and #{destination_what } " if destination.exists? == false
|
1261
|
-
|
1262
|
-
# @o.focus
|
1263
|
-
# @o.select()
|
1264
|
-
# value = self.value
|
1265
|
-
|
1266
|
-
# @o.fireEvent("onSelect")
|
1267
|
-
# @o.fireEvent("ondragstart")
|
1268
|
-
# @o.fireEvent("ondrag")
|
1269
|
-
# destination.fireEvent("onDragEnter")
|
1270
|
-
# destination.fireEvent("onDragOver")
|
1271
|
-
# destination.fireEvent("ondrop")
|
1272
|
-
|
1273
|
-
# @o.fireEvent("ondragend")
|
1274
|
-
# destination.value= ( destination.value + value.to_s )
|
1275
|
-
# self.value = ""
|
1276
|
-
#end
|
1277
|
-
|
1278
|
-
#
|
1279
|
-
# Description:
|
1280
|
-
# Clears the contents of the text field.
|
1281
|
-
# Raises ObjectDisabledException if text field is disabled.
|
1282
|
-
# Raises ObjectReadOnlyException if text field is read only.
|
1283
|
-
#
|
1284
|
-
def clear
|
1285
|
-
assert_exists
|
1286
|
-
assert_enabled
|
1287
|
-
assert_not_readonly
|
1288
|
-
|
1289
|
-
highlight(:set)
|
1290
|
-
|
1291
|
-
@o.scrollIntoView
|
1292
|
-
@o.focus
|
1293
|
-
@o.select()
|
1294
|
-
@o.fireEvent("onSelect")
|
1295
|
-
@o.value = ""
|
1296
|
-
@o.fireEvent("onKeyPress")
|
1297
|
-
@o.fireEvent("onChange")
|
1298
|
-
@container.wait()
|
1299
|
-
highlight(:clear)
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
#
|
1303
|
-
# Description:
|
1304
|
-
# Append the provided text to the contents of the text field.
|
1305
|
-
# Raises ObjectDisabledException if text field is disabled.
|
1306
|
-
# Raises ObjectReadOnlyException if text field is read only.
|
1307
|
-
#
|
1308
|
-
# Input:
|
1309
|
-
# - setThis - Text to be appended.
|
1310
|
-
#
|
1311
|
-
def append( setThis)
|
1312
|
-
assert_exists
|
1313
|
-
assert_enabled
|
1314
|
-
assert_not_readonly
|
1315
|
-
|
1316
|
-
highlight(:set)
|
1317
|
-
@o.scrollIntoView
|
1318
|
-
@o.focus
|
1319
|
-
doKeyPress( setThis )
|
1320
|
-
highlight(:clear)
|
1321
|
-
end
|
1322
|
-
|
1323
|
-
#
|
1324
|
-
# Description:
|
1325
|
-
# Sets the contents of the text field to the provided text. Overwrite the existing contents.
|
1326
|
-
# Raises ObjectDisabledException if text field is disabled.
|
1327
|
-
# Raises ObjectReadOnlyException if text field is read only.
|
1328
|
-
#
|
1329
|
-
# Input:
|
1330
|
-
# - setThis - Text to be set.
|
1331
|
-
#
|
1332
|
-
def set( setThis )
|
1333
|
-
assert_exists
|
1334
|
-
assert_enabled
|
1335
|
-
assert_not_readonly
|
1336
|
-
|
1337
|
-
highlight(:set)
|
1338
|
-
@o.scrollIntoView
|
1339
|
-
@o.focus
|
1340
|
-
@o.select()
|
1341
|
-
@o.fireEvent("onSelect")
|
1342
|
-
@o.value = ""
|
1343
|
-
@o.fireEvent("onKeyPress")
|
1344
|
-
doKeyPress( setThis )
|
1345
|
-
highlight(:clear)
|
1346
|
-
@o.fireEvent("onChange")
|
1347
|
-
@o.fireEvent("onBlur")
|
1348
|
-
end
|
1349
|
-
|
1350
|
-
#
|
1351
|
-
# Description:
|
1352
|
-
# Sets the text of the text field withoud firing the events like onKeyPress, onKeyDown etc. This should not be used generally, but it
|
1353
|
-
# is useful in situations where you need to set large text to the text field and you know that you don't have any event to be
|
1354
|
-
# fired.
|
1355
|
-
#
|
1356
|
-
# Input:
|
1357
|
-
# - v - Text to be set.
|
1358
|
-
#
|
1359
|
-
#def value=(v)
|
1360
|
-
# assert_exists
|
1361
|
-
# @o.value = v.to_s
|
1362
|
-
#end
|
1363
|
-
|
1364
|
-
#
|
1365
|
-
# Description:
|
1366
|
-
# Used to set the value of text box and fires the event onKeyPress, onKeyDown, onKeyUp after each character.
|
1367
|
-
# Shouldnot be used externally. Used internally by set and append methods.
|
1368
|
-
#
|
1369
|
-
# Input:
|
1370
|
-
# - value - The string to enter into the text field
|
1371
|
-
#
|
1372
|
-
def doKeyPress( value )
|
1373
|
-
begin
|
1374
|
-
max = maxlength
|
1375
|
-
if (max > 0 && value.length > max)
|
1376
|
-
original_value = value
|
1377
|
-
value = original_value[0...max]
|
1378
|
-
element.log " Supplied string is #{suppliedValue.length} chars, which exceeds the max length (#{max}) of the field. Using value: #{value}"
|
1379
|
-
end
|
1380
|
-
rescue
|
1381
|
-
# probably a text area - so it doesnt have a max Length
|
1382
|
-
end
|
1383
|
-
for i in 0..value.length-1
|
1384
|
-
#sleep element.typingspeed # typing speed
|
1385
|
-
c = value[i,1]
|
1386
|
-
#element.log " adding c.chr " + c #.chr.to_s
|
1387
|
-
@o.value = "#{(@o.value.to_s + c)}" #c.chr
|
1388
|
-
@o.fireEvent("onKeyDown")
|
1389
|
-
@o.fireEvent("onKeyPress")
|
1390
|
-
@o.fireEvent("onKeyUp")
|
1391
|
-
end
|
1392
|
-
|
1393
|
-
end
|
1394
|
-
private :doKeyPress
|
1395
|
-
|
1396
|
-
alias readOnly? :readonly?
|
1397
|
-
alias getContents value
|
1398
|
-
alias maxLength maxlength
|
1399
|
-
|
1400
|
-
end
|
1401
|
-
|
1402
|
-
#
|
1403
|
-
# Description:
|
1404
|
-
# Class for Hidden Field element.
|
1405
|
-
#
|
1406
|
-
class Hidden < TextField
|
1407
|
-
INPUT_TYPES = ["hidden"]
|
1408
|
-
|
1409
|
-
#
|
1410
|
-
# Description:
|
1411
|
-
# Sets the value of the hidden field. Overriden in this class, as there is no way to set focus to a hidden field
|
1412
|
-
#
|
1413
|
-
# Input:
|
1414
|
-
# n - Value to be set.
|
1415
|
-
#
|
1416
|
-
def set(n)
|
1417
|
-
self.value=n
|
1418
|
-
end
|
1419
|
-
|
1420
|
-
#
|
1421
|
-
# Description:
|
1422
|
-
# Appends the value to the value of the hidden field. Overriden in this class, as there is no way to set focus to a hidden field
|
1423
|
-
#
|
1424
|
-
# Input:
|
1425
|
-
# n - Value to be appended.
|
1426
|
-
#
|
1427
|
-
def append(n)
|
1428
|
-
self.value = self.value.to_s + n.to_s
|
1429
|
-
end
|
1430
|
-
|
1431
|
-
#
|
1432
|
-
# Description:
|
1433
|
-
# Clears the value of the hidden field. Overriden in this class, as there is no way to set focus to a hidden field
|
1434
|
-
#
|
1435
|
-
def clear
|
1436
|
-
self.value = ""
|
1437
|
-
end
|
1438
|
-
|
1439
|
-
#
|
1440
|
-
# Description:
|
1441
|
-
# Does nothing, as you cant set focus to a hidden field. Overridden here so that exception doesn't occurs.
|
1442
|
-
#
|
1443
|
-
def focus
|
1444
|
-
end
|
1445
|
-
|
1446
|
-
end
|
1447
|
-
|
1448
|
-
#
|
1449
|
-
# Description:
|
1450
|
-
# Class for FileField element.
|
1451
|
-
#
|
1452
|
-
class FileField < InputElement
|
1453
|
-
INPUT_TYPES = ["file"]
|
1454
|
-
|
1455
|
-
#
|
1456
|
-
# Description:
|
1457
|
-
# Sets the path of the file in the textbox.
|
1458
|
-
#
|
1459
|
-
# Input:
|
1460
|
-
# setPath - Path of the file.
|
1461
|
-
#
|
1462
|
-
def set(setPath)
|
1463
|
-
assert_exists
|
1464
|
-
|
1465
|
-
setFileFieldValue(setPath)
|
1466
|
-
end
|
1467
|
-
end
|
1468
|
-
|
1469
|
-
#
|
1470
|
-
# Description:
|
1471
|
-
# Base class for checkbox and radio button elements.
|
1472
|
-
#
|
1473
|
-
class RadioCheckCommon < Element
|
1474
|
-
attr_accessor :element_name
|
1475
|
-
#
|
1476
|
-
# Description:
|
1477
|
-
# Initializes the instance of element object. Element can be checkbox or radio button.
|
1478
|
-
#
|
1479
|
-
# Input:
|
1480
|
-
# - how - Attribute to identify the element.
|
1481
|
-
# - what - Value of that attribute.
|
1482
|
-
# - value - value of the element.
|
1483
|
-
#
|
1484
|
-
def initialize(container, how, what, value = nil)
|
1485
|
-
@how = how
|
1486
|
-
@what = what
|
1487
|
-
@value = value
|
1488
|
-
@container = container
|
1489
|
-
end
|
1490
|
-
|
1491
|
-
#
|
1492
|
-
# Description:
|
1493
|
-
# Locate the element on the page. Element can be a checkbox or radio button.
|
1494
|
-
#
|
1495
|
-
def locate
|
1496
|
-
if @how == :jssh_name
|
1497
|
-
@element_name = @what
|
1498
|
-
elsif @how == :xpath
|
1499
|
-
@element_name = element_by_xpath(@container, @what)
|
1500
|
-
else
|
1501
|
-
@element_name = locate_tagged_element("input", @how, @what, @type, @value)
|
1502
|
-
end
|
1503
|
-
@o = self
|
1504
|
-
end
|
1505
|
-
|
1506
|
-
#
|
1507
|
-
# Description:
|
1508
|
-
# Checks if element i.e. radio button or check box is checked or not.
|
1509
|
-
#
|
1510
|
-
# Output:
|
1511
|
-
# True if element is checked, false otherwise.
|
1512
|
-
#
|
1513
|
-
def isSet?
|
1514
|
-
assert_exists
|
1515
|
-
return @o.checked
|
1516
|
-
end
|
1517
|
-
alias getState isSet?
|
1518
|
-
alias checked? isSet?
|
1519
|
-
|
1520
|
-
#
|
1521
|
-
# Description:
|
1522
|
-
# Unchecks the radio button or check box element.
|
1523
|
-
# Raises ObjectDisabledException exception if element is disabled.
|
1524
|
-
#
|
1525
|
-
def clear
|
1526
|
-
assert_exists
|
1527
|
-
assert_enabled
|
1528
|
-
#highlight(:set)
|
1529
|
-
set_clear_item(false)
|
1530
|
-
#highlight(:clear)
|
1531
|
-
end
|
1532
|
-
|
1533
|
-
#
|
1534
|
-
# Description:
|
1535
|
-
# Checks the radio button or check box element.
|
1536
|
-
# Raises ObjectDisabledException exception if element is disabled.
|
1537
|
-
#
|
1538
|
-
def set
|
1539
|
-
assert_exists
|
1540
|
-
assert_enabled
|
1541
|
-
#highlight(:set)
|
1542
|
-
set_clear_item(true)
|
1543
|
-
#highlight(:clear)
|
1544
|
-
end
|
1545
|
-
|
1546
|
-
#
|
1547
|
-
# Description:
|
1548
|
-
# Used by clear and set method to uncheck and check radio button and checkbox element respectively.
|
1549
|
-
#
|
1550
|
-
def set_clear_item(set)
|
1551
|
-
@o.fire_event("onclick")
|
1552
|
-
@container.wait
|
1553
|
-
end
|
1554
|
-
private :set_clear_item
|
1555
|
-
|
1556
|
-
end
|
1557
|
-
|
1558
|
-
#
|
1559
|
-
# Description:
|
1560
|
-
# Class for RadioButton element.
|
1561
|
-
#
|
1562
|
-
class Radio < RadioCheckCommon
|
1563
|
-
def initialize *args
|
1564
|
-
super
|
1565
|
-
@type = ["radio"]
|
1566
|
-
end
|
1567
|
-
|
1568
|
-
def clear
|
1569
|
-
assert_exists
|
1570
|
-
assert_enabled
|
1571
|
-
#higlight(:set)
|
1572
|
-
@o.checked = false
|
1573
|
-
#highlight(:clear)
|
1574
|
-
end
|
1575
|
-
end
|
1576
|
-
|
1577
|
-
#
|
1578
|
-
# Description:
|
1579
|
-
# Class for Checkbox element.
|
1580
|
-
#
|
1581
|
-
class CheckBox < RadioCheckCommon
|
1582
|
-
def initialize *args
|
1583
|
-
super
|
1584
|
-
@type = ["checkbox"]
|
1585
|
-
end
|
1586
|
-
|
1587
|
-
#
|
1588
|
-
# Description:
|
1589
|
-
# Checks or unchecks the checkbox. If no value is supplied it will check the checkbox.
|
1590
|
-
# Raises ObjectDisabledException exception if the object is disabled
|
1591
|
-
#
|
1592
|
-
# Input:
|
1593
|
-
# - set_or_clear - Parameter indicated whether to check or uncheck the checkbox.
|
1594
|
-
# True to check the check box, false for unchecking the checkbox.
|
1595
|
-
#
|
1596
|
-
def set( set_or_clear=true )
|
1597
|
-
assert_exists
|
1598
|
-
assert_enabled
|
1599
|
-
highlight(:set)
|
1600
|
-
|
1601
|
-
if set_or_clear == true
|
1602
|
-
if @o.checked == false
|
1603
|
-
set_clear_item( true )
|
1604
|
-
end
|
1605
|
-
else
|
1606
|
-
self.clear
|
1607
|
-
end
|
1608
|
-
highlight(:clear )
|
1609
|
-
end
|
1610
|
-
|
1611
|
-
#
|
1612
|
-
# Description:
|
1613
|
-
# Unchecks the checkbox.
|
1614
|
-
# Raises ObjectDisabledException exception if the object is disabled
|
1615
|
-
#
|
1616
|
-
def clear
|
1617
|
-
assert_exists
|
1618
|
-
assert_enabled
|
1619
|
-
highlight( :set)
|
1620
|
-
if @o.checked == true
|
1621
|
-
set_clear_item( false )
|
1622
|
-
end
|
1623
|
-
highlight( :clear)
|
1624
|
-
end
|
1625
|
-
end
|
1626
|
-
|
1627
|
-
# this class is the super class for the iterator classes ( buttons, links, spans etc
|
1628
|
-
# it would normally only be accessed by the iterator methods ( spans , links etc) of IE
|
1629
|
-
|
1630
|
-
#class ElementCollections
|
1631
|
-
# include Enumerable
|
1632
|
-
# include Container
|
1633
|
-
# Super class for all the iteractor classes
|
1634
|
-
# * container - an instance of an IE object
|
1635
|
-
# def initialize( container)
|
1636
|
-
# element = container
|
1637
|
-
# @length = length() # defined by subclasses
|
1638
|
-
|
1639
|
-
# set up the items we want to display when the show method s used
|
1640
|
-
# set_show_items
|
1641
|
-
# end
|
1642
|
-
|
1643
|
-
# private
|
1644
|
-
# def set_show_items
|
1645
|
-
# @show_attributes = AttributeLengthPairs.new( "id" , 20)
|
1646
|
-
# @show_attributes.add( "name" , 20)
|
1647
|
-
# end
|
1648
|
-
|
1649
|
-
# public
|
1650
|
-
# def get_length_of_input_objects(object_type)
|
1651
|
-
# object_types =
|
1652
|
-
# if object_type.kind_of? Array
|
1653
|
-
# object_type
|
1654
|
-
# else
|
1655
|
-
# [ object_type ]
|
1656
|
-
# end
|
1657
|
-
|
1658
|
-
# length = 0
|
1659
|
-
# objects = element.document.getElementsByTagName("INPUT")
|
1660
|
-
# if objects.length > 0
|
1661
|
-
# objects.each do |o|
|
1662
|
-
# length += 1 if object_types.include?(o.invoke("type").downcase )
|
1663
|
-
# end
|
1664
|
-
# end
|
1665
|
-
# return length
|
1666
|
-
# end
|
1667
|
-
|
1668
|
-
# iterate through each of the elements in the collection in turn
|
1669
|
-
# def each
|
1670
|
-
# 0.upto( @length-1 ) { |i | yield iterator_object(i) }
|
1671
|
-
# end
|
1672
|
-
|
1673
|
-
# allows access to a specific item in the collection
|
1674
|
-
# def [](n)
|
1675
|
-
# return iterator_object(n-1)
|
1676
|
-
# end
|
1677
|
-
|
1678
|
-
# this method is the way to show the objects, normally used from irb
|
1679
|
-
# def show
|
1680
|
-
# s="index".ljust(6)
|
1681
|
-
# @show_attributes.each do |attribute_length_pair|
|
1682
|
-
# s=s + attribute_length_pair.attribute.ljust(attribute_length_pair.length)
|
1683
|
-
# end
|
1684
|
-
|
1685
|
-
# index = 1
|
1686
|
-
# self.each do |o|
|
1687
|
-
# s= s+"\n"
|
1688
|
-
# s=s + index.to_s.ljust(6)
|
1689
|
-
# @show_attributes.each do |attribute_length_pair|
|
1690
|
-
# begin
|
1691
|
-
# s=s + eval( 'o.getOLEObject.invoke("#{attribute_length_pair.attribute}")').to_s.ljust( attribute_length_pair.length )
|
1692
|
-
# rescue=>e
|
1693
|
-
# s=s+ " ".ljust( attribute_length_pair.length )
|
1694
|
-
# end
|
1695
|
-
# end
|
1696
|
-
# index+=1
|
1697
|
-
# end
|
1698
|
-
# puts s
|
1699
|
-
# end
|
1700
|
-
|
1701
|
-
# this method creates an object of the correct type that the iterators use
|
1702
|
-
# private
|
1703
|
-
# def iterator_object(i)
|
1704
|
-
# element_class.new(element, :index, i+1)
|
1705
|
-
# end
|
1706
|
-
#end
|
1707
|
-
|
1708
|
-
#--
|
1709
|
-
# These classes are not for public consumption, so we switch off rdoc
|
1710
|
-
|
1711
|
-
# presumes element_class or element_tag is defined
|
1712
|
-
# for subclasses of ElementCollections
|
1713
|
-
# module CommonCollection
|
1714
|
-
# def element_tag
|
1715
|
-
# element_class.tag
|
1716
|
-
# end
|
1717
|
-
# def length
|
1718
|
-
# element.document.getElementsByTagName(element_tag).length
|
1719
|
-
# end
|
1720
|
-
# end
|
1721
|
-
|
1722
|
-
# This class is used as part of the .show method of the iterators class
|
1723
|
-
# it would not normally be used by a user
|
1724
|
-
#class AttributeLengthPairs
|
1725
|
-
|
1726
|
-
# This class is used as part of the .show method of the iterators class
|
1727
|
-
# it would not normally be used by a user
|
1728
|
-
# class AttributeLengthHolder
|
1729
|
-
# attr_accessor :attribute
|
1730
|
-
# attr_accessor :length
|
1731
|
-
|
1732
|
-
# def initialize( attrib, length)
|
1733
|
-
# @attribute = attrib
|
1734
|
-
# @length = length
|
1735
|
-
# end
|
1736
|
-
# end
|
1737
|
-
|
1738
|
-
# def initialize( attrib=nil , length=nil)
|
1739
|
-
# @attr=[]
|
1740
|
-
# add( attrib , length ) if attrib
|
1741
|
-
# @index_counter=0
|
1742
|
-
# end
|
1743
|
-
|
1744
|
-
# # BUG: Untested. (Null implementation passes all tests.)
|
1745
|
-
# def add( attrib , length)
|
1746
|
-
# @attr << AttributeLengthHolder.new( attrib , length )
|
1747
|
-
# end
|
1748
|
-
|
1749
|
-
# def delete(attrib)
|
1750
|
-
# item_to_delete=nil
|
1751
|
-
# @attr.each_with_index do |e,i|
|
1752
|
-
# item_to_delete = i if e.attribute==attrib
|
1753
|
-
# end
|
1754
|
-
# @attr.delete_at(item_to_delete ) unless item_to_delete == nil
|
1755
|
-
# end
|
1756
|
-
|
1757
|
-
# def next
|
1758
|
-
# temp = @attr[@index_counter]
|
1759
|
-
# @index_counter +=1
|
1760
|
-
# return temp
|
1761
|
-
# end
|
1762
|
-
|
1763
|
-
# def each
|
1764
|
-
# 0.upto( @attr.length-1 ) { |i | yield @attr[i] }
|
1765
|
-
# end
|
1766
|
-
#end
|
1767
|
-
|
1768
|
-
# resume rdoc
|
1769
|
-
#
|
1770
|
-
|
1771
|
-
# Class for accessing all the button elements in the document.
|
1772
|
-
# It would normally only be accessed by the FireWatir::Container#buttons method
|
1773
|
-
class Buttons < ElementCollections
|
1774
|
-
def locate_elements
|
1775
|
-
locate_tagged_elements("input", ["button", "image", "submit", "reset"])
|
1776
|
-
end
|
1777
|
-
end
|
1778
|
-
|
1779
|
-
# Class for accessing all the File Field elements in the document.
|
1780
|
-
# It would normally only be accessed by the FireWatir::Container#file_fields method
|
1781
|
-
class FileFields < ElementCollections
|
1782
|
-
def locate_elements
|
1783
|
-
locate_tagged_elements("input", ["file"])
|
1784
|
-
end
|
1785
|
-
end
|
1786
|
-
|
1787
|
-
# Class for accessing all the CheckBox elements in the document.
|
1788
|
-
# It would normally only be accessed by the FireWatir::Container#checkboxes method
|
1789
|
-
class CheckBoxes < ElementCollections
|
1790
|
-
def locate_elements
|
1791
|
-
locate_tagged_elements("input", ["checkbox"])
|
1792
|
-
end
|
1793
|
-
end
|
1794
|
-
module Container
|
1795
|
-
alias checkboxes check_boxes
|
1796
|
-
end
|
1797
|
-
|
1798
|
-
# Class for accessing all the Radio button elements in the document.
|
1799
|
-
# It would normally only be accessed by the FireWatir::Container#radios method
|
1800
|
-
class Radios < ElementCollections
|
1801
|
-
def locate_elements
|
1802
|
-
locate_tagged_elements("input", ["radio"])
|
1803
|
-
end
|
1804
|
-
end
|
1805
|
-
|
1806
|
-
# Class for accessing all the select list elements in the document.
|
1807
|
-
# It would normally only be accessed by the FireWatir::Container#select_lists method
|
1808
|
-
class SelectLists < ElementCollections
|
1809
|
-
def locate_elements
|
1810
|
-
locate_tagged_elements("select", ["select-one", "select-multiple"])
|
1811
|
-
end
|
1812
|
-
end
|
1813
|
-
|
1814
|
-
# Class for accessing all the link elements in the document.
|
1815
|
-
# It would normally only be accessed by the FireWatir::Container#links method
|
1816
|
-
class Links < ElementCollections; end
|
1817
|
-
|
1818
|
-
# Class for accessing all the image elements in the document.
|
1819
|
-
# It would normally only be accessed by the FireWatir::Container#images method
|
1820
|
-
class Images < ElementCollections; end
|
1821
|
-
|
1822
|
-
# Class for accessing all the text field elements in the document.
|
1823
|
-
# It would normally only be accessed by the FireWatir::Container#text_fields method
|
1824
|
-
class TextFields < ElementCollections
|
1825
|
-
def locate_elements
|
1826
|
-
locate_tagged_elements("input", ["text", "textarea", "password"])
|
1827
|
-
end
|
1828
|
-
end
|
1829
|
-
|
1830
|
-
# Class for accessing all the hidden elements in the document.
|
1831
|
-
# It would normally only be accessed by the FireWatir::Container#hiddens method
|
1832
|
-
class Hiddens < ElementCollections
|
1833
|
-
def locate_elements
|
1834
|
-
locate_tagged_elements("input", ["hidden"])
|
1835
|
-
end
|
1836
|
-
end
|
1837
|
-
|
1838
|
-
# Class for accessing all the table elements in the document.
|
1839
|
-
# It would normally only be accessed by the FireWatir::Container#tables method
|
1840
|
-
class Tables < ElementCollections; end
|
1841
|
-
|
1842
|
-
# Class for accessing all the label elements in the document.
|
1843
|
-
# It would normally only be accessed by the FireWatir::Container#labels method
|
1844
|
-
class Labels < ElementCollections; end
|
1845
|
-
|
1846
|
-
# Class for accessing all the pre element in the document.
|
1847
|
-
# It would normally only be accessed by the FireWatir::Container#pres method
|
1848
|
-
class Pres < ElementCollections; end
|
1849
|
-
|
1850
|
-
# Class for accessing all the paragraph elements in the document.
|
1851
|
-
# It would normally only be accessed by the FireWatir::Container#ps method
|
1852
|
-
class Ps < ElementCollections; end
|
1853
|
-
|
1854
|
-
# Class for accessing all the span elements in the document.
|
1855
|
-
# It would normally only be accessed by the FireWatir::Container#spans method
|
1856
|
-
class Spans < ElementCollections; end
|
1857
|
-
|
1858
|
-
# Class for accessing all the div elements in the document.
|
1859
|
-
# It would normally only be accessed by the FireWatir::Container#divs method
|
1860
|
-
class Divs < ElementCollections; end
|
1861
|
-
|
1862
|
-
class Ul < NonControlElement
|
1863
|
-
TAG = 'UL'
|
1864
|
-
end
|
1865
|
-
class Uls < ElementCollections; end
|
1866
|
-
|
1867
|
-
class Li < NonControlElement
|
1868
|
-
TAG = 'LI'
|
1869
|
-
end
|
1870
|
-
class Lis < ElementCollections; end
|
1871
|
-
|
1872
|
-
class H1 < NonControlElement
|
1873
|
-
TAG = 'H1'
|
1874
|
-
end
|
1875
|
-
|
1876
|
-
class H2 < NonControlElement
|
1877
|
-
TAG = 'H2'
|
1878
|
-
end
|
1879
|
-
|
1880
|
-
class H3 < NonControlElement
|
1881
|
-
TAG = 'H3'
|
1882
|
-
end
|
1883
|
-
|
1884
|
-
class H4 < NonControlElement
|
1885
|
-
TAG = 'H4'
|
1886
|
-
end
|
1887
|
-
|
1888
|
-
class H5 < NonControlElement
|
1889
|
-
TAG = 'H5'
|
1890
|
-
end
|
1891
|
-
|
1892
|
-
class H6 < NonControlElement
|
1893
|
-
TAG = 'H6'
|
1894
|
-
end
|
1895
|
-
|
1896
|
-
class Map < NonControlElement
|
1897
|
-
TAG = 'MAP'
|
1898
|
-
end
|
1899
|
-
class Maps < ElementCollections; end
|
1900
|
-
|
1901
|
-
class Area < NonControlElement
|
1902
|
-
TAG = 'AREA'
|
1903
|
-
end
|
1904
|
-
class Areas < ElementCollections; end
|
1905
|
-
|
1906
|
-
class Body < NonControlElement
|
1907
|
-
TAG = 'TBODY'
|
1908
|
-
end
|
1909
|
-
class Bodies < ElementCollections; end
|
1910
|
-
|
1911
|
-
end
|