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



377
378
379
380
# File 'lib/function/HTMLElement.rb', line 377

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

#click_javascript_buttonObject



467
468
469
470
471
472
# File 'lib/function/HTMLElement.rb', line 467

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

#clickalertButtonid(name) ⇒ Object



435
436
437
438
439
# File 'lib/function/HTMLElement.rb', line 435

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

#clickalertButtonname(name) ⇒ Object



441
442
443
444
445
# File 'lib/function/HTMLElement.rb', line 441

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

#clickalertElement(name) ⇒ Object



447
448
449
450
451
# File 'lib/function/HTMLElement.rb', line 447

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

#clickalertImageid(text) ⇒ Object



460
461
462
463
464
465
# File 'lib/function/HTMLElement.rb', line 460

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

#clickalertImagesrc(text) ⇒ Object



453
454
455
456
457
458
# File 'lib/function/HTMLElement.rb', line 453

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

#clickalertLinkclass(name) ⇒ Object



429
430
431
432
433
# File 'lib/function/HTMLElement.rb', line 429

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

#clickalertLinkid(name) ⇒ Object



417
418
419
420
421
# File 'lib/function/HTMLElement.rb', line 417

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

#clickalertLinktext(name) ⇒ Object

Alert



411
412
413
414
415
# File 'lib/function/HTMLElement.rb', line 411

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

#clickalertLinktitle(name) ⇒ Object



423
424
425
426
427
# File 'lib/function/HTMLElement.rb', line 423

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



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

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



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

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



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

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



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

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



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

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



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

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)



505
506
507
508
509
510
# File 'lib/function/HTMLElement.rb', line 505

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

#getAttachtitle(title) ⇒ Object



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

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



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

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

#getDivclass(text) ⇒ Object

Div



258
259
260
261
262
# File 'lib/function/HTMLElement.rb', line 258

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

#getDivid(text) ⇒ Object



264
265
266
267
268
# File 'lib/function/HTMLElement.rb', line 264

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

#getFormaction(text) ⇒ Object



155
156
157
158
159
160
# File 'lib/function/HTMLElement.rb', line 155

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

#getFormid(text) ⇒ Object



150
151
152
153
# File 'lib/function/HTMLElement.rb', line 150

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

#getFrameid(text) ⇒ Object

Frame



163
164
165
166
# File 'lib/function/HTMLElement.rb', line 163

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

#getFrameindex(text) ⇒ Object



168
169
170
171
# File 'lib/function/HTMLElement.rb', line 168

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

#getFramesrc(text) ⇒ Object



173
174
175
176
# File 'lib/function/HTMLElement.rb', line 173

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

#getSelectlistid(text) ⇒ Object



394
395
396
397
398
# File 'lib/function/HTMLElement.rb', line 394

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

#getTableid(text) ⇒ Object

Table



251
252
253
254
255
# File 'lib/function/HTMLElement.rb', line 251

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



476
477
478
479
480
# File 'lib/function/HTMLElement.rb', line 476

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



518
519
520
521
# File 'lib/function/HTMLElement.rb', line 518

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



362
363
364
365
# File 'lib/function/HTMLElement.rb', line 362

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

#setCheckboxname(name) ⇒ Object



367
368
369
370
# File 'lib/function/HTMLElement.rb', line 367

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

#setCheckboxvalue(name) ⇒ Object



372
373
374
375
# File 'lib/function/HTMLElement.rb', line 372

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

#setfilefieldid(text1, text2) ⇒ Object

Filefield



129
130
131
132
# File 'lib/function/HTMLElement.rb', line 129

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

#setfilefieldname(text1, text2) ⇒ Object



134
135
136
137
# File 'lib/function/HTMLElement.rb', line 134

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

#setFTextfieldid(fr, text) ⇒ Object



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

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



406
407
408
409
# File 'lib/function/HTMLElement.rb', line 406

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

#setRadiovalue(value) ⇒ Object

Radio



401
402
403
404
# File 'lib/function/HTMLElement.rb', line 401

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,



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

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



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

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
99
# 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



140
141
142
143
# File 'lib/function/HTMLElement.rb', line 140

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

#submitFormname(text) ⇒ Object



145
146
147
148
# File 'lib/function/HTMLElement.rb', line 145

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

#verifyTextfieldid(text1, text2) ⇒ Object



118
119
120
121
# File 'lib/function/HTMLElement.rb', line 118

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

#verifyTextfieldname(text1, text2) ⇒ Object



123
124
125
126
# File 'lib/function/HTMLElement.rb', line 123

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



513
514
515
# File 'lib/function/HTMLElement.rb', line 513

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

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

0.0.7



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

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



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

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



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

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



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

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



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

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