qfunction 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/function/assertions.rb +338 -232
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/function/assertions.rb
CHANGED
@@ -1,297 +1,403 @@
|
|
1
1
|
#E: Assert
|
2
2
|
#Assertion text in page
|
3
3
|
module Qa
|
4
|
-
def assertText(text,waittime = $timeout) #0.0.6
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# break;
|
4
|
+
def assertText(text,waittime = $timeout) #0.0.6
|
5
|
+
i = 0
|
6
|
+
while !$ff.contains_text(text) do
|
7
|
+
sleep(1)
|
8
|
+
if i>=waittime then
|
9
|
+
assert($ff.contains_text(text))
|
10
|
+
# break;
|
11
|
+
end
|
12
|
+
i=i+1
|
11
13
|
end
|
12
|
-
i=i+1
|
13
14
|
end
|
14
|
-
end
|
15
15
|
|
16
|
-
#Assert False text in page
|
17
|
-
def assertfalseText(text)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
#Assert False text in page
|
17
|
+
def assertfalseText(text)
|
18
|
+
i = 0
|
19
|
+
while $ff.contains_text(text) do
|
20
|
+
sleep(1)
|
21
|
+
if i>=$timeout then
|
22
|
+
assert_false($ff.contains_text(text))
|
23
|
+
break;
|
24
|
+
end
|
25
|
+
i=i+1
|
24
26
|
end
|
25
|
-
i=i+1
|
26
27
|
end
|
27
|
-
end
|
28
28
|
|
29
|
-
#Assert Equal<br>
|
30
|
-
#type = 1:text(default)<br>
|
31
|
-
#type = 2:title<br>
|
32
|
-
#type = 3:url<br>
|
33
|
-
#type = 4:value<br>
|
34
|
-
#type = 5:maxlength<br>
|
35
|
-
def assertEqual(value1,value2,type=1) #0.0.8
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
29
|
+
#Assert Equal<br>
|
30
|
+
#type = 1:text(default)<br>
|
31
|
+
#type = 2:title<br>
|
32
|
+
#type = 3:url<br>
|
33
|
+
#type = 4:value<br>
|
34
|
+
#type = 5:maxlength<br>
|
35
|
+
def assertEqual(value1,value2,type=1) #0.0.8
|
36
|
+
i = 0
|
37
|
+
if type == 1 then
|
38
|
+
begin
|
39
|
+
assert_equal(value1, value2.text)
|
40
|
+
rescue Exception => e
|
41
|
+
sleep(1)
|
42
|
+
i += 1
|
43
|
+
if i < $timeout then retry
|
44
|
+
end
|
45
|
+
assert_equal(value1, value2.text)
|
46
|
+
end
|
47
|
+
elsif type == 2 then
|
48
|
+
begin
|
49
|
+
assert_equal(value1, value2.title)
|
50
|
+
rescue
|
51
|
+
sleep(1)
|
52
|
+
i += 1
|
53
|
+
if i <= $timeout+1 then retry
|
54
|
+
end
|
55
|
+
assert_equal(value1, value2.title)
|
56
|
+
end
|
57
|
+
elsif type == 3 then
|
58
|
+
begin
|
59
|
+
assert_equal(value1, value2.url)
|
60
|
+
rescue
|
61
|
+
sleep(1)
|
62
|
+
i += 1
|
63
|
+
if i <= $timeout+1 then retry
|
64
|
+
end
|
65
|
+
assert_equal(value1, value2.url)
|
66
|
+
end
|
67
|
+
elsif type == 4 then
|
68
|
+
begin
|
69
|
+
assert_equal(value1, value2.value)
|
70
|
+
rescue
|
71
|
+
sleep(1)
|
72
|
+
i += 1
|
73
|
+
if i <= $timeout+1 then retry
|
74
|
+
end
|
75
|
+
assert_equal(value1, value2.value)
|
76
|
+
end
|
77
|
+
elsif type == 5 then
|
78
|
+
begin
|
79
|
+
assert_equal(value1, value2.maxlength)
|
80
|
+
rescue
|
81
|
+
sleep(1)
|
82
|
+
i += 1
|
83
|
+
if i <= $timeout+1 then retry
|
84
|
+
end
|
85
|
+
assert_equal(value1, value2.maxlength)
|
44
86
|
end
|
45
|
-
assert_equal(value1, value2.text)
|
46
|
-
end
|
47
|
-
elsif type == 2 then
|
48
|
-
begin
|
49
|
-
assert_equal(value1, value2.title)
|
50
|
-
rescue
|
51
|
-
sleep(1)
|
52
|
-
i += 1
|
53
|
-
if i <= $timeout+1 then retry
|
54
|
-
end
|
55
|
-
assert_equal(value1, value2.title)
|
56
|
-
end
|
57
|
-
elsif type == 3 then
|
58
|
-
begin
|
59
|
-
assert_equal(value1, value2.url)
|
60
|
-
rescue
|
61
|
-
sleep(1)
|
62
|
-
i += 1
|
63
|
-
if i <= $timeout+1 then retry
|
64
|
-
end
|
65
|
-
assert_equal(value1, value2.url)
|
66
87
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
#Assert Equal False,<br>
|
92
|
+
#value1 = "String",<br>
|
93
|
+
#value2 = $ff.text,<br>
|
94
|
+
#type = 1:text(default),<br>
|
95
|
+
#type = 2:title,<br>
|
96
|
+
#type = 3:url<br>
|
97
|
+
#type = 4:value<br>
|
98
|
+
def assertfalseEqual(value1,value2,type=1)
|
99
|
+
i = 0
|
100
|
+
if type == 1 then
|
101
|
+
while value2.text == value1 do
|
102
|
+
sleep(1)
|
103
|
+
if i >= $timeout then
|
104
|
+
assert_equal("Timeout assertfalseEqual", value2.text)
|
105
|
+
break;
|
106
|
+
end
|
107
|
+
i += 1
|
108
|
+
end
|
109
|
+
elsif type == 2 then
|
110
|
+
while value2.title == value1 do
|
111
|
+
sleep(1)
|
112
|
+
if i >= $timeout then
|
113
|
+
assert_equal("Timeout assertfalseEqual", value2.title)
|
114
|
+
break;
|
115
|
+
end
|
116
|
+
i += 1
|
117
|
+
end
|
118
|
+
elsif type == 3 then
|
119
|
+
while value2.url == value1 do
|
120
|
+
sleep(1)
|
121
|
+
if i >= $timeout then
|
122
|
+
assert_equal("Timeout assertfalseEqual", value2.url)
|
123
|
+
break;
|
124
|
+
end
|
125
|
+
i += 1
|
126
|
+
end
|
127
|
+
elsif type == 4 then
|
128
|
+
while value2.value == value1 do
|
129
|
+
sleep(1)
|
130
|
+
if i >= $timeout then
|
131
|
+
assert_equal("Timeout assertfalseEqual", value2.value)
|
132
|
+
break;
|
133
|
+
end
|
134
|
+
i += 1
|
135
|
+
end
|
76
136
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
#Wait Element show
|
141
|
+
def waitExists(text,type = 1)
|
142
|
+
i = 0
|
143
|
+
if type == 1 then
|
144
|
+
while !text.exists? do
|
145
|
+
sleep(1)
|
146
|
+
i +=1
|
147
|
+
if i>=$timeout then
|
148
|
+
assert( text.exists? )
|
149
|
+
break;
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
else
|
154
|
+
begin
|
155
|
+
assert( text.click )
|
156
|
+
rescue
|
157
|
+
|
158
|
+
sleep(1)
|
159
|
+
i += 1
|
160
|
+
retry if i <= $timeout
|
161
|
+
end
|
86
162
|
end
|
87
163
|
end
|
88
|
-
|
89
|
-
end
|
90
164
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
while value2.text == value1 do
|
102
|
-
sleep(1)
|
103
|
-
if i >= $timeout then
|
104
|
-
assert_equal("Timeout assertfalseEqual", value2.text)
|
105
|
-
break;
|
165
|
+
def waitLinks(arg,text) #0.0.9
|
166
|
+
text.each do |item|
|
167
|
+
i = 0
|
168
|
+
while !$ff.link(:"#{arg}",item).exists? do
|
169
|
+
sleep(1)
|
170
|
+
i +=1
|
171
|
+
if i>=$timeout then
|
172
|
+
assert( $ff.link(:"#{arg}",item).exists? )
|
173
|
+
break;
|
174
|
+
end
|
106
175
|
end
|
107
|
-
i += 1
|
108
176
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
177
|
+
end
|
178
|
+
def waitSpans(arg,text) #0.0.9
|
179
|
+
text.each do |item|
|
180
|
+
i = 0
|
181
|
+
while !$ff.span(:"#{arg}",item).exists? do
|
182
|
+
sleep(1)
|
183
|
+
i +=1
|
184
|
+
if i>=$timeout then
|
185
|
+
assert( $ff.span(:"#{arg}",item).exists? )
|
186
|
+
break;
|
187
|
+
end
|
115
188
|
end
|
116
|
-
i += 1
|
117
189
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
190
|
+
end
|
191
|
+
def waitButtons(arg,text) #0.0.9
|
192
|
+
text.each do |item|
|
193
|
+
i = 0
|
194
|
+
while !$ff.button(:"#{arg}",item).exists? do
|
195
|
+
sleep(1)
|
196
|
+
i +=1
|
197
|
+
if i>=$timeout then
|
198
|
+
assert( $ff.button(:"#{arg}",item).exists? )
|
199
|
+
break;
|
200
|
+
end
|
124
201
|
end
|
125
|
-
i += 1
|
126
202
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
203
|
+
end
|
204
|
+
|
205
|
+
def waitImages(arg,text) #0.0.9
|
206
|
+
text.each do |item|
|
207
|
+
i = 0
|
208
|
+
while !$ff.image(:"#{arg}",item).exists? do
|
209
|
+
sleep(1)
|
210
|
+
i +=1
|
211
|
+
if i>=$timeout then
|
212
|
+
assert( $ff.image(:"#{arg}",item).exists? )
|
213
|
+
break;
|
214
|
+
end
|
133
215
|
end
|
134
|
-
i += 1
|
135
216
|
end
|
136
217
|
end
|
137
218
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
i = 0
|
143
|
-
if type == 1 then
|
144
|
-
while !text.exists? do
|
219
|
+
#Wait Element none
|
220
|
+
def waitfalseExists(text)
|
221
|
+
i = 0
|
222
|
+
while text.exists? do
|
145
223
|
sleep(1)
|
146
|
-
i +=1
|
147
224
|
if i>=$timeout then
|
148
|
-
assert(
|
225
|
+
assert(text.exists?)
|
149
226
|
break;
|
150
227
|
end
|
151
|
-
|
152
|
-
|
153
|
-
else
|
154
|
-
begin
|
155
|
-
assert( text.click )
|
156
|
-
rescue
|
157
|
-
|
158
|
-
sleep(1)
|
159
|
-
i += 1
|
160
|
-
retry if i <= $timeout
|
228
|
+
i +=1
|
161
229
|
end
|
162
230
|
end
|
163
|
-
end
|
164
231
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
232
|
+
def noLinks(arg,text)
|
233
|
+
text.each do |item|
|
234
|
+
i = 0
|
235
|
+
while $ff.link(:"#{arg}",item).exists? do
|
236
|
+
sleep(1)
|
237
|
+
i +=1
|
238
|
+
if i>=$timeout then
|
239
|
+
assert( !$ff.link(:"#{arg}",item).exists? )
|
240
|
+
end
|
241
|
+
end
|
173
242
|
end
|
174
|
-
i +=1
|
175
243
|
end
|
176
|
-
end
|
177
244
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
sleep(1)
|
188
|
-
i +=1
|
189
|
-
if i>=10 then
|
190
|
-
assert(!$ff.link(:id,text).exists?)
|
245
|
+
def noButtons(arg,text)
|
246
|
+
text.each do |item|
|
247
|
+
i = 0
|
248
|
+
while $ff.button(:"#{arg}",item).exists? do
|
249
|
+
sleep(1)
|
250
|
+
i +=1
|
251
|
+
if i>=$timeout then
|
252
|
+
assert( !$ff.button(:"#{arg}",item).exists? )
|
253
|
+
end
|
191
254
|
end
|
192
255
|
end
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
256
|
+
end
|
257
|
+
|
258
|
+
def noSpans(arg,text)
|
259
|
+
text.each do |item|
|
260
|
+
i = 0
|
261
|
+
while $ff.span(:"#{arg}",item).exists? do
|
262
|
+
sleep(1)
|
263
|
+
i +=1
|
264
|
+
if i>=$timeout then
|
265
|
+
assert( !$ff.span(:"#{arg}",item).exists? )
|
266
|
+
end
|
201
267
|
end
|
202
268
|
end
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
i
|
208
|
-
|
209
|
-
|
269
|
+
end
|
270
|
+
|
271
|
+
def noImages(arg,text)
|
272
|
+
text.each do |item|
|
273
|
+
i = 0
|
274
|
+
while $ff.image(:"#{arg}",item).exists? do
|
275
|
+
sleep(1)
|
276
|
+
i +=1
|
277
|
+
if i>=$timeout then
|
278
|
+
assert( !$ff.image(:"#{arg}",item).exists? )
|
279
|
+
end
|
210
280
|
end
|
211
281
|
end
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
282
|
+
end
|
283
|
+
|
284
|
+
#tags = 1: Link(d)<br>
|
285
|
+
#tags = 2: Button<br>
|
286
|
+
#tags = 3: Table<br>
|
287
|
+
#tags = 4: Textfield<br>
|
288
|
+
#tags = 5: Div<br>
|
289
|
+
def falseExistsid(text,tags=1)
|
290
|
+
if tags == 1 then
|
291
|
+
i = 0
|
292
|
+
while $ff.link(:id,text).exists? do
|
293
|
+
sleep(1)
|
294
|
+
i +=1
|
295
|
+
if i>=10 then
|
296
|
+
assert(!$ff.link(:id,text).exists?)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
elsif tags == 2 then
|
301
|
+
i = 0
|
302
|
+
while $ff.button(:id,text).exists? do
|
303
|
+
sleep(1)
|
304
|
+
i +=1
|
305
|
+
if i>=10 then
|
306
|
+
assert(!$ff.button(:id,text).exists?)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
elsif tags == 3 then
|
310
|
+
i = 0
|
311
|
+
while $ff.table(:id,text).exists? do
|
312
|
+
sleep(1)
|
313
|
+
i +=1
|
314
|
+
if i>=10 then
|
315
|
+
assert(!$ff.table(:id,text).exists?)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
elsif tags == 4 then
|
319
|
+
i = 0
|
320
|
+
while $ff.text_field(:id,text).exists? do
|
321
|
+
sleep(1)
|
322
|
+
i +=1
|
323
|
+
if i>=10 then
|
324
|
+
assert(!$ff.text_field(:id,text).exists?)
|
325
|
+
end
|
219
326
|
end
|
220
327
|
end
|
221
|
-
end
|
222
328
|
|
223
|
-
end
|
329
|
+
end
|
224
330
|
|
225
|
-
#tags = 1: Link(d)
|
226
|
-
def falseExiststext(text,tags=1)
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
331
|
+
#tags = 1: Link(d)
|
332
|
+
def falseExiststext(text,tags=1)
|
333
|
+
if tags == 1 then
|
334
|
+
i = 0
|
335
|
+
while $ff.link(:text,text).exists? do
|
336
|
+
sleep(1)
|
337
|
+
i +=1
|
338
|
+
if i>=10 then
|
339
|
+
assert(!$ff.link(:text,text).exists?)
|
340
|
+
end
|
234
341
|
end
|
235
|
-
end
|
236
342
|
|
343
|
+
end
|
237
344
|
end
|
238
|
-
end
|
239
345
|
|
240
|
-
#tags = 1: Link(d)
|
241
|
-
def falseExistsclass(text,tags=1)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
346
|
+
#tags = 1: Link(d)
|
347
|
+
def falseExistsclass(text,tags=1)
|
348
|
+
if tags == 1 then
|
349
|
+
i = 0
|
350
|
+
while $ff.link(:class,text).exists? do
|
351
|
+
sleep(1)
|
352
|
+
i +=1
|
353
|
+
if i>=10 then
|
354
|
+
assert(!$ff.link(:class,text).exists?)
|
355
|
+
break;
|
356
|
+
end
|
250
357
|
end
|
251
|
-
end
|
252
358
|
|
359
|
+
end
|
253
360
|
end
|
254
|
-
end
|
255
361
|
|
256
362
|
|
257
|
-
#tags = 1: Link(d)
|
258
|
-
def falseExistshref(text,tags=1)
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
363
|
+
#tags = 1: Link(d)
|
364
|
+
def falseExistshref(text,tags=1)
|
365
|
+
if tags == 1 then
|
366
|
+
i = 0
|
367
|
+
while $ff.link(:href,text).exists? do
|
368
|
+
sleep(1)
|
369
|
+
i +=1
|
370
|
+
if i>=10 then
|
371
|
+
assert(!$ff.link(:href,text).exists?)
|
372
|
+
end
|
266
373
|
end
|
267
|
-
end
|
268
374
|
|
375
|
+
end
|
269
376
|
end
|
270
|
-
end
|
271
377
|
|
272
|
-
#tags = 1: Link(d)
|
273
|
-
def falseExistsindex(browser,text,tags=1)
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
378
|
+
#tags = 1: Link(d)
|
379
|
+
def falseExistsindex(browser,text,tags=1)
|
380
|
+
if tags == 1 then
|
381
|
+
i = 0
|
382
|
+
while browser.link(:index,text).exists? do
|
383
|
+
sleep(1)
|
384
|
+
i +=1
|
385
|
+
if i>=10 then
|
386
|
+
assert(!browser.link(:index,text).exists?)
|
387
|
+
end
|
281
388
|
end
|
282
|
-
end
|
283
389
|
|
390
|
+
end
|
284
391
|
end
|
285
|
-
end
|
286
392
|
|
287
|
-
def returnwaitExists(text)
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
393
|
+
def returnwaitExists(text)
|
394
|
+
nwait(1) #0.0.6
|
395
|
+
sleep(0.5)
|
396
|
+
if text.exists? then
|
397
|
+
return true
|
398
|
+
else
|
399
|
+
return false
|
400
|
+
end
|
294
401
|
end
|
295
402
|
end
|
296
|
-
end
|
297
403
|
#E: Assert
|
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
|
+
- 9
|
9
|
+
version: 0.0.9
|
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-
|
17
|
+
date: 2010-11-19 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|