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