Module: Qh

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

Overview

B: HTML

Instance Method Summary collapse

Instance Method Details

#clearCheckboxid(name) ⇒ Object



375
376
377
378
# File 'lib/function/HTMLElement.rb', line 375

def clearCheckboxid(name)
	waitExists($ff.checkbox(:id,name))
	$ff.checkbox(:id,name).clear
end

#click_javascript_buttonObject



465
466
467
468
469
470
# File 'lib/function/HTMLElement.rb', line 465

def click_javascript_button()
	path = File.join(File.dirname(__FILE__), "javascriptPopup.rb")
	Thread.new { system("ruby \"#{path}\"") }
	yield
	sleep(3)
end

#clickalertButtonid(name) ⇒ Object



433
434
435
436
437
# File 'lib/function/HTMLElement.rb', line 433

def clickalertButtonid(name)
	waitExists($ff.button(:id,name))
	$ff.startClicker("OK")
	$ff.button(:id,name).click
end

#clickalertButtonname(name) ⇒ Object



439
440
441
442
443
# File 'lib/function/HTMLElement.rb', line 439

def clickalertButtonname(name)
	waitExists($ff.button(:name,name))
	$ff.startClicker("OK")
	$ff.button(:name,name).click
end

#clickalertElement(name) ⇒ Object



445
446
447
448
449
# File 'lib/function/HTMLElement.rb', line 445

def clickalertElement(name)
	waitExists(name)
	$ff.startClicker("OK")
	name.click
end

#clickalertImageid(text) ⇒ Object



458
459
460
461
462
463
# File 'lib/function/HTMLElement.rb', line 458

def clickalertImageid(text)
	waitExists( $ff.image(:id,text) )
	$ff.startClicker("OK")
	$ff.image(:id,text).click
	sleep(2)
end

#clickalertImagesrc(text) ⇒ Object



451
452
453
454
455
456
# File 'lib/function/HTMLElement.rb', line 451

def clickalertImagesrc(text)
	waitExists( $ff.image(:src,text) )
	$ff.startClicker("OK")
	$ff.image(:src,text).click
	sleep(2)
end

#clickalertLinkclass(name) ⇒ Object



427
428
429
430
431
# File 'lib/function/HTMLElement.rb', line 427

def clickalertLinkclass(name)
	waitExists($ff.link(:class,name))
	$ff.startClicker("OK")
	$ff.link(:class,name).click
end

#clickalertLinkid(name) ⇒ Object



415
416
417
418
419
# File 'lib/function/HTMLElement.rb', line 415

def clickalertLinkid(name)
	waitExists($ff.link(:id,name))
	$ff.startClicker("OK")
	$ff.link(:id,name).click
end

#clickalertLinktext(name) ⇒ Object

Alert



409
410
411
412
413
# File 'lib/function/HTMLElement.rb', line 409

def clickalertLinktext(name)
	waitExists($ff.link(:text,name))
	$ff.startClicker("OK")
	$ff.link(:text,name).click
end

#clickalertLinktitle(name) ⇒ Object



421
422
423
424
425
# File 'lib/function/HTMLElement.rb', line 421

def clickalertLinktitle(name)
	waitExists($ff.link(:title,name))
	$ff.startClicker("OK")
	$ff.link(:title,name).click
end

#clickButtonid(text) ⇒ Object

Button



45
46
47
48
# File 'lib/function/HTMLElement.rb', line 45

def clickButtonid(text)
	waitExists($ff.button(:id,text))
	$ff.button(:id,text).click
end

#clickButtonname(text) ⇒ Object



50
51
52
53
# File 'lib/function/HTMLElement.rb', line 50

def clickButtonname(text)
	waitExists($ff.button(:name,text))
	$ff.button(:name,text).click
end

#clickButtonvalue(text) ⇒ Object

0.0.7



55
56
57
58
# File 'lib/function/HTMLElement.rb', line 55

def clickButtonvalue(text) #0.0.7
	waitExists($ff.button(:value,text))
	$ff.button(:value,text).click
end

#clickDivid(text) ⇒ Object



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

