qfunction 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/function/HTMLElement.rb +501 -393
- data/lib/function/sfunction.rb +12 -15
- data/lib/qfunction.rb +0 -1
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/function/HTMLElement.rb
CHANGED
@@ -1,419 +1,527 @@
|
|
1
1
|
#B: HTML
|
2
2
|
module Qh
|
3
|
-
#Goto url
|
4
|
-
def goto(url)
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
#Refresh
|
9
|
-
def refresh
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def xxx
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
#Link
|
18
|
-
def clickLinktext(text)
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def clickLinkid(text)
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def clickLinkhref(name)
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def clickLinktitle(text)
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def clickLinkclass(text)
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
#Button
|
44
|
-
def clickButtonid(text)
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def clickButtonname(text)
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
#text2 = String,<br>
|
98
|
-
#type = 1: set(d),<br>
|
99
|
-
#type = 2:value,<br>
|
100
|
-
#type = 3:append<br>
|
101
|
-
def setTextfieldclass(text1,text2,type=1)
|
102
|
-
|
103
|
-
waitExists($ff.text_field(:class,text1))
|
104
|
-
if type == 1 then
|
105
|
-
$ff.text_field(:class,text1).set(text2)
|
106
|
-
elsif type == 2 then
|
107
|
-
$ff.text_field(:class,text1).value = text2
|
108
|
-
else $ff.text_field(:class,text1).append(text2)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def verifyTextfieldid(text1,text2)
|
113
|
-
waitExists( $ff.text_field(:id,text1) )
|
114
|
-
assert($ff.text_field(:id, text1).verify_contains(text2) )
|
115
|
-
end
|
116
|
-
|
117
|
-
def verifyTextfieldname(text1,text2)
|
118
|
-
waitExists( $ff.text_field(:name,text1) )
|
119
|
-
assert($ff.text_field(:name, text1).verify_contains(text2) )
|
120
|
-
end
|
121
|
-
|
122
|
-
#Filefield
|
123
|
-
def setfilefieldid(text1,text2)
|
124
|
-
waitExists($ff.file_field(:id,text1))
|
125
|
-
$ff.file_field(:id,text1).set(text2)
|
126
|
-
end
|
127
|
-
|
128
|
-
def setfilefieldname(text1,text2)
|
129
|
-
waitExists($ff.file_field(:name,text1))
|
130
|
-
$ff.file_field(:name,text1).set(text2)
|
131
|
-
end
|
132
|
-
|
133
|
-
#Form
|
134
|
-
def submitFormid(text)
|
135
|
-
waitExists($ff.form(:id,text))
|
136
|
-
$ff.form(:id,text).submit
|
137
|
-
end
|
138
|
-
|
139
|
-
def getFormid(text)
|
140
|
-
waitExists($ff.form(:id,text))
|
141
|
-
return $ff.form(:id,text)
|
142
|
-
end
|
143
|
-
|
144
|
-
def getFormaction(text)
|
145
|
-
waitExists($ff.form(:action,text))
|
146
|
-
nwait(1)
|
147
|
-
sleep(1)
|
148
|
-
return $ff.form(:action,text)
|
149
|
-
end
|
150
|
-
|
151
|
-
#Frame
|
152
|
-
def getFrameid(text)
|
153
|
-
waitExists($ff.frame(:id,text))
|
154
|
-
return $ff.frame(:id,text)
|
155
|
-
end
|
156
|
-
|
157
|
-
def getFrameindex(text)
|
158
|
-
waitExists($ff.frame(:index,text))
|
159
|
-
return $ff.frame(:index,text)
|
160
|
-
end
|
161
|
-
|
162
|
-
def getFramesrc(text)
|
163
|
-
waitExists($ff.frame(:src,text))
|
164
|
-
return $ff.frame(:src,text)
|
165
|
-
end
|
166
|
-
|
167
|
-
#Table
|
168
|
-
def getTableid(text)
|
169
|
-
waitExists( $ff.table(:id,text) )
|
170
|
-
sleep(1)
|
171
|
-
return $ff.table(:id,text)
|
172
|
-
end
|
173
|
-
|
174
|
-
#Div
|
175
|
-
def getDivclass(text)
|
176
|
-
waitExists( $ff.div(:class,text) )
|
177
|
-
nwait(1)
|
178
|
-
return $ff.div(:class,text)
|
179
|
-
end
|
180
|
-
|
181
|
-
def getDivid(text)
|
182
|
-
waitExists( $ff.div(:id,text) )
|
183
|
-
nwait(2)
|
184
|
-
return $ff.div(:id,text)
|
185
|
-
end
|
186
|
-
|
187
|
-
def clickDivid(text)
|
188
|
-
i = 0
|
189
|
-
begin
|
190
|
-
$ff.div(:id , text).click
|
191
|
-
rescue Exception => e
|
192
|
-
sleep(1)
|
193
|
-
i = i + 1
|
194
|
-
if i < $timeout then retry
|
195
|
-
else
|
196
|
-
puts e.exception
|
197
|
-
#~ puts e.backtrace
|
3
|
+
#Goto url
|
4
|
+
def goto(url)
|
5
|
+
$ff.goto(url)
|
6
|
+
end
|
7
|
+
|
8
|
+
#Refresh
|
9
|
+
def refresh
|
10
|
+
$ff.refresh
|
11
|
+
end
|
12
|
+
|
13
|
+
def xxx
|
14
|
+
$ff.close
|
15
|
+
end
|
16
|
+
|
17
|
+
#Link
|
18
|
+
def clickLinktext(text)
|
19
|
+
waitExists($ff.link(:text,text))
|
20
|
+
$ff.link(:text,text).click
|
21
|
+
end
|
22
|
+
|
23
|
+
def clickLinkid(text)
|
24
|
+
waitExists($ff.link(:id,text))
|
25
|
+
$ff.link(:id,text).click
|
26
|
+
end
|
27
|
+
|
28
|
+
def clickLinkhref(name)
|
29
|
+
waitExists($ff.link(:href,name))
|
30
|
+
$ff.link(:href,name).click
|
31
|
+
end
|
32
|
+
|
33
|
+
def clickLinktitle(text)
|
34
|
+
waitExists($ff.link(:title,text))
|
35
|
+
$ff.link(:title,text).click
|
36
|
+
end
|
37
|
+
|
38
|
+
def clickLinkclass(text)
|
39
|
+
waitExists($ff.link(:class,text))
|
40
|
+
$ff.link(:class,text).click
|
41
|
+
end
|
42
|
+
|
43
|
+
#Button
|
44
|
+
def clickButtonid(text)
|
45
|
+
waitExists($ff.button(:id,text))
|
46
|
+
$ff.button(:id,text).click
|
47
|
+
end
|
48
|
+
|
49
|
+
def clickButtonname(text)
|
50
|
+
waitExists($ff.button(:name,text))
|
51
|
+
$ff.button(:name,text).click
|
52
|
+
end
|
53
|
+
|
54
|
+
def clickButtonvalue(text) #0.0.7
|
55
|
+
waitExists($ff.button(:value,text))
|
56
|
+
$ff.button(:value,text).click
|
57
|
+
end
|
58
|
+
|
59
|
+
#Image
|
60
|
+
def clickImagesrc(text)
|
61
|
+
waitExists($ff.image(:src,text))
|
62
|
+
$ff.image(:src,text).click
|
63
|
+
end
|
64
|
+
|
65
|
+
#Textfield
|
66
|
+
#Set TextField "ID"<br>
|
67
|
+
#type = 1: set(d)<br>
|
68
|
+
#type = 2:value<br>
|
69
|
+
#type = 3:append<br>
|
70
|
+
#type = 4:focus<br>
|
71
|
+
def setTextfieldid(text1,text2,type=1)
|
72
|
+
waitExists($ff.text_field(:id,text1))
|
73
|
+
if type == 1 then
|
74
|
+
$ff.text_field(:id,text1).set(text2)
|
75
|
+
elsif type == 2 then
|
76
|
+
$ff.text_field(:id,text1).value = text2
|
77
|
+
elsif type == 3 then
|
78
|
+
$ff.text_field(:id,text1).append(text2)
|
79
|
+
elsif type == 4 then
|
80
|
+
$ff.text_field(:id,text1).focus
|
81
|
+
end
|
82
|
+
end
|
83
|
+
#Set TextField (Name),<br>
|
84
|
+
#text1 = name,<br>
|
85
|
+
#text2 = String,<br>
|
86
|
+
#type = 1: set(d),<br>
|
87
|
+
#type = 2:value,<br>
|
88
|
+
#type = 3:append<br>
|
89
|
+
def setTextfieldname(text1,text2,type=1)
|
90
|
+
|
91
|
+
waitExists($ff.text_field(:name,text1))
|
92
|
+
if type == 1 then
|
93
|
+
$ff.text_field(:name,text1).set(text2)
|
94
|
+
elsif type == 2 then
|
95
|
+
$ff.text_field(:name,text1).value = text2
|
96
|
+
else $ff.text_field(:name,text1).append(text2)
|
198
97
|
end
|
199
98
|
end
|
200
|
-
end
|
201
99
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
100
|
+
#Set TextField (Class),<br>
|
101
|
+
#text1 = name,<br>
|
102
|
+
#text2 = String,<br>
|
103
|
+
#type = 1: set(d),<br>
|
104
|
+
#type = 2:value,<br>
|
105
|
+
#type = 3:append<br>
|
106
|
+
def setTextfieldclass(text1,text2,type=1)
|
107
|
+
|
108
|
+
waitExists($ff.text_field(:class,text1))
|
109
|
+
if type == 1 then
|
110
|
+
$ff.text_field(:class,text1).set(text2)
|
111
|
+
elsif type == 2 then
|
112
|
+
$ff.text_field(:class,text1).value = text2
|
113
|
+
else $ff.text_field(:class,text1).append(text2)
|
214
114
|
end
|
215
115
|
end
|
216
|
-
end
|
217
116
|
|
218
|
-
def
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
117
|
+
def verifyTextfieldid(text1,text2)
|
118
|
+
waitExists( $ff.text_field(:id,text1) )
|
119
|
+
assert($ff.text_field(:id, text1).verify_contains(text2) )
|
120
|
+
end
|
121
|
+
|
122
|
+
def verifyTextfieldname(text1,text2)
|
123
|
+
waitExists( $ff.text_field(:name,text1) )
|
124
|
+
assert($ff.text_field(:name, text1).verify_contains(text2) )
|
125
|
+
end
|
126
|
+
|
127
|
+
#Filefield
|
128
|
+
def setfilefieldid(text1,text2)
|
129
|
+
waitExists($ff.file_field(:id,text1))
|
130
|
+
$ff.file_field(:id,text1).set(text2)
|
131
|
+
end
|
132
|
+
|
133
|
+
def setfilefieldname(text1,text2)
|
134
|
+
waitExists($ff.file_field(:name,text1))
|
135
|
+
$ff.file_field(:name,text1).set(text2)
|
136
|
+
end
|
137
|
+
|
138
|
+
#Form
|
139
|
+
def submitFormid(text)
|
140
|
+
waitExists($ff.form(:id,text))
|
141
|
+
$ff.form(:id,text).submit
|
142
|
+
end
|
143
|
+
|
144
|
+
def getFormid(text)
|
145
|
+
waitExists($ff.form(:id,text))
|
146
|
+
return $ff.form(:id,text)
|
147
|
+
end
|
148
|
+
|
149
|
+
def getFormaction(text)
|
150
|
+
waitExists($ff.form(:action,text))
|
151
|
+
nwait(1)
|
223
152
|
sleep(1)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
153
|
+
return $ff.form(:action,text)
|
154
|
+
end
|
155
|
+
|
156
|
+
#Frame
|
157
|
+
def getFrameid(text)
|
158
|
+
waitExists($ff.frame(:id,text))
|
159
|
+
return $ff.frame(:id,text)
|
160
|
+
end
|
161
|
+
|
162
|
+
def getFrameindex(text)
|
163
|
+
waitExists($ff.frame(:index,text))
|
164
|
+
return $ff.frame(:index,text)
|
165
|
+
end
|
166
|
+
|
167
|
+
def getFramesrc(text)
|
168
|
+
waitExists($ff.frame(:src,text))
|
169
|
+
return $ff.frame(:src,text)
|
170
|
+
end
|
171
|
+
|
172
|
+
def setFTextfieldid(fr,text)
|
173
|
+
i = 0
|
174
|
+
while !$ff.frame(:id,fr).text_field(:id,text).exists? do
|
175
|
+
sleep(1)
|
176
|
+
i +=1
|
177
|
+
if i>=$timeout then
|
178
|
+
assert( $ff.frame(:id,fr).text_field(:id,text).exists? )
|
179
|
+
break;
|
180
|
+
end
|
229
181
|
end
|
230
182
|
end
|
231
|
-
end
|
232
183
|
|
233
|
-
def
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
puts e.exception
|
243
|
-
#~ puts e.backtrace
|
184
|
+
def waitFLink(fr,text,typeF,typeL = "text") #0.0.7
|
185
|
+
i = 0
|
186
|
+
frame = getFrameid("#{fr}")
|
187
|
+
while !$ff.frame(:"#{typeF}",fr).link(:"#{typeL}",text).exists? do
|
188
|
+
sleep(1)
|
189
|
+
i +=1
|
190
|
+
if i>=$timeout then
|
191
|
+
assert( $ff.frame(:"#{typeF}",fr).link(:"#{typeL}",text).exists? )
|
192
|
+
end
|
244
193
|
end
|
245
194
|
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
def
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
def getSelectlistid(text)
|
282
|
-
waitExists($ff.select_list(:id,text))
|
283
|
-
nwait(1)
|
284
|
-
return $ff.select_list(:id,text)
|
285
|
-
end
|
286
|
-
|
287
|
-
#Radio
|
288
|
-
def setRadiovalue(value)
|
289
|
-
waitExists($ff.radio(:value,value))
|
290
|
-
$ff.radio(:value,value).set
|
291
|
-
end
|
292
|
-
|
293
|
-
def setRadioid(id)
|
294
|
-
waitExists($ff.radio(:id,id))
|
295
|
-
$ff.radio(:id,id).set
|
296
|
-
end
|
297
|
-
#Alert
|
298
|
-
def clickalertLinktext(name)
|
299
|
-
waitExists($ff.link(:text,name))
|
300
|
-
$ff.startClicker("OK")
|
301
|
-
$ff.link(:text,name).click
|
302
|
-
end
|
303
|
-
|
304
|
-
def clickalertLinkid(name)
|
305
|
-
waitExists($ff.link(:id,name))
|
306
|
-
$ff.startClicker("OK")
|
307
|
-
$ff.link(:id,name).click
|
308
|
-
end
|
309
|
-
|
310
|
-
def clickalertLinktitle(name)
|
311
|
-
waitExists($ff.link(:title,name))
|
312
|
-
$ff.startClicker("OK")
|
313
|
-
$ff.link(:title,name).click
|
314
|
-
end
|
315
|
-
|
316
|
-
def clickalertLinkclass(name)
|
317
|
-
waitExists($ff.link(:class,name))
|
318
|
-
$ff.startClicker("OK")
|
319
|
-
$ff.link(:class,name).click
|
320
|
-
end
|
321
|
-
|
322
|
-
def clickalertButtonid(name)
|
323
|
-
waitExists($ff.button(:id,name))
|
324
|
-
$ff.startClicker("OK")
|
325
|
-
$ff.button(:id,name).click
|
326
|
-
end
|
327
|
-
|
328
|
-
def clickalertButtonname(name)
|
329
|
-
waitExists($ff.button(:name,name))
|
330
|
-
$ff.startClicker("OK")
|
331
|
-
$ff.button(:name,name).click
|
332
|
-
end
|
333
|
-
|
334
|
-
def clickalertElement(name)
|
335
|
-
waitExists(name)
|
336
|
-
$ff.startClicker("OK")
|
337
|
-
name.click
|
338
|
-
end
|
339
|
-
|
340
|
-
def clickalertImagesrc(text)
|
341
|
-
waitExists( $ff.image(:src,text) )
|
342
|
-
$ff.startClicker("OK")
|
343
|
-
$ff.image(:src,text).click
|
344
|
-
sleep(2)
|
345
|
-
end
|
346
|
-
|
347
|
-
def clickalertImageid(text)
|
348
|
-
waitExists( $ff.image(:id,text) )
|
349
|
-
$ff.startClicker("OK")
|
350
|
-
$ff.image(:id,text).click
|
351
|
-
sleep(2)
|
352
|
-
end
|
353
|
-
|
354
|
-
def click_javascript_button()
|
355
|
-
path = File.join(File.dirname(__FILE__), "javascriptPopup.rb")
|
356
|
-
Thread.new { system("ruby \"#{path}\"") }
|
357
|
-
yield
|
358
|
-
sleep(3)
|
359
|
-
end
|
360
|
-
|
361
|
-
#E: Alert
|
362
|
-
|
363
|
-
def nwait(n=1)
|
364
|
-
for i in 1..n
|
365
|
-
$ff.wait
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
#Attach
|
370
|
-
def getAttachurl(url)
|
371
|
-
i = 0
|
372
|
-
begin
|
373
|
-
ff1 = $ff.attach(:url,url)
|
374
|
-
rescue Exception => e
|
375
|
-
sleep(1)
|
376
|
-
i = i + 1
|
377
|
-
if i <= $timeout then retry
|
378
|
-
else
|
379
|
-
puts e.exception
|
380
|
-
#~ puts e.backtrace
|
195
|
+
|
196
|
+
def waitFTextfield(fr,text,typeF,typeT = "id") #0.0.7
|
197
|
+
i = 0
|
198
|
+
frame = getFrameid("#{fr}")
|
199
|
+
while !$ff.frame(:"#{typeF}",fr).text_field(:"#{typeT}",text).exists? do
|
200
|
+
sleep(1)
|
201
|
+
i +=1
|
202
|
+
if i>=$timeout then
|
203
|
+
assert( $ff.frame(:"#{typeF}",fr).text_field(:"#{typeT}",text).exists? )
|
204
|
+
end
|
205
|
+
puts i
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def waitFFilefied(fr,text,typeF,typeT = "id") #0.0.7
|
210
|
+
i = 0
|
211
|
+
frame = getFrameid("#{fr}")
|
212
|
+
while !$ff.frame(:"#{typeF}",fr).file_field(:"#{typeT}",text).exists? do
|
213
|
+
sleep(1)
|
214
|
+
i +=1
|
215
|
+
if i>=$timeout then
|
216
|
+
assert( $ff.frame(:"#{typeF}",fr).file_field(:"#{typeT}",text).exists? )
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def waitFSpan(fr,text,typeF,typeS = "id") #0.0.7
|
222
|
+
i = 0
|
223
|
+
frame = getFrameid("#{fr}")
|
224
|
+
while !$ff.frame(:"#{typeF}",fr).span(:"#{typeS}",text).exists? do
|
225
|
+
sleep(1)
|
226
|
+
i +=1
|
227
|
+
if i>=$timeout then
|
228
|
+
assert( $ff.frame(:"#{typeF}",fr).span(:"#{typeS}",text).exists? )
|
229
|
+
end
|
381
230
|
end
|
382
231
|
end
|
383
|
-
|
384
|
-
|
232
|
+
|
233
|
+
def waitFButton(fr,text,typeF,typeB = "id") #0.0.7
|
234
|
+
i = 0
|
235
|
+
frame = getFrameid("#{fr}")
|
236
|
+
while !$ff.frame(:"#{typeF}",fr).button(:"#{typeB}",text).exists? do
|
237
|
+
sleep(1)
|
238
|
+
i +=1
|
239
|
+
if i>=$timeout then
|
240
|
+
assert( $ff.frame(:"#{typeF}",fr).button(:"#{typeB}",text).exists? )
|
241
|
+
end
|
242
|
+
end
|
385
243
|
end
|
386
|
-
end
|
387
244
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
ff1 = $ff.attach(:title,title)
|
392
|
-
rescue Exception => e
|
245
|
+
#Table
|
246
|
+
def getTableid(text)
|
247
|
+
waitExists( $ff.table(:id,text) )
|
393
248
|
sleep(1)
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
249
|
+
return $ff.table(:id,text)
|
250
|
+
end
|
251
|
+
|
252
|
+
#Div
|
253
|
+
def getDivclass(text)
|
254
|
+
waitExists( $ff.div(:class,text) )
|
255
|
+
nwait(1)
|
256
|
+
return $ff.div(:class,text)
|
257
|
+
end
|
258
|
+
|
259
|
+
def getDivid(text)
|
260
|
+
waitExists( $ff.div(:id,text) )
|
261
|
+
nwait(2)
|
262
|
+
return $ff.div(:id,text)
|
263
|
+
end
|
264
|
+
|
265
|
+
def clickDivid(text)
|
266
|
+
i = 0
|
267
|
+
begin
|
268
|
+
$ff.div(:id , text).click
|
269
|
+
rescue Exception => e
|
270
|
+
sleep(1)
|
271
|
+
i = i + 1
|
272
|
+
if i < $timeout then retry
|
273
|
+
else
|
274
|
+
puts e.exception
|
275
|
+
#~ puts e.backtrace
|
276
|
+
end
|
399
277
|
end
|
400
278
|
end
|
401
|
-
|
402
|
-
|
279
|
+
|
280
|
+
def clickDivtext(text) #0.0.7
|
281
|
+
i = 0
|
282
|
+
begin
|
283
|
+
$ff.div(:text , text).click
|
284
|
+
rescue Exception => e
|
285
|
+
sleep(1)
|
286
|
+
i = i + 1
|
287
|
+
if i < $timeout then retry
|
288
|
+
else
|
289
|
+
puts e.exception
|
290
|
+
#~ puts e.backtrace
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
#Span
|
296
|
+
def clickSpanid(text)
|
297
|
+
i = 0
|
298
|
+
begin
|
299
|
+
$ff.span(:id , text).click
|
300
|
+
rescue Exception => e
|
301
|
+
sleep(1)
|
302
|
+
i = i + 1
|
303
|
+
if i < $timeout then retry
|
304
|
+
else
|
305
|
+
puts e.exception
|
306
|
+
#~ puts e.backtrace
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def clickSpantext(text) #0.0.7
|
312
|
+
i = 0
|
313
|
+
begin
|
314
|
+
$ff.span(:text , text).click
|
315
|
+
rescue Exception => e
|
316
|
+
sleep(1)
|
317
|
+
i = i + 1
|
318
|
+
if i < $timeout then retry
|
319
|
+
else
|
320
|
+
puts e.exception
|
321
|
+
#~ puts e.backtrace
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def clickSpanclass(text)
|
327
|
+
i = 0
|
328
|
+
begin
|
329
|
+
$ff.span(:class , text).click
|
330
|
+
rescue Exception => e
|
331
|
+
sleep(1)
|
332
|
+
i = i + 1
|
333
|
+
if i < $timeout then retry
|
334
|
+
else
|
335
|
+
puts e.exception
|
336
|
+
#~ puts e.backtrace
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def clickSpanxpath(text)
|
342
|
+
i = 0
|
343
|
+
begin
|
344
|
+
$ff.span(:xpath , text).click
|
345
|
+
rescue Exception => e
|
346
|
+
sleep(1)
|
347
|
+
i = i + 1
|
348
|
+
if i < $timeout then retry
|
349
|
+
else
|
350
|
+
puts e.exception
|
351
|
+
#~ puts e.backtrace
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
#Checkbox
|
357
|
+
def setCheckboxid(name)
|
358
|
+
waitExists($ff.checkbox(:id,name))
|
359
|
+
$ff.checkbox(:id,name).set
|
360
|
+
end
|
361
|
+
|
362
|
+
def setCheckboxname(name)
|
363
|
+
waitExists($ff.checkbox(:name,name))
|
364
|
+
$ff.checkbox(:name,name).set
|
365
|
+
end
|
366
|
+
|
367
|
+
def setCheckboxvalue(name)
|
368
|
+
waitExists($ff.checkbox(:value,name))
|
369
|
+
$ff.checkbox(:value,name).set
|
370
|
+
end
|
371
|
+
|
372
|
+
def clearCheckboxid(name)
|
373
|
+
waitExists($ff.checkbox(:id,name))
|
374
|
+
$ff.checkbox(:id,name).clear
|
375
|
+
end
|
376
|
+
|
377
|
+
#Select_list:<br>
|
378
|
+
#type = 1: text(d),<br>
|
379
|
+
#type = 2: value,<br>
|
380
|
+
def setSelectlistid(name,value,type=1)
|
381
|
+
waitExists($ff.select_list(:id,name))
|
382
|
+
if type == 1 then
|
383
|
+
$ff.select_list(:id,name).select(value)
|
384
|
+
elsif type == 2 then
|
385
|
+
$ff.select_list(:id,name).select_value(value)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
def getSelectlistid(text)
|
390
|
+
waitExists($ff.select_list(:id,text))
|
391
|
+
nwait(1)
|
392
|
+
return $ff.select_list(:id,text)
|
393
|
+
end
|
394
|
+
|
395
|
+
#Radio
|
396
|
+
def setRadiovalue(value)
|
397
|
+
waitExists($ff.radio(:value,value))
|
398
|
+
$ff.radio(:value,value).set
|
399
|
+
end
|
400
|
+
|
401
|
+
def setRadioid(id)
|
402
|
+
waitExists($ff.radio(:id,id))
|
403
|
+
$ff.radio(:id,id).set
|
404
|
+
end
|
405
|
+
#Alert
|
406
|
+
def clickalertLinktext(name)
|
407
|
+
waitExists($ff.link(:text,name))
|
408
|
+
$ff.startClicker("OK")
|
409
|
+
$ff.link(:text,name).click
|
403
410
|
end
|
404
|
-
end
|
405
411
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
if type == 1 then
|
411
|
-
element.fire_event("onMouseOver")
|
412
|
+
def clickalertLinkid(name)
|
413
|
+
waitExists($ff.link(:id,name))
|
414
|
+
$ff.startClicker("OK")
|
415
|
+
$ff.link(:id,name).click
|
412
416
|
end
|
413
|
-
end
|
414
417
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
418
|
+
def clickalertLinktitle(name)
|
419
|
+
waitExists($ff.link(:title,name))
|
420
|
+
$ff.startClicker("OK")
|
421
|
+
$ff.link(:title,name).click
|
422
|
+
end
|
423
|
+
|
424
|
+
def clickalertLinkclass(name)
|
425
|
+
waitExists($ff.link(:class,name))
|
426
|
+
$ff.startClicker("OK")
|
427
|
+
$ff.link(:class,name).click
|
428
|
+
end
|
429
|
+
|
430
|
+
def clickalertButtonid(name)
|
431
|
+
waitExists($ff.button(:id,name))
|
432
|
+
$ff.startClicker("OK")
|
433
|
+
$ff.button(:id,name).click
|
434
|
+
end
|
435
|
+
|
436
|
+
def clickalertButtonname(name)
|
437
|
+
waitExists($ff.button(:name,name))
|
438
|
+
$ff.startClicker("OK")
|
439
|
+
$ff.button(:name,name).click
|
440
|
+
end
|
441
|
+
|
442
|
+
def clickalertElement(name)
|
443
|
+
waitExists(name)
|
444
|
+
$ff.startClicker("OK")
|
445
|
+
name.click
|
446
|
+
end
|
447
|
+
|
448
|
+
def clickalertImagesrc(text)
|
449
|
+
waitExists( $ff.image(:src,text) )
|
450
|
+
$ff.startClicker("OK")
|
451
|
+
$ff.image(:src,text).click
|
452
|
+
sleep(2)
|
453
|
+
end
|
454
|
+
|
455
|
+
def clickalertImageid(text)
|
456
|
+
waitExists( $ff.image(:id,text) )
|
457
|
+
$ff.startClicker("OK")
|
458
|
+
$ff.image(:id,text).click
|
459
|
+
sleep(2)
|
460
|
+
end
|
461
|
+
|
462
|
+
def click_javascript_button()
|
463
|
+
path = File.join(File.dirname(__FILE__), "javascriptPopup.rb")
|
464
|
+
Thread.new { system("ruby \"#{path}\"") }
|
465
|
+
yield
|
466
|
+
sleep(3)
|
467
|
+
end
|
468
|
+
|
469
|
+
#E: Alert
|
470
|
+
|
471
|
+
def nwait(n=1)
|
472
|
+
for i in 1..n
|
473
|
+
$ff.wait
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
#Attach
|
478
|
+
def getAttachurl(url)
|
479
|
+
i = 0
|
480
|
+
begin
|
481
|
+
ff1 = $ff.attach(:url,url)
|
482
|
+
rescue Exception => e
|
483
|
+
sleep(1)
|
484
|
+
i = i + 1
|
485
|
+
if i <= $timeout then retry
|
486
|
+
else
|
487
|
+
puts e.exception
|
488
|
+
#~ puts e.backtrace
|
489
|
+
end
|
490
|
+
end
|
491
|
+
if i <= $timeout then
|
492
|
+
return ff1
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
def getAttachtitle(title)
|
497
|
+
i = 0
|
498
|
+
begin
|
499
|
+
ff1 = $ff.attach(:title,title)
|
500
|
+
rescue Exception => e
|
501
|
+
sleep(1)
|
502
|
+
i = i + 1
|
503
|
+
if i <= 20 then retry
|
504
|
+
else
|
505
|
+
puts e.exception
|
506
|
+
#~ puts e.backtrace
|
507
|
+
end
|
508
|
+
end
|
509
|
+
if i <= 20 then
|
510
|
+
return ff1
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
#Javascript event:<br>
|
515
|
+
#type = 1: onMouseOver(d)
|
516
|
+
def fire_event(element,type = 1)
|
517
|
+
waitExists(element)
|
518
|
+
if type == 1 then
|
519
|
+
element.fire_event("onMouseOver")
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
#Wait Element show use class Waiter
|
524
|
+
def wait_ut(text)
|
525
|
+
Watir::Waiter.wait_until($timeout) { text }
|
526
|
+
end
|
419
527
|
end
|
data/lib/function/sfunction.rb
CHANGED
@@ -89,17 +89,17 @@ module Qs
|
|
89
89
|
return x
|
90
90
|
end
|
91
91
|
|
92
|
-
def cutEndline(text)
|
93
|
-
if
|
94
|
-
|
95
|
-
|
92
|
+
def cutEndline(text) #0.0.7
|
93
|
+
if RUBY_VERSION <= '1.8.6' then
|
94
|
+
if text[text.length - 1] < 32 or text[text.length] > 126 then
|
95
|
+
return text[0,text.length - 2]
|
96
|
+
else return text[0,text.length - 1]
|
96
97
|
end
|
97
|
-
return abc
|
98
98
|
else
|
99
|
-
|
100
|
-
|
99
|
+
if text[text.length - 1] < ' ' or text[text.length] > '~' then
|
100
|
+
return text[0,text.length - 2]
|
101
|
+
else return text[0,text.length - 1]
|
101
102
|
end
|
102
|
-
return abc
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -118,17 +118,14 @@ module Qs
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def getFile(name)
|
121
|
-
|
122
|
-
|
123
|
-
return true
|
124
|
-
rescue
|
125
|
-
return false
|
121
|
+
if File.exist?(name) then return true
|
122
|
+
else return false
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
|
-
def getPathExe(default_dir
|
126
|
+
def getPathExe(default_dir)
|
130
127
|
if ENV['OCRA_EXECUTABLE'].nil?
|
131
|
-
root_dir = default_dir
|
128
|
+
root_dir = File.dirname(default_dir).gsub('/', '\\') #0.0.7
|
132
129
|
else
|
133
130
|
root_dir = File.expand_path(File.dirname(ENV['OCRA_EXECUTABLE'])).gsub('/', '\\')
|
134
131
|
end
|
data/lib/qfunction.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- QuangMV, Cyworld VietNam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Ha Noi, VietNam
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-11 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|