firewatir 1.6.5 → 1.6.6.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,314 +1,314 @@
|
|
1
|
-
module FireWatir
|
2
|
-
|
3
|
-
#
|
4
|
-
# Description:
|
5
|
-
# Class for iterating over elements of common type like links, images, divs etc.
|
6
|
-
#
|
7
|
-
class ElementCollections
|
8
|
-
include Enumerable
|
9
|
-
include JsshSocket
|
10
|
-
|
11
|
-
def self.inherited subclass
|
12
|
-
class_name = subclass.to_s.demodulize
|
13
|
-
method_name = class_name.underscore
|
14
|
-
element_class_name = class_name.singularize
|
15
|
-
|
16
|
-
FireWatir::Container.module_eval "def #{method_name}
|
17
|
-
locate if respond_to?(:locate)
|
18
|
-
return #{class_name}.new(self); end"
|
19
|
-
|
20
|
-
subclass.class_eval "def element_class; #{element_class_name}; end"
|
21
|
-
end
|
22
|
-
|
23
|
-
@@current_level = 0
|
24
|
-
|
25
|
-
def initialize(container)
|
26
|
-
@container = container
|
27
|
-
elements = locate_elements
|
28
|
-
length = elements.length
|
29
|
-
#puts "length is : #{length}"
|
30
|
-
@element_objects = Array.new(length)
|
31
|
-
for i in 0..length - 1 do
|
32
|
-
@element_objects[i] = element_class.new(container, :jssh_name, elements[i])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# default implementation. overridden by some subclasses.
|
37
|
-
def locate_elements
|
38
|
-
locate_tagged_elements(element_class::TAG)
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
# Return all the elements of give tag and type inside the container.
|
43
|
-
#
|
44
|
-
# Input:
|
45
|
-
# tag - tag name of the elements
|
46
|
-
# types - array of element type names. used in case where same
|
47
|
-
# element tag has different types like input has type image, button etc.
|
48
|
-
#
|
49
|
-
def locate_tagged_elements(tag, types = [])
|
50
|
-
|
51
|
-
# generate array to hold results
|
52
|
-
result_name = "arr_coll_#{tag}_#{@@current_level}"
|
53
|
-
jssh_command = "var #{result_name}=new Array();"
|
54
|
-
|
55
|
-
# generate array of elements matching the tag
|
56
|
-
case @container
|
57
|
-
when FireWatir::Firefox, FireWatir::Frame
|
58
|
-
elements_tag = "elements_#{tag}"
|
59
|
-
container_name = "#{@container.document_var}"
|
60
|
-
else
|
61
|
-
elements_tag = "elements_#{@@current_level}_#{tag}"
|
62
|
-
container_name = @container.element_name
|
63
|
-
end
|
64
|
-
if types.include?("textarea") || types.include?("button")
|
65
|
-
search_tag = '*'
|
66
|
-
else
|
67
|
-
search_tag = tag
|
68
|
-
end
|
69
|
-
jssh_command << "var #{elements_tag} = null; "
|
70
|
-
jssh_command << "#{elements_tag} = #{container_name}.getElementsByTagName(\"#{search_tag}\");"
|
71
|
-
|
72
|
-
|
73
|
-
# generate array containing results
|
74
|
-
if types.empty?
|
75
|
-
jssh_command << "#{result_name} = #{elements_tag};"
|
76
|
-
else
|
77
|
-
# generate types array
|
78
|
-
jssh_command << "var types = new Array("
|
79
|
-
types.each_with_index do |type, count|
|
80
|
-
jssh_command << "," unless count == 0
|
81
|
-
jssh_command << "\"#{type}\""
|
82
|
-
end
|
83
|
-
jssh_command << ");"
|
84
|
-
|
85
|
-
# check the type of each element
|
86
|
-
jssh_command << "
|
87
|
-
for(var i=0; i<#{elements_tag}.length; i++)
|
88
|
-
{
|
89
|
-
var element = #{elements_tag} [i];
|
90
|
-
var same_type = false;
|
91
|
-
|
92
|
-
for (var j = 0; j < types.length; j++)
|
93
|
-
{
|
94
|
-
if (types[j] == element.type || types[j] == element.tagName)
|
95
|
-
{
|
96
|
-
same_type = true;
|
97
|
-
break;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
if (same_type)
|
102
|
-
{
|
103
|
-
#{result_name}.push(element);
|
104
|
-
}
|
105
|
-
};"
|
106
|
-
end
|
107
|
-
jssh_command << "#{result_name}.length;"
|
108
|
-
|
109
|
-
# Remove \n that are there in the string as a result of pressing enter while formatting.
|
110
|
-
jssh_command.gsub!(/\n/, "")
|
111
|
-
#puts jssh_command
|
112
|
-
jssh_socket.send("#{jssh_command};\n", 0)
|
113
|
-
length = read_socket().to_i;
|
114
|
-
#puts "elements length is in locate_tagged_elements is : #{length}"
|
115
|
-
|
116
|
-
elements = (0...length).collect {|i| "#{result_name}[#{i}]"}
|
117
|
-
|
118
|
-
@@current_level = @@current_level + 1
|
119
|
-
return elements
|
120
|
-
end
|
121
|
-
private :locate_tagged_elements
|
122
|
-
|
123
|
-
#
|
124
|
-
# Description:
|
125
|
-
# Gets the length of elements of same tag and type found on the page.
|
126
|
-
#
|
127
|
-
# Ouput:
|
128
|
-
# Count of elements found on the page.
|
129
|
-
#
|
130
|
-
def length
|
131
|
-
return @element_objects.length
|
132
|
-
end
|
133
|
-
alias_method :size, :length
|
134
|
-
|
135
|
-
#
|
136
|
-
# Description:
|
137
|
-
# Iterate over the elements of same tag and type found on the page.
|
138
|
-
#
|
139
|
-
def each
|
140
|
-
for i in 0..@element_objects.length - 1
|
141
|
-
yield @element_objects[i]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
#
|
146
|
-
# Description:
|
147
|
-
# Accesses nth element of same tag and type found on the page.
|
148
|
-
#
|
149
|
-
# Input:
|
150
|
-
# n - index of element (1 based)
|
151
|
-
#
|
152
|
-
def [](n)
|
153
|
-
return @element_objects[n-1]
|
154
|
-
end
|
155
|
-
|
156
|
-
#
|
157
|
-
# Returns the first element in the collection.
|
158
|
-
#
|
159
|
-
|
160
|
-
def first
|
161
|
-
@element_objects.first
|
162
|
-
end
|
163
|
-
|
164
|
-
#
|
165
|
-
# Returns the last element in the collection.
|
166
|
-
#
|
167
|
-
|
168
|
-
def last
|
169
|
-
@element_objects.last
|
170
|
-
end
|
171
|
-
|
172
|
-
def to_s
|
173
|
-
map { |e| e.to_s }.join("\n")
|
174
|
-
end
|
175
|
-
|
176
|
-
def inspect
|
177
|
-
'#<%s:0x%x length=%s container=%s> elements=%s>' %
|
178
|
-
[self.class, hash*2, length.inspect, @container.inspect, @element_objects.inspect]
|
179
|
-
end
|
180
|
-
|
181
|
-
end # ElementCollections
|
182
|
-
|
183
|
-
# Class for accessing all the button elements in the document.
|
184
|
-
# It would normally only be accessed by the FireWatir::Container#buttons method
|
185
|
-
class Buttons < ElementCollections
|
186
|
-
def locate_elements
|
187
|
-
locate_tagged_elements("input", ["button", "image", "submit", "reset"])
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
# Class for accessing all the File Field elements in the document.
|
192
|
-
# It would normally only be accessed by the FireWatir::Container#file_fields method
|
193
|
-
class FileFields < ElementCollections
|
194
|
-
def locate_elements
|
195
|
-
locate_tagged_elements("input", ["file"])
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# Class for accessing all the CheckBox elements in the document.
|
200
|
-
# It would normally only be accessed by the FireWatir::Container#checkboxes method
|
201
|
-
class CheckBoxes < ElementCollections
|
202
|
-
def locate_elements
|
203
|
-
locate_tagged_elements("input", ["checkbox"])
|
204
|
-
end
|
205
|
-
end
|
206
|
-
module Container
|
207
|
-
alias checkboxes check_boxes
|
208
|
-
end
|
209
|
-
|
210
|
-
# Class for accessing all the Radio button elements in the document.
|
211
|
-
# It would normally only be accessed by the FireWatir::Container#radios method
|
212
|
-
class Radios < ElementCollections
|
213
|
-
def locate_elements
|
214
|
-
locate_tagged_elements("input", ["radio"])
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# Class for accessing all the select list elements in the document.
|
219
|
-
# It would normally only be accessed by the FireWatir::Container#select_lists method
|
220
|
-
class SelectLists < ElementCollections
|
221
|
-
def locate_elements
|
222
|
-
locate_tagged_elements("select", ["select-one", "select-multiple"])
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# Class for accessing all the link elements in the document.
|
227
|
-
# It would normally only be accessed by the FireWatir::Container#links method
|
228
|
-
class Links < ElementCollections; end
|
229
|
-
|
230
|
-
# Class for accessing all the image elements in the document.
|
231
|
-
# It would normally only be accessed by the FireWatir::Container#images method
|
232
|
-
class Images < ElementCollections; end
|
233
|
-
|
234
|
-
# Class for accessing all the text field elements in the document.
|
235
|
-
# It would normally only be accessed by the FireWatir::Container#text_fields method
|
236
|
-
class TextFields < ElementCollections
|
237
|
-
def locate_elements
|
238
|
-
locate_tagged_elements("input", ["text", "textarea", "password"])
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
# Class for accessing all the hidden elements in the document.
|
243
|
-
# It would normally only be accessed by the FireWatir::Container#hiddens method
|
244
|
-
class Hiddens < ElementCollections
|
245
|
-
def locate_elements
|
246
|
-
locate_tagged_elements("input", ["hidden"])
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
# Class for accessing all the table elements in the document.
|
251
|
-
# It would normally only be accessed by the FireWatir::Container#tables method
|
252
|
-
class Tables < ElementCollections; end
|
253
|
-
|
254
|
-
# Class for accessing all the label elements in the document.
|
255
|
-
# It would normally only be accessed by the FireWatir::Container#labels method
|
256
|
-
class Labels < ElementCollections; end
|
257
|
-
|
258
|
-
# Class for accessing all the pre element in the document.
|
259
|
-
# It would normally only be accessed by the FireWatir::Container#pres method
|
260
|
-
class Pres < ElementCollections; end
|
261
|
-
|
262
|
-
# Class for accessing all the paragraph elements in the document.
|
263
|
-
# It would normally only be accessed by the FireWatir::Container#ps method
|
264
|
-
class Ps < ElementCollections; end
|
265
|
-
|
266
|
-
# Class for accessing all the span elements in the document.
|
267
|
-
# It would normally only be accessed by the FireWatir::Container#spans method
|
268
|
-
class Spans < ElementCollections; end
|
269
|
-
|
270
|
-
# Class for accessing all the strong elements in the document.
|
271
|
-
# It would normally only be accessed by the FireWatir::Container#strongs method
|
272
|
-
class Strongs < ElementCollections; end
|
273
|
-
|
274
|
-
# Class for accessing all the div elements in the document.
|
275
|
-
# It would normally only be accessed by the FireWatir::Container#divs method
|
276
|
-
class Divs < ElementCollections; end
|
277
|
-
|
278
|
-
# Class for accessing all the ul elements in the document.
|
279
|
-
# It would normally only be accessed by the FireWatir::Container#uls method
|
280
|
-
class Uls < ElementCollections; end
|
281
|
-
|
282
|
-
# Class for accessing all the li elements in the document.
|
283
|
-
# It would normally only be accessed by the FireWatir::Container#lis method
|
284
|
-
class Lis < ElementCollections; end
|
285
|
-
|
286
|
-
# Class for accessing all the dl elements in the document.
|
287
|
-
# It would normally only be accessed by the FireWatir::Container#dls method
|
288
|
-
class Dls < ElementCollections; end
|
289
|
-
|
290
|
-
# Class for accessing all the dt elements in the document.
|
291
|
-
# It would normally only be accessed by the FireWatir::Container#dts method
|
292
|
-
class Dts < ElementCollections; end
|
293
|
-
|
294
|
-
# Class for accessing all the dd elements in the document.
|
295
|
-
# It would normally only be accessed by the FireWatir::Container#dds method
|
296
|
-
class Dds < ElementCollections; end
|
297
|
-
|
298
|
-
# Class for accessing all the dd elements in the document.
|
299
|
-
# It would normally only be accessed by the FireWatir::Container#dds method
|
300
|
-
class Ems < ElementCollections; end
|
301
|
-
|
302
|
-
# Class for accessing all the area elements in the document.
|
303
|
-
# It would normally only be accessed by the FireWatir::Container#areas method
|
304
|
-
class Areas < ElementCollections; end
|
305
|
-
|
306
|
-
# Class for accessing all the body elements in the document.
|
307
|
-
# It would normally only be accessed by the FireWatir::Container#bodies method
|
308
|
-
class Bodies < ElementCollections; end
|
309
|
-
|
310
|
-
# Class for accessing all the dd elements in the document.
|
311
|
-
# It would normally only be accessed by the FireWatir::Container#maps method
|
312
|
-
class Maps < ElementCollections; end
|
313
|
-
|
314
|
-
end # FireWatir
|
1
|
+
module FireWatir
|
2
|
+
|
3
|
+
#
|
4
|
+
# Description:
|
5
|
+
# Class for iterating over elements of common type like links, images, divs etc.
|
6
|
+
#
|
7
|
+
class ElementCollections
|
8
|
+
include Enumerable
|
9
|
+
include JsshSocket
|
10
|
+
|
11
|
+
def self.inherited subclass
|
12
|
+
class_name = subclass.to_s.demodulize
|
13
|
+
method_name = class_name.underscore
|
14
|
+
element_class_name = class_name.singularize
|
15
|
+
|
16
|
+
FireWatir::Container.module_eval "def #{method_name}
|
17
|
+
locate if respond_to?(:locate)
|
18
|
+
return #{class_name}.new(self); end"
|
19
|
+
|
20
|
+
subclass.class_eval "def element_class; #{element_class_name}; end"
|
21
|
+
end
|
22
|
+
|
23
|
+
@@current_level = 0
|
24
|
+
|
25
|
+
def initialize(container)
|
26
|
+
@container = container
|
27
|
+
elements = locate_elements
|
28
|
+
length = elements.length
|
29
|
+
#puts "length is : #{length}"
|
30
|
+
@element_objects = Array.new(length)
|
31
|
+
for i in 0..length - 1 do
|
32
|
+
@element_objects[i] = element_class.new(container, :jssh_name, elements[i])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# default implementation. overridden by some subclasses.
|
37
|
+
def locate_elements
|
38
|
+
locate_tagged_elements(element_class::TAG)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Return all the elements of give tag and type inside the container.
|
43
|
+
#
|
44
|
+
# Input:
|
45
|
+
# tag - tag name of the elements
|
46
|
+
# types - array of element type names. used in case where same
|
47
|
+
# element tag has different types like input has type image, button etc.
|
48
|
+
#
|
49
|
+
def locate_tagged_elements(tag, types = [])
|
50
|
+
|
51
|
+
# generate array to hold results
|
52
|
+
result_name = "arr_coll_#{tag}_#{@@current_level}"
|
53
|
+
jssh_command = "var #{result_name}=new Array();"
|
54
|
+
|
55
|
+
# generate array of elements matching the tag
|
56
|
+
case @container
|
57
|
+
when FireWatir::Firefox, FireWatir::Frame
|
58
|
+
elements_tag = "elements_#{tag}"
|
59
|
+
container_name = "#{@container.document_var}"
|
60
|
+
else
|
61
|
+
elements_tag = "elements_#{@@current_level}_#{tag}"
|
62
|
+
container_name = @container.element_name
|
63
|
+
end
|
64
|
+
if types.include?("textarea") || types.include?("button")
|
65
|
+
search_tag = '*'
|
66
|
+
else
|
67
|
+
search_tag = tag
|
68
|
+
end
|
69
|
+
jssh_command << "var #{elements_tag} = null; "
|
70
|
+
jssh_command << "#{elements_tag} = #{container_name}.getElementsByTagName(\"#{search_tag}\");"
|
71
|
+
|
72
|
+
|
73
|
+
# generate array containing results
|
74
|
+
if types.empty?
|
75
|
+
jssh_command << "#{result_name} = #{elements_tag};"
|
76
|
+
else
|
77
|
+
# generate types array
|
78
|
+
jssh_command << "var types = new Array("
|
79
|
+
types.each_with_index do |type, count|
|
80
|
+
jssh_command << "," unless count == 0
|
81
|
+
jssh_command << "\"#{type}\""
|
82
|
+
end
|
83
|
+
jssh_command << ");"
|
84
|
+
|
85
|
+
# check the type of each element
|
86
|
+
jssh_command << "
|
87
|
+
for(var i=0; i<#{elements_tag}.length; i++)
|
88
|
+
{
|
89
|
+
var element = #{elements_tag} [i];
|
90
|
+
var same_type = false;
|
91
|
+
|
92
|
+
for (var j = 0; j < types.length; j++)
|
93
|
+
{
|
94
|
+
if (types[j] == element.type || types[j] == element.tagName)
|
95
|
+
{
|
96
|
+
same_type = true;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
if (same_type)
|
102
|
+
{
|
103
|
+
#{result_name}.push(element);
|
104
|
+
}
|
105
|
+
};"
|
106
|
+
end
|
107
|
+
jssh_command << "#{result_name}.length;"
|
108
|
+
|
109
|
+
# Remove \n that are there in the string as a result of pressing enter while formatting.
|
110
|
+
jssh_command.gsub!(/\n/, "")
|
111
|
+
#puts jssh_command
|
112
|
+
jssh_socket.send("#{jssh_command};\n", 0)
|
113
|
+
length = read_socket().to_i;
|
114
|
+
#puts "elements length is in locate_tagged_elements is : #{length}"
|
115
|
+
|
116
|
+
elements = (0...length).collect {|i| "#{result_name}[#{i}]"}
|
117
|
+
|
118
|
+
@@current_level = @@current_level + 1
|
119
|
+
return elements
|
120
|
+
end
|
121
|
+
private :locate_tagged_elements
|
122
|
+
|
123
|
+
#
|
124
|
+
# Description:
|
125
|
+
# Gets the length of elements of same tag and type found on the page.
|
126
|
+
#
|
127
|
+
# Ouput:
|
128
|
+
# Count of elements found on the page.
|
129
|
+
#
|
130
|
+
def length
|
131
|
+
return @element_objects.length
|
132
|
+
end
|
133
|
+
alias_method :size, :length
|
134
|
+
|
135
|
+
#
|
136
|
+
# Description:
|
137
|
+
# Iterate over the elements of same tag and type found on the page.
|
138
|
+
#
|
139
|
+
def each
|
140
|
+
for i in 0..@element_objects.length - 1
|
141
|
+
yield @element_objects[i]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
#
|
146
|
+
# Description:
|
147
|
+
# Accesses nth element of same tag and type found on the page.
|
148
|
+
#
|
149
|
+
# Input:
|
150
|
+
# n - index of element (1 based)
|
151
|
+
#
|
152
|
+
def [](n)
|
153
|
+
return @element_objects[n-1]
|
154
|
+
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# Returns the first element in the collection.
|
158
|
+
#
|
159
|
+
|
160
|
+
def first
|
161
|
+
@element_objects.first
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# Returns the last element in the collection.
|
166
|
+
#
|
167
|
+
|
168
|
+
def last
|
169
|
+
@element_objects.last
|
170
|
+
end
|
171
|
+
|
172
|
+
def to_s
|
173
|
+
map { |e| e.to_s }.join("\n")
|
174
|
+
end
|
175
|
+
|
176
|
+
def inspect
|
177
|
+
'#<%s:0x%x length=%s container=%s> elements=%s>' %
|
178
|
+
[self.class, hash*2, length.inspect, @container.inspect, @element_objects.inspect]
|
179
|
+
end
|
180
|
+
|
181
|
+
end # ElementCollections
|
182
|
+
|
183
|
+
# Class for accessing all the button elements in the document.
|
184
|
+
# It would normally only be accessed by the FireWatir::Container#buttons method
|
185
|
+
class Buttons < ElementCollections
|
186
|
+
def locate_elements
|
187
|
+
locate_tagged_elements("input", ["button", "image", "submit", "reset"])
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Class for accessing all the File Field elements in the document.
|
192
|
+
# It would normally only be accessed by the FireWatir::Container#file_fields method
|
193
|
+
class FileFields < ElementCollections
|
194
|
+
def locate_elements
|
195
|
+
locate_tagged_elements("input", ["file"])
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Class for accessing all the CheckBox elements in the document.
|
200
|
+
# It would normally only be accessed by the FireWatir::Container#checkboxes method
|
201
|
+
class CheckBoxes < ElementCollections
|
202
|
+
def locate_elements
|
203
|
+
locate_tagged_elements("input", ["checkbox"])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
module Container
|
207
|
+
alias checkboxes check_boxes
|
208
|
+
end
|
209
|
+
|
210
|
+
# Class for accessing all the Radio button elements in the document.
|
211
|
+
# It would normally only be accessed by the FireWatir::Container#radios method
|
212
|
+
class Radios < ElementCollections
|
213
|
+
def locate_elements
|
214
|
+
locate_tagged_elements("input", ["radio"])
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Class for accessing all the select list elements in the document.
|
219
|
+
# It would normally only be accessed by the FireWatir::Container#select_lists method
|
220
|
+
class SelectLists < ElementCollections
|
221
|
+
def locate_elements
|
222
|
+
locate_tagged_elements("select", ["select-one", "select-multiple"])
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# Class for accessing all the link elements in the document.
|
227
|
+
# It would normally only be accessed by the FireWatir::Container#links method
|
228
|
+
class Links < ElementCollections; end
|
229
|
+
|
230
|
+
# Class for accessing all the image elements in the document.
|
231
|
+
# It would normally only be accessed by the FireWatir::Container#images method
|
232
|
+
class Images < ElementCollections; end
|
233
|
+
|
234
|
+
# Class for accessing all the text field elements in the document.
|
235
|
+
# It would normally only be accessed by the FireWatir::Container#text_fields method
|
236
|
+
class TextFields < ElementCollections
|
237
|
+
def locate_elements
|
238
|
+
locate_tagged_elements("input", ["text", "textarea", "password"])
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
# Class for accessing all the hidden elements in the document.
|
243
|
+
# It would normally only be accessed by the FireWatir::Container#hiddens method
|
244
|
+
class Hiddens < ElementCollections
|
245
|
+
def locate_elements
|
246
|
+
locate_tagged_elements("input", ["hidden"])
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
# Class for accessing all the table elements in the document.
|
251
|
+
# It would normally only be accessed by the FireWatir::Container#tables method
|
252
|
+
class Tables < ElementCollections; end
|
253
|
+
|
254
|
+
# Class for accessing all the label elements in the document.
|
255
|
+
# It would normally only be accessed by the FireWatir::Container#labels method
|
256
|
+
class Labels < ElementCollections; end
|
257
|
+
|
258
|
+
# Class for accessing all the pre element in the document.
|
259
|
+
# It would normally only be accessed by the FireWatir::Container#pres method
|
260
|
+
class Pres < ElementCollections; end
|
261
|
+
|
262
|
+
# Class for accessing all the paragraph elements in the document.
|
263
|
+
# It would normally only be accessed by the FireWatir::Container#ps method
|
264
|
+
class Ps < ElementCollections; end
|
265
|
+
|
266
|
+
# Class for accessing all the span elements in the document.
|
267
|
+
# It would normally only be accessed by the FireWatir::Container#spans method
|
268
|
+
class Spans < ElementCollections; end
|
269
|
+
|
270
|
+
# Class for accessing all the strong elements in the document.
|
271
|
+
# It would normally only be accessed by the FireWatir::Container#strongs method
|
272
|
+
class Strongs < ElementCollections; end
|
273
|
+
|
274
|
+
# Class for accessing all the div elements in the document.
|
275
|
+
# It would normally only be accessed by the FireWatir::Container#divs method
|
276
|
+
class Divs < ElementCollections; end
|
277
|
+
|
278
|
+
# Class for accessing all the ul elements in the document.
|
279
|
+
# It would normally only be accessed by the FireWatir::Container#uls method
|
280
|
+
class Uls < ElementCollections; end
|
281
|
+
|
282
|
+
# Class for accessing all the li elements in the document.
|
283
|
+
# It would normally only be accessed by the FireWatir::Container#lis method
|
284
|
+
class Lis < ElementCollections; end
|
285
|
+
|
286
|
+
# Class for accessing all the dl elements in the document.
|
287
|
+
# It would normally only be accessed by the FireWatir::Container#dls method
|
288
|
+
class Dls < ElementCollections; end
|
289
|
+
|
290
|
+
# Class for accessing all the dt elements in the document.
|
291
|
+
# It would normally only be accessed by the FireWatir::Container#dts method
|
292
|
+
class Dts < ElementCollections; end
|
293
|
+
|
294
|
+
# Class for accessing all the dd elements in the document.
|
295
|
+
# It would normally only be accessed by the FireWatir::Container#dds method
|
296
|
+
class Dds < ElementCollections; end
|
297
|
+
|
298
|
+
# Class for accessing all the dd elements in the document.
|
299
|
+
# It would normally only be accessed by the FireWatir::Container#dds method
|
300
|
+
class Ems < ElementCollections; end
|
301
|
+
|
302
|
+
# Class for accessing all the area elements in the document.
|
303
|
+
# It would normally only be accessed by the FireWatir::Container#areas method
|
304
|
+
class Areas < ElementCollections; end
|
305
|
+
|
306
|
+
# Class for accessing all the body elements in the document.
|
307
|
+
# It would normally only be accessed by the FireWatir::Container#bodies method
|
308
|
+
class Bodies < ElementCollections; end
|
309
|
+
|
310
|
+
# Class for accessing all the dd elements in the document.
|
311
|
+
# It would normally only be accessed by the FireWatir::Container#maps method
|
312
|
+
class Maps < ElementCollections; end
|
313
|
+
|
314
|
+
end # FireWatir
|