Module: Qa

Includes:
Test::Unit::Assertions
Defined in:
lib/function/assertions.rb

Overview

E: Assert Assertion text in page

Instance Method Summary collapse

Instance Method Details

#assertBrowser_Equal(value, valuetype = "title") ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/function/assertions.rb', line 247

def assertBrowser_Equal(value,valuetype="title")
	i = 0
	case valuetype
	when "title" then
 begin
		assert_equal(value, $ff.title)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value, $ff.title)
 end
	when "url" then
 begin
		assert_equal(value, $ff.url)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value, $ff.url)
 end
	when "status" then
 begin
		assert_equal(value, $ff.status)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value, $ff.status)
 end
	end
end

#assertDiv_Equal(value1, divtype, value2, valuetype = "text") ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/function/assertions.rb', line 114

def assertDiv_Equal(value1,divtype,value2,valuetype="text")
	i = 0
	case valuetype
	when "text" then
 begin
		assert_equal(value1, $ff.div(:"#{divtype}",value2).text)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.div(:"#{divtype}",value2).text)
 end
	when "id" then
 begin
		assert_equal(value1, $ff.div(:"#{divtype}",value2).id)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.div(:"#{divtype}",value2).id)
 end
	end
end

#assertEqual(value1, value2, type = 1) ⇒ Object

Assert Equal
type = 1:text(default)
type = 2:title
type = 3:url
type = 4:value
type = 5:maxlength



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
# File 'lib/function/assertions.rb', line 34

def assertEqual(value1,value2,type=1) #0.0.8
	i = 0
	case type
	when 1 then
 begin
		assert_equal(value1, value2.text)
 rescue Exception => e
		sleep(1)
		i += 1
		if i < $timeout then retry
		end
		assert_equal(value1, value2.text)
 end
	when 2 then
 begin
		assert_equal(value1, value2.title)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, value2.title)
 end
	when 3 then
 begin
		assert_equal(value1, value2.url)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, value2.url)
 end
	when 4 then
 begin
		assert_equal(value1, value2.value)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, value2.value)
 end
	when 5 then
 begin
		assert_equal(value1, value2.maxlength)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, value2.maxlength)
 end
	end
end

#assertfalseEqual(value1, value2, type = 1) ⇒ Object

Assert Equal False,
value1 = “String”,
value2 = $ff.text,
type = 1:text(default),
type = 2:title,
type = 3:url
type = 4:value



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/function/assertions.rb', line 290

def assertfalseEqual(value1,value2,type=1)
	i = 0
	case type
	when 1 then
 while value2.text == value1 do
		sleep(1)
		if i >= $timeout then
  assert_equal("Timeout assertfalseEqual", value2.text)
  break;
		end
		i += 1
 end
	when 2 then
 while value2.title == value1 do
		sleep(1)
		if i >= $timeout then
  assert_equal("Timeout assertfalseEqual", value2.title)
  break;
		end
		i += 1
 end
	when 3 then
 while value2.url == value1 do
		sleep(1)
		if i >= $timeout then
  assert_equal("Timeout assertfalseEqual", value2.url)
  break;
		end
		i += 1
 end
	when 4 then
 while value2.value == value1 do
		sleep(1)
		if i >= $timeout then
  assert_equal("Timeout assertfalseEqual", value2.value)
  break;
		end
		i += 1
 end
	end
end

#assertfalseText(text) ⇒ Object

Assert False text in page



17
18
19
20
21
22
23
24
25
26
# File 'lib/function/assertions.rb', line 17

def assertfalseText(text)
	i = 0
	while $ff.contains_text(text) do
 sleep(1)
 if i>=$timeout then
		assert_false($ff.contains_text(text))
 end
 i=i+1
	end
end

#assertImage_Equal(value1, imagetype, value2, valuetype = "src") ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/function/assertions.rb', line 166

def assertImage_Equal(value1,imagetype,value2,valuetype="src")
	i = 0
	case valuetype
	when "src" then
 begin
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).src)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).src)
 end
	when "href" then
 begin
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).href)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).href)
 end
	when "id" then
 begin
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).id)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.image(:"#{imagetype}",value2).id)
 end
	end
end


140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/function/assertions.rb', line 140

def assertLink_Equal(value1,linktype,value2,valuetype="text")
	i = 0
	case valuetype
	when "text" then
 begin
		assert_equal(value1, $ff.link(:"#{linktype}",value2).text)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.link(:"#{linktype}",value2).text)
 end
	when "id" then
 begin
		assert_equal(value1, $ff.link(:"#{linktype}",value2).id)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.link(:"#{linktype}",value2).id)
 end
	end
