Module: Qa

Defined in:
lib/function/assertions.rb

Overview

E: Assert Assertion text in page

Instance Method Summary collapse

Instance Method Details

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

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



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
# File 'lib/function/assertions.rb', line 35

def assertEqual(value1,value2,type=1)
    i = 0
    if type == 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
    elsif type == 2 then
	begin
	    assert_equal(value1, value2.title)
	rescue
	    sleep(1)
	    i += 1
	    if i <= $timeout+1 then retry
	    end
	end
    elsif type == 3 then
	begin
	    assert_equal(value1, value2.url)
	rescue
	    sleep(1)
	    i += 1
	    if i <= $timeout+1 then retry
	    end
	end
    elsif type == 4 then
	begin
	    assert_equal(value1, value2.value)
	rescue
	    sleep(1)
	    i += 1
	    if i <= $timeout+1 then retry
	    end
	end
    elsif type == 5 then
	begin
	    assert_equal(value1, value2.maxlength)
	rescue
	    sleep(1)
	    i += 1
	    if i <= $timeout+1 then retry
	    end
	end
    end
    puts "assertEqual :#{i}" if i != 0
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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/function/assertions.rb', line 94

def assertfalseEqual(value1,value2,type=1)
    i = 0
    if type == 1 then
	while value2.text == value1 do
	    sleep(1)
	    if i >= $timeout then
		assert_equal("Timeout assertfalseEqual", value2.text)
		break;
	    end
	    i += 1
	end
    elsif type == 2 then
	while value2.title == value1 do
	    sleep(1)
	    if i >= $timeout then
		assert_equal("Timeout assertfalseEqual", value2.title)
		break;
	    end
	    i += 1
	end
    elsif type == 3 then
	while value2.url == value1 do
	    sleep(1)
	    if i >= $timeout then
		assert_equal("Timeout assertfalseEqual", value2.url)
		break;
	    end
	    i += 1
	end
    elsif type == 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
    puts "assertfalseEqual :#{i}" if i != 0
end

#assertfalseText(text) ⇒ Object

Assert False text in page



17
18
19
20
21
22
23
24
25
26
27
# 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))
	    break;
	end
	i=i+1
    end
end

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

0.0.6



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

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))
#	    break;
	end
	i=i+1
    end
end

#falseExistsclass(text, tags = 1) ⇒ Object

tags = 1: Link(d)



237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/function/assertions.rb', line 237

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
        puts "falseExistsclass :#{i}" if i != 0
    end
end

#falseExistshref(text, tags = 1) ⇒ Object

tags = 1: Link(d)



254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/function/assertions.rb', line 254

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
	puts "falseExistshref :#{i}" if i != 0
    end
end

#falseExistsid(text, tags = 1) ⇒ Object

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



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/function/assertions.rb', line 179

def falseExistsid(text,tags=1)
    if tags == 1 then
	i = 0
	while $ff.link(:id,text).exists? do
	    sleep(1)
	    i +=1
	    if i>=10 then
		assert(!$ff.link(:id,text).exists?)
	    end
	end
	puts "falseExistsid :#{i}" if i != 0
    elsif tags == 2 then
	i = 0
	while $ff.button(:id,text).exists? do
	    sleep(1)
	    i +=1
	    if i>=10 then
		assert(!$ff.button(:id,text).exists?)
	    end
	end
    elsif tags == 3 then
	i = 0
	while $ff.table(:id,text).exists? do
	    sleep(1)
	    i +=1
	    if i>=10 then
		assert(!$ff.table(:id,text).exists?)
	    end
	end
    elsif tags == 4 then
	i = 0
	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
    end
    
end

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

tags = 1: Link(d)



269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/function/assertions.rb', line 269

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
	puts "falseExistsindex :#{i}" if i != 0
    end
end

#falseExiststext(text, tags = 1) ⇒ Object

tags = 1: Link(d)



222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/function/assertions.rb', line 222

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
	puts "falseExiststext :#{i}" if i != 0
    end
end

#returnwaitExists(text) ⇒ Object



283
284
285
286
287
288
289
290
291
# File 'lib/function/assertions.rb', line 283

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

#waitExists(text, type = 1) ⇒ Object

Wait Element show



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/function/assertions.rb', line 137

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
	puts "WaitExists: #{i}" if i != 0
    else
	begin
	    assert( text.click )
	rescue
	    puts i
	    sleep(1)
	    i += 1
	    retry if i <= $timeout
	end
    end
end

#waitfalseExists(text) ⇒ Object

Wait Element none



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/function/assertions.rb', line 162

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