def clickDivid(text)
	i = 0
	begin
 $ff.div(:id , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#clickDivtext(text) ⇒ Object

0.0.7



283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/function/HTMLElement.rb', line 283

def clickDivtext(text) #0.0.7
	i = 0
	begin
 $ff.div(:text , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#clickImagesrc(text) ⇒ Object

Image



61
62
63
64
# File 'lib/function/HTMLElement.rb', line 61

def clickImagesrc(text)
	waitExists($ff.image(:src,text))
	$ff.image(:src,text).click
end

#clickLinkclass(text) ⇒ Object



39
40
41
42
# File 'lib/function/HTMLElement.rb', line 39

def clickLinkclass(text)
	waitExists($ff.link(:class,text))
	$ff.link(:class,text).click
end

#clickLinkhref(name) ⇒ Object



29
30
31
32
# File 'lib/function/HTMLElement.rb', line 29

def clickLinkhref(name)
	waitExists($ff.link(:href,name))
	$ff.link(:href,name).click
end

#clickLinkid(text) ⇒ Object



24
25
26
27
# File 'lib/function/HTMLElement.rb', line 24

def clickLinkid(text)
	waitExists($ff.link(:id,text))
	$ff.link(:id,text).click
end

#clickLinktext(text) ⇒ Object

Link



19
20
21
22
# File 'lib/function/HTMLElement.rb', line 19

def clickLinktext(text)
	waitExists($ff.link(:text,text))
	$ff.link(:text,text).click
end

#clickLinktitle(text) ⇒ Object



34
35
36
37
# File 'lib/function/HTMLElement.rb', line 34

def clickLinktitle(text)
	waitExists($ff.link(:title,text))
	$ff.link(:title,text).click
end

#clickSpanclass(text) ⇒ Object



329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/function/HTMLElement.rb', line 329

def clickSpanclass(text)
	i = 0
	begin
 $ff.span(:class , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#clickSpanid(text) ⇒ Object

Span



299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/function/HTMLElement.rb', line 299

def clickSpanid(text)
	i = 0
	begin
 $ff.span(:id , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#clickSpantext(text) ⇒ Object

0.0.7



314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/function/HTMLElement.rb', line 314

def clickSpantext(text) #0.0.7
	i = 0
	begin
 $ff.span(:text , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#clickSpanxpath(text) ⇒ Object



344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/function/HTMLElement.rb', line 344

def clickSpanxpath(text)
	i = 0
	begin
 $ff.span(:xpath , text).click
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i < $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
end

#fire_event(element, type = 1) ⇒ Object

Javascript event:
type = 1: onMouseOver(d)



503
504
505
506
507
508
# File 'lib/function/HTMLElement.rb', line 503

def fire_event(element,type = 1)
	waitExists(element)
	if type == 1 then
 element.fire_event("onMouseOver")
	end
end

#getAttachtitle(title) ⇒ Object



491
492
493
494
495
496
497
498
499
# File 'lib/function/HTMLElement.rb', line 491

def getAttachtitle(title)
	begin
 ff1 = $ff.attach(:title,title)
	rescue Exception => e
 sleep(1)
 retry
	end
	return ff1
end

#getAttachurl(url) ⇒ Object

Attach 0.0.8



481
482
483
484
485
486
487
488
489
# File 'lib/function/HTMLElement.rb', line 481

def getAttachurl(url)
	begin
 ff1 = $ff.attach(:url,url)
	rescue Exception => e
 sleep(1)
 retry
	end
	return ff1
end

#getDivclass(text) ⇒ Object

Div



256
257
258
259
260
# File 'lib/function/HTMLElement.rb', line 256

def getDivclass(text)
	waitExists( $ff.div(:class,text) )
	nwait(1)
	return $ff.div(:class,text)
end

#getDivid(text) ⇒ Object



262
263
264
265
266
# File 'lib/function/HTMLElement.rb', line 262

def getDivid(text)
	waitExists( $ff.div(:id,text) )
	nwait(2)
	return $ff.div(:id,text)
end

#getFormaction(text) ⇒ Object



153
154
155
156
157
158
# File 'lib/function/HTMLElement.rb', line 153

def getFormaction(text)
	waitExists($ff.form(:action,text))
	nwait(1)
	sleep(1)
	return $ff.form(:action,text)
end

#getFormid(text) ⇒ Object



148
149
150
151
# File 'lib/function/HTMLElement.rb', line 148

def getFormid(text)
	waitExists($ff.form(:id,text))
	return $ff.form(:id,text)
end

#getFrameid(text) ⇒ Object

Frame



161
162
163
164
# File 'lib/function/HTMLElement.rb', line 161

def getFrameid(text)
	waitExists($ff.frame(:id,text))
	return $ff.frame(:id,text)
end

#getFrameindex(text) ⇒ Object



166
167
168
169
# File 'lib/function/HTMLElement.rb', line 166

def getFrameindex(text)
	waitExists($ff.frame(:index,text))
	return $ff.frame(:index,text)
end

#getFramesrc(text) ⇒ Object



171
172
173
174
# File 'lib/function/HTMLElement.rb', line 171

def getFramesrc(text)
	waitExists($ff.frame(:src,text))
	return $ff.frame(:src,text)
end

#getSelectlistid(text) ⇒ Object



392
393
394
395
396
# File 'lib/function/HTMLElement.rb', line 392

def getSelectlistid(text)
	waitExists($ff.select_list(:id,text))
	nwait(1)
	return $ff.select_list(:id,text)
end

#getTableid(text) ⇒ Object

Table



249
250
251
252
253
# File 'lib/function/HTMLElement.rb', line 249

def getTableid(text)
	waitExists( $ff.table(:id,text) )
	sleep(1)
	return $ff.table(:id,text)
end

#goto(url) ⇒ Object

Goto url



5
6
7
# File 'lib/function/HTMLElement.rb', line 5

def goto(url)
	$ff.goto(url)
end

#nwait(n = 1) ⇒ Object

E: Alert



474
475
476
477
478
# File 'lib/function/HTMLElement.rb', line 474

def nwait(n=1)
	for i in 1..n
 $ff.wait
	end
end

#refreshObject

Refresh



10
11
12
# File 'lib/function/HTMLElement.rb', line 10

def refresh
	$ff.refresh
end

#removeAllCookiesObject

Remove all Cookies on Browser



516
517
518
519
# File 'lib/function/HTMLElement.rb', line 516

def removeAllCookies #0.0.8
	jssh_command = "Components.classes[\"@mozilla.org/cookiemanager;1\"].getService(Components.interfaces.nsICookieManager).removeAll();"
	$jssh_socket.send("#{jssh_command}\n", 0)
end

#setCheckboxid(name) ⇒ Object

Checkbox



360
361
362
363
# File 'lib/function/HTMLElement.rb', line 360

def setCheckboxid(name)
	waitExists($ff.checkbox(:id,name))
	$ff.checkbox(:id,name).set
end

#setCheckboxname(name) ⇒ Object



365
366
367
368
# File 'lib/function/HTMLElement.rb', line 365

def setCheckboxname(name)
	waitExists($ff.checkbox(:name,name))
	$ff.checkbox(:name,name).set
end

#setCheckboxvalue(name) ⇒ Object



370
371
372
373
# File 'lib/function/HTMLElement.rb', line 370

def setCheckboxvalue(name)
	waitExists($ff.checkbox(:value,name))
	$ff.checkbox(:value,name).set
end

#setfilefieldid(text1, text2) ⇒ Object

Filefield



127
128
129
130
# File 'lib/function/HTMLElement.rb', line 127

def setfilefieldid(text1,text2)
	waitExists($ff.file_field(:id,text1))
	$ff.file_field(:id,text1).set(text2)
end

#setfilefieldname(text1, text2) ⇒ Object



132
133
134
135
# File 'lib/function/HTMLElement.rb', line 132

def setfilefieldname(text1,text2)
	waitExists($ff.file_field(:name,text1))
	$ff.file_field(:name,text1).set(text2)
end

#setFTextfieldid(fr, text) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/function/HTMLElement.rb', line 176

def setFTextfieldid(fr,text)
	i = 0
	while !$ff.frame(:id,fr).text_field(:id,text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:id,fr).text_field(:id,text).exists? )
		break;
 end
	end
end

#setRadioid(id) ⇒ Object



404
405
406
407
# File 'lib/function/HTMLElement.rb', line 404

def setRadioid(id)
	waitExists($ff.radio(:id,id))
	$ff.radio(:id,id).set
end

#setRadiovalue(value) ⇒ Object

Radio



399
400
401
402
# File 'lib/function/HTMLElement.rb', line 399

def setRadiovalue(value)
	waitExists($ff.radio(:value,value))
	$ff.radio(:value,value).set
end

#setSelectlistid(name, value, type = 1) ⇒ Object

Select_list:
type = 1: text(d),
type = 2: value,



383
384
385
386
387
388
389
390
# File 'lib/function/HTMLElement.rb', line 383

def setSelectlistid(name,value,type=1)
	waitExists($ff.select_list(:id,name))
	if	type == 1 then
 $ff.select_list(:id,name).select(value)
	elsif type == 2 then
 $ff.select_list(:id,name).select_value(value)
	end
end

#setTextfieldclass(text1, text2, type = 1) ⇒ Object

Set TextField (Class),
text1 = name,
text2 = String,
type = 1: set(d),
type = 2:value,
type = 3:append



106
107
108
109
110
111
112
113
114
# File 'lib/function/HTMLElement.rb', line 106

def setTextfieldclass(text1,text2,type=1)
	waitExists($ff.text_field(:class,text1))
	if type == 1 then
 $ff.text_field(:class,text1).set(text2)
	elsif type == 2 then
 $ff.text_field(:class,text1).value = text2
	else $ff.text_field(:class,text1).append(text2)
	end
end

#setTextfieldid(text1, text2, type = 1) ⇒ Object

Textfield Set TextField “ID”
type = 1: set(d)
type = 2:value
type = 3:append
type = 4:focus



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/function/HTMLElement.rb', line 72

def setTextfieldid(text1,text2,type=1)
	waitExists($ff.text_field(:id,text1))
	if type == 1 then
 $ff.text_field(:id,text1).set(text2)
	elsif type == 2 then
 $ff.text_field(:id,text1).value = text2
	elsif type == 3 then
 $ff.text_field(:id,text1).append(text2)
	elsif type == 4 then
 $ff.text_field(:id,text1).focus
	end
end

#setTextfieldname(text1, text2, type = 1) ⇒ Object

Set TextField (Name),
text1 = name,
text2 = String,
type = 1: set(d),
type = 2:value,
type = 3:append



90
91
92
93
94
95
96
97
98
# File 'lib/function/HTMLElement.rb', line 90

def setTextfieldname(text1,text2,type=1)
	waitExists($ff.text_field(:name,text1))
	if type == 1 then
 $ff.text_field(:name,text1).set(text2)
	elsif type == 2 then
 $ff.text_field(:name,text1).value = text2
	else $ff.text_field(:name,text1).append(text2)
	end
end

#submitFormid(text) ⇒ Object

Form



138
139
140
141
# File 'lib/function/HTMLElement.rb', line 138

def submitFormid(text)
	waitExists($ff.form(:id,text))
	$ff.form(:id,text).submit
end

#submitFormname(text) ⇒ Object



143
144
145
146
# File 'lib/function/HTMLElement.rb', line 143

def submitFormname(text)
	waitExists($ff.form(:name,text))
	$ff.form(:name,text).submit
end

#verifyTextfieldid(text1, text2) ⇒ Object



116
117
118
119
# File 'lib/function/HTMLElement.rb', line 116

def verifyTextfieldid(text1,text2)
	waitExists( $ff.text_field(:id,text1) )
	assert($ff.text_field(:id, text1).verify_contains(text2) )
end

#verifyTextfieldname(text1, text2) ⇒ Object



121
122
123
124
# File 'lib/function/HTMLElement.rb', line 121

def verifyTextfieldname(text1,text2)
	waitExists( $ff.text_field(:name,text1) )
	assert($ff.text_field(:name, text1).verify_contains(text2) )
end

#wait_ut(text) ⇒ Object

Wait Element show use class Waiter



511
512
513
# File 'lib/function/HTMLElement.rb', line 511

def wait_ut(text)
	Watir::Waiter.wait_until($timeout) { text }
end

#waitFButton(fr, text, typeF, typeB = "id") ⇒ Object

0.0.7



236
237
238
239
240
241
242
243
244
245
246
# File 'lib/function/HTMLElement.rb', line 236

def waitFButton(fr,text,typeF,typeB = "id") #0.0.7
	i = 0
	frame = getFrameid("#{fr}")
	while !$ff.frame(:"#{typeF}",fr).button(:"#{typeB}",text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:"#{typeF}",fr).button(:"#{typeB}",text).exists? )
 end
	end
end

#waitFFilefield(fr, text, typeF, typeT = "id") ⇒ Object

0.0.8



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/function/HTMLElement.rb', line 212

def waitFFilefield(fr,text,typeF,typeT = "id") #0.0.8
	i = 0
	frame = getFrameid("#{fr}")
	while !$ff.frame(:"#{typeF}",fr).file_field(:"#{typeT}",text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:"#{typeF}",fr).file_field(:"#{typeT}",text).exists? )
 end
	end
end

0.0.7



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/function/HTMLElement.rb', line 188

def waitFLink(fr,text,typeF,typeL = "text") #0.0.7
	i = 0
	frame = getFrameid("#{fr}")
	while !$ff.frame(:"#{typeF}",fr).link(:"#{typeL}",text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:"#{typeF}",fr).link(:"#{typeL}",text).exists? )
 end
	end
end

#waitFSpan(fr, text, typeF, typeS = "id") ⇒ Object

0.0.7



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

def waitFSpan(fr,text,typeF,typeS = "id") #0.0.7
	i = 0
	frame = getFrameid("#{fr}")
	while !$ff.frame(:"#{typeF}",fr).span(:"#{typeS}",text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:"#{typeF}",fr).span(:"#{typeS}",text).exists? )
 end
	end
end

#waitFTextfield(fr, text, typeF, typeT = "id") ⇒ Object

0.0.7



200
201
202
203
204
205
206
207
208
209
210
# File 'lib/function/HTMLElement.rb', line 200

def waitFTextfield(fr,text,typeF,typeT = "id") #0.0.7
	i = 0
	frame = getFrameid("#{fr}")
	while !$ff.frame(:"#{typeF}",fr).text_field(:"#{typeT}",text).exists? do
 sleep(1)
 i +=1
 if i>=$timeout then
		assert( $ff.frame(:"#{typeF}",fr).text_field(:"#{typeT}",text).exists? )
 end
	end
end

#xxxObject



14
15
16
# File 'lib/function/HTMLElement.rb', line 14

def xxx
	$ff.close
end