firewatir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -0
- data/LICENSE +31 -31
- data/README.rdoc +112 -0
- data/VERSION +1 -0
- data/lib/firewatir.rb +41 -40
- data/lib/firewatir/container.rb +491 -491
- data/lib/firewatir/document.rb +239 -239
- data/lib/firewatir/element.rb +1364 -1364
- data/lib/firewatir/element_collections.rb +314 -314
- data/lib/firewatir/elements/button.rb +15 -15
- data/lib/firewatir/elements/file_field.rb +29 -29
- data/lib/firewatir/elements/form.rb +40 -40
- data/lib/firewatir/elements/frame.rb +55 -55
- data/lib/firewatir/elements/hidden.rb +56 -56
- data/lib/firewatir/elements/image.rb +139 -139
- data/lib/firewatir/elements/input_element.rb +44 -44
- data/lib/firewatir/elements/link.rb +76 -76
- data/lib/firewatir/elements/non_control_element.rb +53 -53
- data/lib/firewatir/elements/non_control_elements.rb +108 -108
- data/lib/firewatir/elements/not_used.rb +278 -278
- data/lib/firewatir/elements/option.rb +130 -130
- data/lib/firewatir/elements/radio_check_common.rb +163 -163
- data/lib/firewatir/elements/select_list.rb +188 -188
- data/lib/firewatir/elements/table.rb +218 -218
- data/lib/firewatir/elements/table_cell.rb +54 -54
- data/lib/firewatir/elements/table_row.rb +100 -100
- data/lib/firewatir/elements/text_field.rb +218 -218
- data/lib/firewatir/exceptions.rb +10 -10
- data/lib/firewatir/firefox.rb +984 -1040
- data/lib/firewatir/jssh_socket.rb +100 -100
- data/lib/firewatir/winClicker.rb +122 -122
- data/lib/firewatir/x11.rb +192 -192
- data/rakefile.rb +15 -0
- data/unittests/attach_to_new_window_test.rb +49 -49
- data/unittests/bug_fixes_test.rb +195 -195
- data/unittests/buttons_xpath_test.rb +88 -88
- data/unittests/checkbox_test.rb +158 -158
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/div_test.rb +275 -275
- data/unittests/ff_test.rb +47 -0
- data/unittests/filefield_test.rb +49 -49
- data/unittests/filefield_xpath_test.rb +35 -35
- data/unittests/form_test.rb +296 -296
- data/unittests/frame_test.rb +159 -159
- data/unittests/hidden_test.rb +85 -85
- data/unittests/hidden_xpath_test.rb +72 -72
- data/unittests/html/JavascriptClick.html +42 -42
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +61 -61
- data/unittests/html/checkboxes1.html +70 -70
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/div.html +72 -72
- data/unittests/html/div_xml.html +20 -20
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +45 -45
- data/unittests/html/forms3.html +132 -132
- data/unittests/html/forms4.html +27 -27
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/frame_links.html +3 -3
- data/unittests/html/frame_multi.html +4 -4
- data/unittests/html/iframeTest.html +14 -14
- data/unittests/html/iframeTest1.html +13 -13
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/images1.html +66 -66
- data/unittests/html/javascriptevents.html +35 -35
- data/unittests/html/link_pass.html +10 -10
- data/unittests/html/links1.html +42 -42
- data/unittests/html/links2.html +10 -10
- data/unittests/html/modal_dialog.html +8 -8
- data/unittests/html/modal_dialog_launcher.html +11 -11
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +17 -17
- data/unittests/html/new_browser_popup.html +7 -7
- data/unittests/html/pass.html +9 -9
- data/unittests/html/popups1.html +60 -60
- data/unittests/html/pre.html +27 -27
- data/unittests/html/radioButtons1.html +70 -70
- data/unittests/html/redirect.html +10 -10
- data/unittests/html/redirect1.html +8 -8
- data/unittests/html/redirect2.html +8 -8
- data/unittests/html/redirect3.html +8 -8
- data/unittests/html/select_tealeaf.html +54 -54
- data/unittests/html/selectboxes1.html +55 -55
- data/unittests/html/simple_table.html +26 -26
- data/unittests/html/simple_table_buttons.html +104 -104
- data/unittests/html/simple_table_columns.html +74 -74
- data/unittests/html/table1.html +165 -165
- data/unittests/html/tableCell_using_xpath.html +19 -19
- data/unittests/html/textarea.html +30 -30
- data/unittests/html/textfields1.html +62 -62
- data/unittests/html/textsearch.html +44 -44
- data/unittests/images_test.rb +198 -198
- data/unittests/images_xpath_test.rb +118 -118
- data/unittests/javascript_test.rb +75 -75
- data/unittests/links_test.rb +231 -231
- data/unittests/links_xpath_test.rb +79 -79
- data/unittests/mozilla_all_tests.rb +7 -7
- data/unittests/pre_test.rb +75 -75
- data/unittests/radios_test.rb +166 -166
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/redirect_test.rb +41 -41
- data/unittests/selectbox_test.rb +142 -142
- data/unittests/selectbox_xpath_test.rb +129 -129
- data/unittests/setup.rb +29 -29
- data/unittests/table_test.rb +385 -385
- data/unittests/table_xpath_test.rb +185 -185
- data/unittests/textfields_test.rb +234 -234
- data/unittests/textfields_xpath_test.rb +113 -113
- metadata +51 -19
- data/lib/firewatir/version.rb +0 -5
@@ -1,278 +1,278 @@
|
|
1
|
-
# # this class is a collection of the table body objects that exist in the table
|
2
|
-
# # it wouldnt normally be created by a user, but gets returned by the bodies method of the Table object
|
3
|
-
# # many of the methods available to this object are inherited from the Element class
|
4
|
-
# # TODO: Implement TableBodies class.
|
5
|
-
# class TableBodies < Element
|
6
|
-
#
|
7
|
-
# # Description:
|
8
|
-
# # Initializes the form element.
|
9
|
-
# #
|
10
|
-
# # Input:
|
11
|
-
# # - how - Attribute to identify the form element.
|
12
|
-
# # - what - Value of that attribute.
|
13
|
-
# #
|
14
|
-
# def initialize( parent_table)
|
15
|
-
# element = container
|
16
|
-
# @o = parent_table # in this case, @o is the parent table
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# # returns the number of TableBodies that exist in the table
|
20
|
-
# def length
|
21
|
-
# assert_exists
|
22
|
-
# return @o.tBodies.length
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# # returns the n'th Body as a FireWatir TableBody object
|
26
|
-
# def []n
|
27
|
-
# assert_exists
|
28
|
-
# return TableBody.new(element, :direct, ole_table_body_at_index(n))
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# # returns an ole table body
|
32
|
-
# def ole_table_body_at_index(n)
|
33
|
-
# return @o.tBodies[(n-1).to_s]
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# # iterates through each of the TableBodies in the Table. Yields a TableBody object
|
37
|
-
# def each
|
38
|
-
# 1.upto( @o.tBodies.length ) { |i| yield TableBody.new(element, :direct, ole_table_body_at_index(i)) }
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# end # TableBodies
|
42
|
-
#
|
43
|
-
# # this class is a table body
|
44
|
-
# # TODO: Implement TableBody class
|
45
|
-
# class TableBody < Element
|
46
|
-
# def locate
|
47
|
-
# @o = nil
|
48
|
-
# if @how == :direct
|
49
|
-
# @o = @what # in this case, @o is the table body
|
50
|
-
# elsif @how == :index
|
51
|
-
# @o = @parent_table.bodies.ole_table_body_at_index(@what)
|
52
|
-
# end
|
53
|
-
# @rows = []
|
54
|
-
# if @o
|
55
|
-
# @o.rows.each do |oo|
|
56
|
-
# @rows << TableRow.new(element, :direct, oo)
|
57
|
-
# end
|
58
|
-
# end
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
#
|
62
|
-
# # Description:
|
63
|
-
# # Initializes the form element.
|
64
|
-
# #
|
65
|
-
# # Input:
|
66
|
-
# # - how - Attribute to identify the form element.
|
67
|
-
# # - what - Value of that attribute.
|
68
|
-
# #
|
69
|
-
# def initialize( how, what, parent_table = nil)
|
70
|
-
# element = container
|
71
|
-
# @how = how
|
72
|
-
# @what = what
|
73
|
-
# @parent_table = parent_table
|
74
|
-
# super nil
|
75
|
-
# end
|
76
|
-
#
|
77
|
-
# # returns the specified row as a TableRow object
|
78
|
-
# def [](n)
|
79
|
-
# assert_exists
|
80
|
-
# return @rows[n - 1]
|
81
|
-
# end
|
82
|
-
#
|
83
|
-
# # iterates through all the rows in the table body
|
84
|
-
# def each
|
85
|
-
# locate
|
86
|
-
# 0.upto(@rows.length - 1) { |i| yield @rows[i] }
|
87
|
-
# end
|
88
|
-
#
|
89
|
-
# # returns the number of rows in this table body.
|
90
|
-
# def length
|
91
|
-
# return @rows.length
|
92
|
-
# end
|
93
|
-
# end # TableBody
|
94
|
-
|
95
|
-
# # this class is the super class for the iterator classes ( buttons, links, spans etc
|
96
|
-
# # it would normally only be accessed by the iterator methods ( spans , links etc) of IE
|
97
|
-
# class ElementCollections
|
98
|
-
# include Enumerable
|
99
|
-
# include Container
|
100
|
-
#
|
101
|
-
# # Super class for all the iteractor classes
|
102
|
-
# # * container - an instance of an IE object
|
103
|
-
# def initialize( container)
|
104
|
-
# element = container
|
105
|
-
# @length = length() # defined by subclasses
|
106
|
-
#
|
107
|
-
# # set up the items we want to display when the show method s used
|
108
|
-
# set_show_items
|
109
|
-
# end
|
110
|
-
#
|
111
|
-
# private
|
112
|
-
# def set_show_items
|
113
|
-
# @show_attributes = AttributeLengthPairs.new( "id" , 20)
|
114
|
-
# @show_attributes.add( "name" , 20)
|
115
|
-
# end
|
116
|
-
#
|
117
|
-
# public
|
118
|
-
# def get_length_of_input_objects(object_type)
|
119
|
-
# object_types =
|
120
|
-
# if object_type.kind_of? Array
|
121
|
-
# object_type
|
122
|
-
# else
|
123
|
-
# [ object_type ]
|
124
|
-
# end
|
125
|
-
#
|
126
|
-
# length = 0
|
127
|
-
# objects = element.document.getElementsByTagName("INPUT")
|
128
|
-
# if objects.length > 0
|
129
|
-
# objects.each do |o|
|
130
|
-
# length += 1 if object_types.include?(o.invoke("type").downcase )
|
131
|
-
# end
|
132
|
-
# end
|
133
|
-
# return length
|
134
|
-
# end
|
135
|
-
#
|
136
|
-
# # iterate through each of the elements in the collection in turn
|
137
|
-
# def each
|
138
|
-
# 0.upto( @length-1 ) { |i | yield iterator_object(i) }
|
139
|
-
# end
|
140
|
-
#
|
141
|
-
# # allows access to a specific item in the collection
|
142
|
-
# def [](n)
|
143
|
-
# return iterator_object(n-1)
|
144
|
-
# end
|
145
|
-
#
|
146
|
-
# # this method is the way to show the objects, normally used from irb
|
147
|
-
# def show
|
148
|
-
# s="index".ljust(6)
|
149
|
-
# @show_attributes.each do |attribute_length_pair|
|
150
|
-
# s=s + attribute_length_pair.attribute.ljust(attribute_length_pair.length)
|
151
|
-
# end
|
152
|
-
#
|
153
|
-
# index = 1
|
154
|
-
# self.each do |o|
|
155
|
-
# s= s+"\n"
|
156
|
-
# s=s + index.to_s.ljust(6)
|
157
|
-
# @show_attributes.each do |attribute_length_pair|
|
158
|
-
# begin
|
159
|
-
# s=s + eval( 'o.getOLEObject.invoke("#{attribute_length_pair.attribute}")').to_s.ljust( attribute_length_pair.length )
|
160
|
-
# rescue=>e
|
161
|
-
# s=s+ " ".ljust( attribute_length_pair.length )
|
162
|
-
# end
|
163
|
-
# end
|
164
|
-
# index+=1
|
165
|
-
# end
|
166
|
-
# puts s
|
167
|
-
# end
|
168
|
-
#
|
169
|
-
# # this method creates an object of the correct type that the iterators use
|
170
|
-
# private
|
171
|
-
# def iterator_object(i)
|
172
|
-
# element_class.new(element, :index, i+1)
|
173
|
-
# end
|
174
|
-
# end
|
175
|
-
#
|
176
|
-
# # --
|
177
|
-
# # These classes are not for public consumption, so we switch off rdoc
|
178
|
-
# #
|
179
|
-
# # presumes element_class or element_tag is defined
|
180
|
-
# # for subclasses of ElementCollections
|
181
|
-
# module CommonCollection
|
182
|
-
# def element_tag
|
183
|
-
# element_class.tag
|
184
|
-
# end
|
185
|
-
# def length
|
186
|
-
# element.document.getElementsByTagName(element_tag).length
|
187
|
-
# end
|
188
|
-
# end
|
189
|
-
#
|
190
|
-
# # This class is used as part of the .show method of the iterators class
|
191
|
-
# # it would not normally be used by a user
|
192
|
-
# class AttributeLengthPairs
|
193
|
-
#
|
194
|
-
# # This class is used as part of the .show method of the iterators class
|
195
|
-
# # it would not normally be used by a user
|
196
|
-
# class AttributeLengthHolder
|
197
|
-
# attr_accessor :attribute
|
198
|
-
# attr_accessor :length
|
199
|
-
#
|
200
|
-
# def initialize( attrib, length)
|
201
|
-
# @attribute = attrib
|
202
|
-
# @length = length
|
203
|
-
# end
|
204
|
-
# end
|
205
|
-
#
|
206
|
-
# def initialize( attrib=nil , length=nil)
|
207
|
-
# @attr=[]
|
208
|
-
# add( attrib , length ) if attrib
|
209
|
-
# @index_counter=0
|
210
|
-
# end
|
211
|
-
#
|
212
|
-
# # BUG: Untested. (Null implementation passes all tests.)
|
213
|
-
# def add( attrib , length)
|
214
|
-
# @attr << AttributeLengthHolder.new( attrib , length )
|
215
|
-
# end
|
216
|
-
#
|
217
|
-
# def delete(attrib)
|
218
|
-
# item_to_delete=nil
|
219
|
-
# @attr.each_with_index do |e,i|
|
220
|
-
# item_to_delete = i if e.attribute==attrib
|
221
|
-
# end
|
222
|
-
# @attr.delete_at(item_to_delete ) unless item_to_delete == nil
|
223
|
-
# end
|
224
|
-
#
|
225
|
-
# def next
|
226
|
-
# temp = @attr[@index_counter]
|
227
|
-
# @index_counter +=1
|
228
|
-
# return temp
|
229
|
-
# end
|
230
|
-
#
|
231
|
-
# def each
|
232
|
-
# 0.upto( @attr.length-1 ) { |i | yield @attr[i] }
|
233
|
-
# end
|
234
|
-
# end
|
235
|
-
#
|
236
|
-
|
237
|
-
#
|
238
|
-
#
|
239
|
-
# # Module for handling the Javascript pop-ups. Not in use currently, will be available in future.
|
240
|
-
# # Use ff.startClicker() method for clicking javascript pop ups. Refer to unit tests on how to handle
|
241
|
-
# # javascript pop up (unittests/javascript_test.rb)
|
242
|
-
# module Dialog
|
243
|
-
# # Class for handling javascript popup. Not in use currently, will be available in future. See unit tests on how to handle
|
244
|
-
# # javascript pop up (unittests/javascript_test.rb).
|
245
|
-
# class JSPopUp
|
246
|
-
# include Container
|
247
|
-
#
|
248
|
-
# def has_appeared(text)
|
249
|
-
# require 'socket'
|
250
|
-
# sleep 4
|
251
|
-
# shell = TCPSocket.new("localhost", 9997)
|
252
|
-
# read_socket(shell)
|
253
|
-
# #jssh_command = "var url = document.URL;"
|
254
|
-
# jssh_command = "var length = getWindows().length; var win;length;\n"
|
255
|
-
# #jssh_command << "for(var i = 0; i < length; i++)"
|
256
|
-
# #jssh_command << "{"
|
257
|
-
# #jssh_command << " win = getWindows()[i];"
|
258
|
-
# #jssh_command << " if(win.opener != null && "
|
259
|
-
# #jssh_command << " win.title == \"[JavaScript Application]\" &&"
|
260
|
-
# #jssh_command << " win.opener.document.URL == url)"
|
261
|
-
# #jssh_command << " {"
|
262
|
-
# #jssh_command << " break;"
|
263
|
-
# #jssh_command << " }"
|
264
|
-
# #jssh_command << "}"
|
265
|
-
#
|
266
|
-
# #jssh_command << " win.title;\n";
|
267
|
-
# #jssh_command << "var dialog = win.document.childNodes[0];"
|
268
|
-
# #jssh_command << "vbox = dialog.childNodes[1].childNodes[1];"
|
269
|
-
# #jssh_command << "vbox.childNodes[1].childNodes[0].childNodes[0].textContent;\n"
|
270
|
-
# puts jssh_command
|
271
|
-
# shell.send("#{jssh_command}", 0)
|
272
|
-
# jstext = read_socket(shell)
|
273
|
-
# puts jstext
|
274
|
-
# return jstext == text
|
275
|
-
# end
|
276
|
-
# end # JSPopUp
|
277
|
-
# end # Dialog
|
278
|
-
#
|
1
|
+
# # this class is a collection of the table body objects that exist in the table
|
2
|
+
# # it wouldnt normally be created by a user, but gets returned by the bodies method of the Table object
|
3
|
+
# # many of the methods available to this object are inherited from the Element class
|
4
|
+
# # TODO: Implement TableBodies class.
|
5
|
+
# class TableBodies < Element
|
6
|
+
#
|
7
|
+
# # Description:
|
8
|
+
# # Initializes the form element.
|
9
|
+
# #
|
10
|
+
# # Input:
|
11
|
+
# # - how - Attribute to identify the form element.
|
12
|
+
# # - what - Value of that attribute.
|
13
|
+
# #
|
14
|
+
# def initialize( parent_table)
|
15
|
+
# element = container
|
16
|
+
# @o = parent_table # in this case, @o is the parent table
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# # returns the number of TableBodies that exist in the table
|
20
|
+
# def length
|
21
|
+
# assert_exists
|
22
|
+
# return @o.tBodies.length
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # returns the n'th Body as a FireWatir TableBody object
|
26
|
+
# def []n
|
27
|
+
# assert_exists
|
28
|
+
# return TableBody.new(element, :direct, ole_table_body_at_index(n))
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # returns an ole table body
|
32
|
+
# def ole_table_body_at_index(n)
|
33
|
+
# return @o.tBodies[(n-1).to_s]
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# # iterates through each of the TableBodies in the Table. Yields a TableBody object
|
37
|
+
# def each
|
38
|
+
# 1.upto( @o.tBodies.length ) { |i| yield TableBody.new(element, :direct, ole_table_body_at_index(i)) }
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# end # TableBodies
|
42
|
+
#
|
43
|
+
# # this class is a table body
|
44
|
+
# # TODO: Implement TableBody class
|
45
|
+
# class TableBody < Element
|
46
|
+
# def locate
|
47
|
+
# @o = nil
|
48
|
+
# if @how == :direct
|
49
|
+
# @o = @what # in this case, @o is the table body
|
50
|
+
# elsif @how == :index
|
51
|
+
# @o = @parent_table.bodies.ole_table_body_at_index(@what)
|
52
|
+
# end
|
53
|
+
# @rows = []
|
54
|
+
# if @o
|
55
|
+
# @o.rows.each do |oo|
|
56
|
+
# @rows << TableRow.new(element, :direct, oo)
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# # Description:
|
63
|
+
# # Initializes the form element.
|
64
|
+
# #
|
65
|
+
# # Input:
|
66
|
+
# # - how - Attribute to identify the form element.
|
67
|
+
# # - what - Value of that attribute.
|
68
|
+
# #
|
69
|
+
# def initialize( how, what, parent_table = nil)
|
70
|
+
# element = container
|
71
|
+
# @how = how
|
72
|
+
# @what = what
|
73
|
+
# @parent_table = parent_table
|
74
|
+
# super nil
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# # returns the specified row as a TableRow object
|
78
|
+
# def [](n)
|
79
|
+
# assert_exists
|
80
|
+
# return @rows[n - 1]
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# # iterates through all the rows in the table body
|
84
|
+
# def each
|
85
|
+
# locate
|
86
|
+
# 0.upto(@rows.length - 1) { |i| yield @rows[i] }
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# # returns the number of rows in this table body.
|
90
|
+
# def length
|
91
|
+
# return @rows.length
|
92
|
+
# end
|
93
|
+
# end # TableBody
|
94
|
+
|
95
|
+
# # this class is the super class for the iterator classes ( buttons, links, spans etc
|
96
|
+
# # it would normally only be accessed by the iterator methods ( spans , links etc) of IE
|
97
|
+
# class ElementCollections
|
98
|
+
# include Enumerable
|
99
|
+
# include Container
|
100
|
+
#
|
101
|
+
# # Super class for all the iteractor classes
|
102
|
+
# # * container - an instance of an IE object
|
103
|
+
# def initialize( container)
|
104
|
+
# element = container
|
105
|
+
# @length = length() # defined by subclasses
|
106
|
+
#
|
107
|
+
# # set up the items we want to display when the show method s used
|
108
|
+
# set_show_items
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
# private
|
112
|
+
# def set_show_items
|
113
|
+
# @show_attributes = AttributeLengthPairs.new( "id" , 20)
|
114
|
+
# @show_attributes.add( "name" , 20)
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# public
|
118
|
+
# def get_length_of_input_objects(object_type)
|
119
|
+
# object_types =
|
120
|
+
# if object_type.kind_of? Array
|
121
|
+
# object_type
|
122
|
+
# else
|
123
|
+
# [ object_type ]
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# length = 0
|
127
|
+
# objects = element.document.getElementsByTagName("INPUT")
|
128
|
+
# if objects.length > 0
|
129
|
+
# objects.each do |o|
|
130
|
+
# length += 1 if object_types.include?(o.invoke("type").downcase )
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
# return length
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# # iterate through each of the elements in the collection in turn
|
137
|
+
# def each
|
138
|
+
# 0.upto( @length-1 ) { |i | yield iterator_object(i) }
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# # allows access to a specific item in the collection
|
142
|
+
# def [](n)
|
143
|
+
# return iterator_object(n-1)
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# # this method is the way to show the objects, normally used from irb
|
147
|
+
# def show
|
148
|
+
# s="index".ljust(6)
|
149
|
+
# @show_attributes.each do |attribute_length_pair|
|
150
|
+
# s=s + attribute_length_pair.attribute.ljust(attribute_length_pair.length)
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
# index = 1
|
154
|
+
# self.each do |o|
|
155
|
+
# s= s+"\n"
|
156
|
+
# s=s + index.to_s.ljust(6)
|
157
|
+
# @show_attributes.each do |attribute_length_pair|
|
158
|
+
# begin
|
159
|
+
# s=s + eval( 'o.getOLEObject.invoke("#{attribute_length_pair.attribute}")').to_s.ljust( attribute_length_pair.length )
|
160
|
+
# rescue=>e
|
161
|
+
# s=s+ " ".ljust( attribute_length_pair.length )
|
162
|
+
# end
|
163
|
+
# end
|
164
|
+
# index+=1
|
165
|
+
# end
|
166
|
+
# puts s
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# # this method creates an object of the correct type that the iterators use
|
170
|
+
# private
|
171
|
+
# def iterator_object(i)
|
172
|
+
# element_class.new(element, :index, i+1)
|
173
|
+
# end
|
174
|
+
# end
|
175
|
+
#
|
176
|
+
# # --
|
177
|
+
# # These classes are not for public consumption, so we switch off rdoc
|
178
|
+
# #
|
179
|
+
# # presumes element_class or element_tag is defined
|
180
|
+
# # for subclasses of ElementCollections
|
181
|
+
# module CommonCollection
|
182
|
+
# def element_tag
|
183
|
+
# element_class.tag
|
184
|
+
# end
|
185
|
+
# def length
|
186
|
+
# element.document.getElementsByTagName(element_tag).length
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
#
|
190
|
+
# # This class is used as part of the .show method of the iterators class
|
191
|
+
# # it would not normally be used by a user
|
192
|
+
# class AttributeLengthPairs
|
193
|
+
#
|
194
|
+
# # This class is used as part of the .show method of the iterators class
|
195
|
+
# # it would not normally be used by a user
|
196
|
+
# class AttributeLengthHolder
|
197
|
+
# attr_accessor :attribute
|
198
|
+
# attr_accessor :length
|
199
|
+
#
|
200
|
+
# def initialize( attrib, length)
|
201
|
+
# @attribute = attrib
|
202
|
+
# @length = length
|
203
|
+
# end
|
204
|
+
# end
|
205
|
+
#
|
206
|
+
# def initialize( attrib=nil , length=nil)
|
207
|
+
# @attr=[]
|
208
|
+
# add( attrib , length ) if attrib
|
209
|
+
# @index_counter=0
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
# # BUG: Untested. (Null implementation passes all tests.)
|
213
|
+
# def add( attrib , length)
|
214
|
+
# @attr << AttributeLengthHolder.new( attrib , length )
|
215
|
+
# end
|
216
|
+
#
|
217
|
+
# def delete(attrib)
|
218
|
+
# item_to_delete=nil
|
219
|
+
# @attr.each_with_index do |e,i|
|
220
|
+
# item_to_delete = i if e.attribute==attrib
|
221
|
+
# end
|
222
|
+
# @attr.delete_at(item_to_delete ) unless item_to_delete == nil
|
223
|
+
# end
|
224
|
+
#
|
225
|
+
# def next
|
226
|
+
# temp = @attr[@index_counter]
|
227
|
+
# @index_counter +=1
|
228
|
+
# return temp
|
229
|
+
# end
|
230
|
+
#
|
231
|
+
# def each
|
232
|
+
# 0.upto( @attr.length-1 ) { |i | yield @attr[i] }
|
233
|
+
# end
|
234
|
+
# end
|
235
|
+
#
|
236
|
+
|
237
|
+
#
|
238
|
+
#
|
239
|
+
# # Module for handling the Javascript pop-ups. Not in use currently, will be available in future.
|
240
|
+
# # Use ff.startClicker() method for clicking javascript pop ups. Refer to unit tests on how to handle
|
241
|
+
# # javascript pop up (unittests/javascript_test.rb)
|
242
|
+
# module Dialog
|
243
|
+
# # Class for handling javascript popup. Not in use currently, will be available in future. See unit tests on how to handle
|
244
|
+
# # javascript pop up (unittests/javascript_test.rb).
|
245
|
+
# class JSPopUp
|
246
|
+
# include Container
|
247
|
+
#
|
248
|
+
# def has_appeared(text)
|
249
|
+
# require 'socket'
|
250
|
+
# sleep 4
|
251
|
+
# shell = TCPSocket.new("localhost", 9997)
|
252
|
+
# read_socket(shell)
|
253
|
+
# #jssh_command = "var url = document.URL;"
|
254
|
+
# jssh_command = "var length = getWindows().length; var win;length;\n"
|
255
|
+
# #jssh_command << "for(var i = 0; i < length; i++)"
|
256
|
+
# #jssh_command << "{"
|
257
|
+
# #jssh_command << " win = getWindows()[i];"
|
258
|
+
# #jssh_command << " if(win.opener != null && "
|
259
|
+
# #jssh_command << " win.title == \"[JavaScript Application]\" &&"
|
260
|
+
# #jssh_command << " win.opener.document.URL == url)"
|
261
|
+
# #jssh_command << " {"
|
262
|
+
# #jssh_command << " break;"
|
263
|
+
# #jssh_command << " }"
|
264
|
+
# #jssh_command << "}"
|
265
|
+
#
|
266
|
+
# #jssh_command << " win.title;\n";
|
267
|
+
# #jssh_command << "var dialog = win.document.childNodes[0];"
|
268
|
+
# #jssh_command << "vbox = dialog.childNodes[1].childNodes[1];"
|
269
|
+
# #jssh_command << "vbox.childNodes[1].childNodes[0].childNodes[0].textContent;\n"
|
270
|
+
# puts jssh_command
|
271
|
+
# shell.send("#{jssh_command}", 0)
|
272
|
+
# jstext = read_socket(shell)
|
273
|
+
# puts jstext
|
274
|
+
# return jstext == text
|
275
|
+
# end
|
276
|
+
# end # JSPopUp
|
277
|
+
# end # Dialog
|
278
|
+
#
|