end

#assertSpan_Equal(value1, spantype, value2, valuetype = "text") ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/function/assertions.rb', line 89

def assertSpan_Equal(value1,spantype,value2,valuetype="text")
	i = 0
	case valuetype
	when "text" then
 begin
		assert_equal(value1, $ff.span(:"#{spantype}",value2).text)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.span(:"#{spantype}",value2).text)
 end
	when "id" then
 begin
		assert_equal(value1, $ff.span(:"#{spantype}",value2).id)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.span(:"#{spantype}",value2).id)
 end
	end
end

#assertText(text, waittime = $timeout) ⇒ Object

0.0.6



5
6
7
8
9
10
11
12
13
14
# File 'lib/function/assertions.rb', line 5

def assertText(text,waittime = $timeout) #0.0.6
	i = 0
	while !$ff.contains_text(text) do
 sleep(1)
 if i>=waittime then
		assert($ff.contains_text(text))
 end
 i=i+1
	end
end

#assertTextfield_Equal(value1, textfieldtype, value2, valuetype = "value") ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/function/assertions.rb', line 202

def assertTextfield_Equal(value1,textfieldtype,value2,valuetype="value")
	i = 0
	case valuetype
	when "value" then
 begin
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).value)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).value)
 end
	when "id" then
 begin
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).id)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).id)
 end
	when "name" then
 begin
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).name)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).name)
 end
	when "maxlength" then
 begin
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).maxlength)
 rescue
		sleep(1)
		i += 1
		if i <= $timeout+1 then retry
		end
		assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).maxlength)
 end
	end
end

#falseExistsclass(text, tags = 1) ⇒ Object

tags = 1: Link(d)



639
640
641
642
643
644
645
646
647
648
649
650
651
652
# File 'lib/function/assertions.rb', line 639

def falseExistsclass(text,tags=1)
	if tags == 1 then
 i = 0
 while $ff.link(:class,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.link(:class,text).exists?)
  break;
		end
 end
    
	end
end

#falseExistshref(text, tags = 1) ⇒ Object

tags = 1: Link(d)



656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'lib/function/assertions.rb', line 656

def falseExistshref(text,tags=1)
	if tags == 1 then
 i = 0
 while $ff.link(:href,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.link(:href,text).exists?)
		end
 end
	
	end
end

#falseExistsid(text, tags = 1) ⇒ Object

tags = 1: Link(d)
tags = 2: Button
tags = 3: Table
tags = 4: Textfield
tags = 5: Div



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/function/assertions.rb', line 578

def falseExistsid(text,tags=1)
	i = 0
	case tags
	when 1 then
 while $ff.link(:id,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.link(:id,text).exists?)
		end
 end
	when 2 then
 while $ff.button(:id,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.button(:id,text).exists?)
		end
 end
	when 3 then
 while $ff.table(:id,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.table(:id,text).exists?)
		end
 end
	when 4 then
 while $ff.text_field(:id,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.text_field(:id,text).exists?)
		end
 end
	when 5 then
 while $ff.div(:id,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.div(:id,text).exists?)
		end
 end
	end
end

#falseExistsindex(browser, text, tags = 1) ⇒ Object

tags = 1: Link(d)



671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/function/assertions.rb', line 671

def falseExistsindex(browser,text,tags=1)
	if tags == 1 then
 i = 0
 while browser.link(:index,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!browser.link(:index,text).exists?)
		end
 end
	
	end
end

#falseExiststext(text, tags = 1) ⇒ Object

tags = 1: Link(d)



624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/function/assertions.rb', line 624

def falseExiststext(text,tags=1)
	if tags == 1 then
 i = 0
 while $ff.link(:text,text).exists? do
		sleep(1)
		i +=1
		if i>=10 then
  assert(!$ff.link(:text,text).exists?)
		end
 end
	
	end
end

#noButtons(arg, text) ⇒ Object



497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/function/assertions.rb', line 497

def noButtons(arg,text)
	text.each do |item|
 i = 0
 while $ff.button(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.button(:"#{arg}",item).exists? )
		end
 end
	end
end

#noDivs(arg, text) ⇒ Object



548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/function/assertions.rb', line 548

def noDivs(arg,text)
	text.each do |item|
 i = 0
 while $ff.div(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.div(:"#{arg}",item).exists? )
		end
 end
	end
end

#noImages(arg, text) ⇒ Object



523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/function/assertions.rb', line 523

