firewatir 1.2.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/firewatir.rb +50 -0
- data/lib/firewatir/MozillaBaseElement.rb +1863 -0
- data/lib/firewatir/container.rb +534 -0
- data/lib/firewatir/exceptions.rb +10 -0
- data/lib/firewatir/firefox.rb +1127 -0
- data/lib/firewatir/htmlelements.rb +1911 -0
- data/lib/firewatir/version.rb +5 -0
- data/{firewatir → lib/firewatir}/winClicker.rb +0 -0
- data/{firewatir → lib/firewatir}/x11.rb +0 -0
- data/unittests/attach_to_new_window_test.rb +20 -12
- data/unittests/bug_fixes_test.rb +79 -69
- data/unittests/buttons_xpath_test.rb +45 -44
- data/unittests/checkbox_test.rb +86 -85
- data/unittests/checkbox_xpath_test.rb +58 -58
- data/unittests/div_test.rb +117 -115
- data/unittests/filefield_test.rb +12 -12
- data/unittests/filefield_xpath_test.rb +11 -11
- data/unittests/form_test.rb +134 -133
- data/unittests/frame_test.rb +42 -41
- data/unittests/hidden_test.rb +40 -40
- data/unittests/hidden_xpath_test.rb +32 -32
- data/unittests/images_test.rb +85 -84
- data/unittests/images_xpath_test.rb +57 -56
- data/unittests/iostring_test.rb +1 -1
- data/unittests/javascript_test.rb +42 -38
- data/unittests/links_test.rb +88 -86
- data/unittests/links_xpath_test.rb +38 -38
- data/unittests/mozilla_all_tests.rb +2 -14
- data/unittests/pre_test.rb +27 -25
- data/unittests/radios_test.rb +86 -86
- data/unittests/radios_xpath_test.rb +48 -48
- data/unittests/redirect_test.rb +20 -19
- data/unittests/selectbox_test.rb +72 -71
- data/unittests/selectbox_xpath_test.rb +58 -56
- data/unittests/setup.rb +22 -27
- data/unittests/table_test.rb +89 -88
- data/unittests/table_xpath_test.rb +37 -36
- data/unittests/textfields_test.rb +105 -102
- data/unittests/textfields_xpath_test.rb +53 -52
- metadata +37 -18
- data/MozillaBaseElement.rb +0 -1780
- data/container.rb +0 -900
- data/firewatir.rb +0 -1195
- data/firewatir/exceptions.rb +0 -44
- data/firewatir/testUnitAddons.rb +0 -8
- data/htmlelements.rb +0 -2281
- data/unittests/buttons_test.rb +0 -215
@@ -0,0 +1,534 @@
|
|
1
|
+
=begin
|
2
|
+
#
|
3
|
+
# This module contains the factory methods that are used to access most html objects
|
4
|
+
#
|
5
|
+
# For example, to access a button on a web page that has the following html
|
6
|
+
# <input type = button name= 'b1' value='Click Me' onClick='javascript:doSomething()'>
|
7
|
+
#
|
8
|
+
# the following Firewatir code could be used
|
9
|
+
#
|
10
|
+
# ff.button(:name, 'b1').click
|
11
|
+
#
|
12
|
+
# or
|
13
|
+
#
|
14
|
+
# ff.button(:value, 'Click Me').to_s
|
15
|
+
#
|
16
|
+
# One can use any attribute to uniquely identify an element including the user defined attributes
|
17
|
+
# that is rendered on the HTML screen. Though, Attribute used to access an element depends on the type of element,
|
18
|
+
# attributes used frequently to address an element are listed below
|
19
|
+
#
|
20
|
+
# :index - find the item using the index in the container ( a container can be a document,
|
21
|
+
# a TableCell, a Span, a Div or a P)
|
22
|
+
# index is 1 based
|
23
|
+
# :name - find the item using the name attribute
|
24
|
+
# :id - find the item using the id attribute
|
25
|
+
# :value - find the item using the value attribute
|
26
|
+
# :caption - same as value
|
27
|
+
# :xpath - finds the item using xpath query
|
28
|
+
#
|
29
|
+
# Typical Usage
|
30
|
+
#
|
31
|
+
# ff.button(:id, 'b_1') # access the button with an ID of b_1
|
32
|
+
# ff.button(:name, 'verify_data') # access the button with a name of verify_data
|
33
|
+
# ff.button(:value, 'Login') # access the button with a value (the text displayed on the button) of Login
|
34
|
+
# ff.button(:caption, 'Login') # same as above
|
35
|
+
# ff.button(:value, /Log/) # access the button that has text matching /Log/
|
36
|
+
# ff.button(:index, 2) # access the second button on the page ( 1 based, so the first button is accessed with :index,1)
|
37
|
+
#
|
38
|
+
=end
|
39
|
+
|
40
|
+
require 'firewatir/exceptions'
|
41
|
+
|
42
|
+
module FireWatir
|
43
|
+
module Container
|
44
|
+
include FireWatir
|
45
|
+
include Watir::Exception
|
46
|
+
|
47
|
+
# IP Address of the machine where the script is to be executed. Default to localhost.
|
48
|
+
MACHINE_IP = "127.0.0.1"
|
49
|
+
# Name of the variable with which window is identified in JSSh.
|
50
|
+
WINDOW_VAR = "window"
|
51
|
+
# Name of the variable with which browser is identified in JSSh.
|
52
|
+
BROWSER_VAR = "browser"
|
53
|
+
# Name of the variable with which document is identified in JSSh.
|
54
|
+
DOCUMENT_VAR = "document"
|
55
|
+
# Name of the variable with which body is identified in JSSh.
|
56
|
+
BODY_VAR = "body"
|
57
|
+
|
58
|
+
|
59
|
+
# The delay when entering text on a web page when speed = :slow.
|
60
|
+
DEFAULT_TYPING_SPEED = 0.01
|
61
|
+
|
62
|
+
# The default time we wait after a page has loaded when speed = :slow.
|
63
|
+
DEFAULT_SLEEP_TIME = 0.1
|
64
|
+
|
65
|
+
# The default color for highlighting objects as they are accessed.
|
66
|
+
DEFAULT_HIGHLIGHT_COLOR = "yellow"
|
67
|
+
|
68
|
+
public
|
69
|
+
#
|
70
|
+
# Description:
|
71
|
+
# Used to access a frame element. Usually an <frame> or <iframe> HTML tag.
|
72
|
+
#
|
73
|
+
# Input:
|
74
|
+
# - how - The attribute used to identify the framet.
|
75
|
+
# - what - The value of that attribute.
|
76
|
+
# If only one parameter is supplied, "how" is by default taken as name and the
|
77
|
+
# parameter supplied becomes the value of the name attribute.
|
78
|
+
#
|
79
|
+
# Typical usage:
|
80
|
+
#
|
81
|
+
# ff.frame(:index, 1)
|
82
|
+
# ff.frame(:name , 'main_frame')
|
83
|
+
# ff.frame('main_frame') # in this case, just a name is supplied.
|
84
|
+
#
|
85
|
+
# Output:
|
86
|
+
# Frame object.
|
87
|
+
#
|
88
|
+
def frame(how, what = nil)
|
89
|
+
locate if defined?(locate)
|
90
|
+
if(what == nil)
|
91
|
+
what = how
|
92
|
+
how = :name
|
93
|
+
end
|
94
|
+
Frame.new(self, how, what)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Description:
|
99
|
+
# Used to access a form element. Usually an <form> HTML tag.
|
100
|
+
#
|
101
|
+
# Input:
|
102
|
+
# - how - The attribute used to identify the form.
|
103
|
+
# - what - The value of that attribute.
|
104
|
+
# If only one parameter is supplied, "how" is by default taken as name and the
|
105
|
+
# parameter supplied becomes the value of the name attribute.
|
106
|
+
#
|
107
|
+
# Typical usage:
|
108
|
+
#
|
109
|
+
# ff.form(:index, 1)
|
110
|
+
# ff.form(:name , 'main_form')
|
111
|
+
# ff.form('main_form') # in this case, just a name is supplied.
|
112
|
+
#
|
113
|
+
# Output:
|
114
|
+
# Form object.
|
115
|
+
#
|
116
|
+
def form(how, what=nil)
|
117
|
+
locate if defined?(locate)
|
118
|
+
if(what == nil)
|
119
|
+
what = how
|
120
|
+
how = :name
|
121
|
+
end
|
122
|
+
Form.new(self, how, what)
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# Description:
|
127
|
+
# Used to access a table. Usually an <table> HTML tag.
|
128
|
+
#
|
129
|
+
# Input:
|
130
|
+
# - how - The attribute used to identify the table.
|
131
|
+
# - what - The value of that attribute.
|
132
|
+
#
|
133
|
+
# Typical usage:
|
134
|
+
#
|
135
|
+
# ff.table(:index, 1) #index starts from 1.
|
136
|
+
# ff.table(:id, 'main_table')
|
137
|
+
#
|
138
|
+
# Output:
|
139
|
+
# Table object.
|
140
|
+
#
|
141
|
+
def table(how, what=nil)
|
142
|
+
locate if defined?(locate)
|
143
|
+
Table.new(self, how, what)
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# Description:
|
148
|
+
# Used to access a table cell. Usually an <td> HTML tag.
|
149
|
+
#
|
150
|
+
# Input:
|
151
|
+
# - how - The attribute used to identify the cell.
|
152
|
+
# - what - The value of that attribute.
|
153
|
+
#
|
154
|
+
# Typical Usage:
|
155
|
+
# ff.cell(:id, 'tb_cell')
|
156
|
+
# ff.cell(:index, 1)
|
157
|
+
#
|
158
|
+
# Output:
|
159
|
+
# TableCell Object
|
160
|
+
#
|
161
|
+
def cell(how, what=nil)
|
162
|
+
locate if defined?(locate)
|
163
|
+
TableCell.new(self, how, what)
|
164
|
+
end
|
165
|
+
|
166
|
+
#
|
167
|
+
# Description:
|
168
|
+
# Used to access a table row. Usually an <tr> HTML tag.
|
169
|
+
#
|
170
|
+
# Input:
|
171
|
+
# - how - The attribute used to identify the row.
|
172
|
+
# - what - The value of that attribute.
|
173
|
+
#
|
174
|
+
# Typical Usage:
|
175
|
+
# ff.row(:id, 'tb_row')
|
176
|
+
# ff.row(:index, 1)
|
177
|
+
#
|
178
|
+
# Output:
|
179
|
+
# TableRow object
|
180
|
+
#
|
181
|
+
def row(how, what=nil)
|
182
|
+
locate if defined?(locate)
|
183
|
+
TableRow.new(self, how, what)
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# Description:
|
188
|
+
# Used to access a button element. Usually an <input type = "button"> HTML tag.
|
189
|
+
#
|
190
|
+
# Input:
|
191
|
+
# - how - The attribute used to identify the row.
|
192
|
+
# - what - The value of that attribute.
|
193
|
+
#
|
194
|
+
# Typical Usage:
|
195
|
+
# ff.button(:id, 'b_1') # access the button with an ID of b_1
|
196
|
+
# ff.button(:name, 'verify_data') # access the button with a name of verify_data
|
197
|
+
#
|
198
|
+
# if only a single parameter is supplied, then :value is used as 'how' and parameter supplied is used as what.
|
199
|
+
#
|
200
|
+
# ff.button('Click Me') # access the button with a value of Click Me
|
201
|
+
#
|
202
|
+
# Output:
|
203
|
+
# Button element.
|
204
|
+
#
|
205
|
+
def button(how, what=nil)
|
206
|
+
locate if defined?(locate)
|
207
|
+
if what.nil? && String === how
|
208
|
+
what = how
|
209
|
+
how = :value
|
210
|
+
end
|
211
|
+
Button.new(self, how, what)
|
212
|
+
end
|
213
|
+
|
214
|
+
#
|
215
|
+
# Description:
|
216
|
+
# Used for accessing a file field. Usually an <input type = file> HTML tag.
|
217
|
+
#
|
218
|
+
# Input:
|
219
|
+
# - how - Attribute used to identify the file field element
|
220
|
+
# - what - Value of that attribute.
|
221
|
+
#
|
222
|
+
# Typical Usage:
|
223
|
+
# ff.file_field(:id, 'up_1') # access the file upload fff.d with an ID of up_1
|
224
|
+
# ff.file_field(:name, 'upload') # access the file upload fff.d with a name of upload
|
225
|
+
#
|
226
|
+
# Output:
|
227
|
+
# FileField object
|
228
|
+
#
|
229
|
+
def file_field(how, what = nil)
|
230
|
+
locate if defined?(locate)
|
231
|
+
FileField.new(self, how, what)
|
232
|
+
end
|
233
|
+
|
234
|
+
#
|
235
|
+
# Description:
|
236
|
+
# Used for accessing a text field. Usually an <input type = text> HTML tag. or a text area - a <textarea> tag
|
237
|
+
#
|
238
|
+
# Input:
|
239
|
+
# - how - Attribute used to identify the text field element.
|
240
|
+
# - what - Value of that attribute.
|
241
|
+
#
|
242
|
+
# Typical Usage:
|
243
|
+
#
|
244
|
+
# ff.text_field(:id, 'user_name') # access the text field with an ID of user_name
|
245
|
+
# ff.text_field(:name, 'address') # access the text field with a name of address
|
246
|
+
#
|
247
|
+
# Output:
|
248
|
+
# TextField object.
|
249
|
+
#
|
250
|
+
def text_field(how, what = nil)
|
251
|
+
locate if defined?(locate)
|
252
|
+
TextField.new(self, how, what)
|
253
|
+
end
|
254
|
+
|
255
|
+
#
|
256
|
+
# Description:
|
257
|
+
# Used to access hidden field element. Usually an <input type = hidden> HTML tag
|
258
|
+
#
|
259
|
+
# Input:
|
260
|
+
# - how - Attribute used to identify the hidden element.
|
261
|
+
# - what - Value of that attribute.
|
262
|
+
#
|
263
|
+
# Typical Usage:
|
264
|
+
#
|
265
|
+
# ff.hidden(:id, 'user_name') # access the hidden element with an ID of user_name
|
266
|
+
# ff.hidden(:name, 'address') # access the hidden element with a name of address
|
267
|
+
#
|
268
|
+
# Output:
|
269
|
+
# Hidden object.
|
270
|
+
#
|
271
|
+
def hidden(how, what=nil)
|
272
|
+
locate if defined?(locate)
|
273
|
+
return Hidden.new(self, how, what)
|
274
|
+
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# Description:
|
278
|
+
# Used to access select list element. Usually an <select> HTML tag.
|
279
|
+
#
|
280
|
+
# Input:
|
281
|
+
# - how - Attribute used to identify the select element.
|
282
|
+
# - what - Value of that attribute.
|
283
|
+
#
|
284
|
+
# Typical Usage:
|
285
|
+
#
|
286
|
+
# ff.select_list(:id, 'user_name') # access the select list with an ID of user_name
|
287
|
+
# ff.select_list(:name, 'address') # access the select list with a name of address
|
288
|
+
#
|
289
|
+
# Output:
|
290
|
+
# Select List object.
|
291
|
+
#
|
292
|
+
def select_list(how, what=nil)
|
293
|
+
locate if defined?(locate)
|
294
|
+
return SelectList.new(self, how, what)
|
295
|
+
end
|
296
|
+
|
297
|
+
#
|
298
|
+
# Description:
|
299
|
+
# Used to access checkbox element. Usually an <input type = checkbox> HTML tag.
|
300
|
+
#
|
301
|
+
# Input:
|
302
|
+
# - how - Attribute used to identify the check box element.
|
303
|
+
# - what - Value of that attribute.
|
304
|
+
#
|
305
|
+
# Typical Usage:
|
306
|
+
#
|
307
|
+
# ff.checkbox(:id, 'user_name') # access the checkbox element with an ID of user_name
|
308
|
+
# ff.checkbox(:name, 'address') # access the checkbox element with a name of address
|
309
|
+
# In many instances, checkboxes on an html page have the same name, but are identified by different values. An example is shown next.
|
310
|
+
#
|
311
|
+
# <input type = checkbox name = email_frequency value = 'daily' > Daily Email
|
312
|
+
# <input type = checkbox name = email_frequency value = 'Weekly'> Weekly Email
|
313
|
+
# <input type = checkbox name = email_frequency value = 'monthly'>Monthly Email
|
314
|
+
#
|
315
|
+
# FireWatir can access these using the following:
|
316
|
+
#
|
317
|
+
# ff.checkbox(:id, 'day_to_send' , 'monday' ) # access the check box with an id of day_to_send and a value of monday
|
318
|
+
# ff.checkbox(:name ,'email_frequency', 'weekly') # access the check box with a name of email_frequency and a value of 'weekly'
|
319
|
+
#
|
320
|
+
# Output:
|
321
|
+
# Checkbox object.
|
322
|
+
#
|
323
|
+
def checkbox(how, what=nil, value = nil)
|
324
|
+
locate if defined?(locate)
|
325
|
+
return CheckBox.new(self, how, what, value)
|
326
|
+
end
|
327
|
+
|
328
|
+
#
|
329
|
+
# Description:
|
330
|
+
# Used to access radio button element. Usually an <input type = radio> HTML tag.
|
331
|
+
#
|
332
|
+
# Input:
|
333
|
+
# - how - Attribute used to identify the radio button element.
|
334
|
+
# - what - Value of that attribute.
|
335
|
+
#
|
336
|
+
# Typical Usage:
|
337
|
+
#
|
338
|
+
# ff.radio(:id, 'user_name') # access the radio button element with an ID of user_name
|
339
|
+
# ff.radio(:name, 'address') # access the radio button element with a name of address
|
340
|
+
# In many instances, radio buttons on an html page have the same name, but are identified by different values. An example is shown next.
|
341
|
+
#
|
342
|
+
# <input type = radio name = email_frequency value = 'daily' > Daily Email
|
343
|
+
# <input type = radio name = email_frequency value = 'Weekly'> Weekly Email
|
344
|
+
# <input type = radio name = email_frequency value = 'monthly'>Monthly Email
|
345
|
+
#
|
346
|
+
# FireWatir can access these using the following:
|
347
|
+
#
|
348
|
+
# ff.radio(:id, 'day_to_send' , 'monday' ) # access the radio button with an id of day_to_send and a value of monday
|
349
|
+
# ff.radio(:name ,'email_frequency', 'weekly') # access the radio button with a name of email_frequency and a value of 'weekly'
|
350
|
+
#
|
351
|
+
# Output:
|
352
|
+
# Radio button object.
|
353
|
+
#
|
354
|
+
def radio(how, what=nil, value = nil)
|
355
|
+
locate if defined?(locate)
|
356
|
+
return Radio.new(self, how, what, value)
|
357
|
+
end
|
358
|
+
|
359
|
+
#
|
360
|
+
# Description:
|
361
|
+
# Used to access link element. Usually an <a> HTML tag.
|
362
|
+
#
|
363
|
+
# Input:
|
364
|
+
# - how - Attribute used to identify the link element.
|
365
|
+
# - what - Value of that attribute.
|
366
|
+
#
|
367
|
+
# Typical Usage:
|
368
|
+
#
|
369
|
+
# ff.link(:id, 'user_name') # access the link element with an ID of user_name
|
370
|
+
# ff.link(:name, 'address') # access the link element with a name of address
|
371
|
+
#
|
372
|
+
# Output:
|
373
|
+
# Link object.
|
374
|
+
#
|
375
|
+
def link(how, what=nil)
|
376
|
+
locate if defined?(locate)
|
377
|
+
return Link.new(self, how, what)
|
378
|
+
end
|
379
|
+
|
380
|
+
#
|
381
|
+
# Description:
|
382
|
+
# Used to access image element. Usually an <img> HTML tag.
|
383
|
+
#
|
384
|
+
# Input:
|
385
|
+
# - how - Attribute used to identify the image element.
|
386
|
+
# - what - Value of that attribute.
|
387
|
+
#
|
388
|
+
# Typical Usage:
|
389
|
+
#
|
390
|
+
# ff.image(:id, 'user_name') # access the image element with an ID of user_name
|
391
|
+
# ff.image(:name, 'address') # access the image element with a name of address
|
392
|
+
#
|
393
|
+
# Output:
|
394
|
+
# Image object.
|
395
|
+
#
|
396
|
+
def image(how, what = nil)
|
397
|
+
locate if defined?(locate)
|
398
|
+
Image.new(self, how, what)
|
399
|
+
end
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
# Description:
|
404
|
+
# Searching for Page Elements. Not for external consumption.
|
405
|
+
#
|
406
|
+
# def ole_inner_elements
|
407
|
+
# return document.body.all
|
408
|
+
# end
|
409
|
+
# private :ole_inner_elements
|
410
|
+
|
411
|
+
|
412
|
+
#
|
413
|
+
# Description:
|
414
|
+
# This method shows the available objects on the current page.
|
415
|
+
# This is usually only used for debugging or writing new test scripts.
|
416
|
+
# This is a nice feature to help find out what HTML objects are on a page
|
417
|
+
# when developing a test case using FireWatir.
|
418
|
+
#
|
419
|
+
# Typical Usage:
|
420
|
+
# ff.show_all_objects
|
421
|
+
#
|
422
|
+
# Output:
|
423
|
+
# Prints all the available elements on the page.
|
424
|
+
#
|
425
|
+
def show_all_objects
|
426
|
+
puts "-----------Objects in the current context-------------"
|
427
|
+
locate if defined?(locate)
|
428
|
+
elements = Document.new(self).all
|
429
|
+
puts elements.length
|
430
|
+
elements.each do |n|
|
431
|
+
puts n.tagName
|
432
|
+
puts n.to_s
|
433
|
+
puts "------------------------------------------"
|
434
|
+
end
|
435
|
+
puts "Total number of objects in the current context : #{elements.length}"
|
436
|
+
return elements
|
437
|
+
# Test the index access.
|
438
|
+
# puts doc[35].to_s
|
439
|
+
end
|
440
|
+
|
441
|
+
# evaluate javascript and return the result.
|
442
|
+
def js_eval javascript
|
443
|
+
javascript.gsub!("\n", "")
|
444
|
+
jssh_socket.send("#{javascript};\n", 0)
|
445
|
+
read_socket
|
446
|
+
end
|
447
|
+
|
448
|
+
# evaluate the provides javascript method on the current object and return
|
449
|
+
# the result
|
450
|
+
def js_eval_method method_name
|
451
|
+
js_eval("#{element_object}.#{method_name}")
|
452
|
+
end
|
453
|
+
|
454
|
+
def jssh_socket
|
455
|
+
$jssh_socket || @container.jssh_socket
|
456
|
+
end
|
457
|
+
|
458
|
+
#
|
459
|
+
# Description:
|
460
|
+
# Reads the javascript execution result from the jssh socket.
|
461
|
+
#
|
462
|
+
# Input:
|
463
|
+
# - socket - It is the jssh socket, the only point of communication between the browser and firewatir scripts.
|
464
|
+
#
|
465
|
+
# Output:
|
466
|
+
# The javascript execution result as string.
|
467
|
+
#
|
468
|
+
def read_socket(socket = jssh_socket)
|
469
|
+
return_value = ""
|
470
|
+
data = ""
|
471
|
+
receive = true
|
472
|
+
#puts Thread.list
|
473
|
+
s = nil
|
474
|
+
while(s == nil) do
|
475
|
+
s = Kernel.select([socket] , nil , nil, 1)
|
476
|
+
end
|
477
|
+
#if(s != nil)
|
478
|
+
for stream in s[0]
|
479
|
+
data = stream.recv(1024)
|
480
|
+
#puts "data is : #{data}"
|
481
|
+
while(receive)
|
482
|
+
#while(data.length == 1024)
|
483
|
+
return_value += data
|
484
|
+
if(return_value.include?("\n> "))
|
485
|
+
receive = false
|
486
|
+
else
|
487
|
+
data = stream.recv(1024)
|
488
|
+
end
|
489
|
+
#puts "return_value is : #{return_value}"
|
490
|
+
#puts "data length is : #{data.length}"
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
# If received data is less than 1024 characters or for last data
|
495
|
+
# we read in the above loop
|
496
|
+
#return_value += data
|
497
|
+
|
498
|
+
# Get the command prompt inserted by JSSH
|
499
|
+
#s = Kernel.select([socket] , nil , nil, 0.3)
|
500
|
+
|
501
|
+
#if(s != nil)
|
502
|
+
# for stream in s[0]
|
503
|
+
# return_value += socket.recv(1024)
|
504
|
+
# end
|
505
|
+
#end
|
506
|
+
|
507
|
+
length = return_value.length
|
508
|
+
#puts "Return value before removing command prompt is : #{return_value}"
|
509
|
+
|
510
|
+
#Remove the command prompt. Every result returned by JSSH has "\n> " at the end.
|
511
|
+
if length <= 3
|
512
|
+
return_value = ""
|
513
|
+
elsif(return_value[0..2] == "\n> ")
|
514
|
+
return_value = return_value[3..length-1]
|
515
|
+
else
|
516
|
+
#return_value = return_value[0..length-3]
|
517
|
+
return_value = return_value[0..length-4]
|
518
|
+
end
|
519
|
+
#puts "Return value after removing command prompt is : #{return_value}"
|
520
|
+
#socket.flush
|
521
|
+
|
522
|
+
# make sure that command prompt doesn't get there.
|
523
|
+
if(return_value[return_value.length - 3..return_value.length - 1] == "\n> ")
|
524
|
+
return_value = return_value[0..return_value.length - 4]
|
525
|
+
end
|
526
|
+
if(return_value[0..2] == "\n> ")
|
527
|
+
return_value = return_value[3..return_value.length - 1]
|
528
|
+
end
|
529
|
+
#puts "return value is : #{return_value}"
|
530
|
+
return return_value
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end # module
|
534
|
+
|