def noImages(arg,text)
	text.each do |item|
 i = 0
 while $ff.image(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.image(:"#{arg}",item).exists? )
		end
 end
	end
end


471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/function/assertions.rb', line 471

def noLinks(arg,text)
	text.each do |item|
 i = 0
 while $ff.link(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.link(:"#{arg}",item).exists? )
		end
 end
	end
end

#noSelectlists(arg, text) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/function/assertions.rb', line 484

def noSelectlists(arg,text)
	text.each do |item|
 i = 0
 while $ff.select_list(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.select_list(:"#{arg}",item).exists? )
		end
 end
	end
end

#noSpans(arg, text) ⇒ Object



510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/function/assertions.rb', line 510

def noSpans(arg,text)
	text.each do |item|
 i = 0
 while $ff.span(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.span(:"#{arg}",item).exists? )
		end
 end
	end
end

#noTables(arg, text) ⇒ Object



536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/function/assertions.rb', line 536

def noTables(arg,text)
	text.each do |item|
 i = 0
 while $ff.table(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.table(:"#{arg}",item).exists? )
		end
 end
	end
end

#noTextfields(arg, text) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/function/assertions.rb', line 560

def noTextfields(arg,text)
	text.each do |item|
 i = 0
 while $ff.text_field(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( !$ff.text_field(:"#{arg}",item).exists? )
		end
 end
	end
end

#returnwaitExists(text) ⇒ Object



685
686
687
688
689
690
691
692
693
# File 'lib/function/assertions.rb', line 685

def returnwaitExists(text)
	nwait(1) #0.0.6
	sleep(0.5)
	if text.exists? then
 return true
	else
 return false
	end
end

#showButtons(arg, text) ⇒ Object



382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/function/assertions.rb', line 382

def showButtons(arg,text)
	text.each do |item|
 i = 0
 while !$ff.button(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.button(:"#{arg}",item).exists? )
		end
 end
	end
end

#showDivs(arg, text) ⇒ Object



421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/function/assertions.rb', line 421

def showDivs(arg,text)
	text.each do |item|
 i = 0
 while !$ff.div(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.div(:"#{arg}",item).exists? )
		end
 end
	end
end

#showImages(arg, text) ⇒ Object



408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/function/assertions.rb', line 408

def showImages(arg,text)
	text.each do |item|
 i = 0
 while !$ff.image(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.image(:"#{arg}",item).exists? )
		end
 end
	end
end


369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/function/assertions.rb', line 369

def showLinks(arg,text)
	text.each do |item|
 i = 0
 while !$ff.link(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.link(:"#{arg}",item).exists? )
		end
 end
	end
end

#showSelectlists(arg, text) ⇒ Object



458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/function/assertions.rb', line 458

def showSelectlists(arg,text)
	text.each do |item|
 i = 0
 while !$ff.select_list(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.select_list(:"#{arg}",item).exists? )
		end
 end
	end
end

#showSpans(arg, text) ⇒ Object



395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/function/assertions.rb', line 395

def showSpans(arg,text)
	text.each do |item|
 i = 0
 while !$ff.span(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.span(:"#{arg}",item).exists? )
		end
 end
	end
end

#showTables(arg, text) ⇒ Object



446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/function/assertions.rb', line 446

def showTables(arg,text)
	text.each do |item|
 i = 0
 while !$ff.table(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.table(:"#{arg}",item).exists? )
		end
 end
	end
end

#showTextfields(arg, text) ⇒ Object



434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/function/assertions.rb', line 434

def showTextfields(arg,text)
	text.each do |item|
 i = 0
 while !$ff.text_field(:"#{arg}",item).exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( $ff.text_field(:"#{arg}",item).exists? )
		end
 end
	end
end

#waitExists(text, type = 1) ⇒ Object

Wait Element show



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/function/assertions.rb', line 333

def waitExists(text,type = 1)
	i = 0
	if type == 1 then
 while !text.exists? do
		sleep(1)
		i +=1
		if i>=$timeout then
  assert( text.exists? )
  break;
		end
 end
	
	else
 begin
		assert( text.click )
 rescue
 
		sleep(1)
		i += 1
		retry if i <= $timeout
 end
	end
end

#waitfalseExists(text) ⇒ Object

Wait Element none



358
359
360
361
362
363
364
365
366
367
# File 'lib/function/assertions.rb', line 358

def waitfalseExists(text)
	i = 0
	while text.exists? do
 sleep(1)
 if i>=$timeout then
		assert(text.exists?)
 end
 i +=1
	end
end