Module: Qh

Defined in:
lib/function/HTMLElement.rb

Overview

B: HTML

Instance Method Summary collapse

Instance Method Details

#clearCheckboxid(name) ⇒ Object



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

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

#click_javascript_buttonObject



462
463
464
465
466
467
# File 'lib/function/HTMLElement.rb', line 462

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

#clickalertButtonid(name) ⇒ Object



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

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

#clickalertButtonname(name) ⇒ Object



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

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

#clickalertElement(name) ⇒ Object



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

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

#clickalertImageid(text) ⇒ Object



455
456
457
458
459
460
# File 'lib/function/HTMLElement.rb', line 455

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

#clickalertImagesrc(text) ⇒ Object



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

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

#clickalertLinkclass(name) ⇒ Object



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

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

#clickalertLinkid(name) ⇒ Object



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

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

#clickalertLinktext(name) ⇒ Object

Alert



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

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

#clickalertLinktitle(name) ⇒ Object



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

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

#clickButtonid(text) ⇒ Object

Button



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

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

#clickButtonname(text) ⇒ Object



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

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

#clickButtonvalue(text) ⇒ Object

0.0.7



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

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

#clickDivid(text) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/function/HTMLElement.rb', line 265

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



280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/function/HTMLElement.rb', line 280

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



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

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

#clickLinkclass(text) ⇒ Object



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

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

#clickLinkhref(name) ⇒ Object



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

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

#clickLinkid(text) ⇒ Object



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

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

#clickLinktext(text) ⇒ Object

Link



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

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

#clickLinktitle(text) ⇒ Object



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

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

#clickSpanclass(text) ⇒ Object



326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/function/HTMLElement.rb', line 326

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



296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/function/HTMLElement.rb', line 296

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



311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/function/HTMLElement.rb', line 311

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



341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/function/HTMLElement.rb', line 341

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)



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

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

#getAttachtitle(title) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/function/HTMLElement.rb', line 496

def getAttachtitle(title)
	i = 0
	begin
 ff1 = $ff.attach(:title,title)
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i <= 20 then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
	if i <= 20 then
 return ff1
	end
end

#getAttachurl(url) ⇒ Object

Attach



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/function/HTMLElement.rb', line 478

def getAttachurl(url)
	i = 0
	begin
 ff1 = $ff.attach(:url,url)
	rescue Exception => e
 sleep(1)
 i = i + 1
 if i <= $timeout then retry
 else
		puts e.exception
		#~ puts e.backtrace
 end
	end
	if i <= $timeout then
 return ff1
	end
end

#getDivclass(text) ⇒ Object

Div



253
254
255
256
257
# File 'lib/function/HTMLElement.rb', line 253

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

#getDivid(text) ⇒ Object



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

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

#getFormaction(text) ⇒ Object



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

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

#getFormid(text) ⇒ Object



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

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

#getFrameid(text) ⇒ Object

Frame



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

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

#getFrameindex(text) ⇒ Object



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

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

#getFramesrc(text) ⇒ Object



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

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

#getSelectlistid(text) ⇒ Object



389
390
391
392
393
# File 'lib/function/HTMLElement.rb', line 389

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

#getTableid(text) ⇒ Object

Table



246
247
248
249
250
# File 'lib/function/HTMLElement.rb', line 246

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

#goto(url) ⇒ Object

Goto url



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

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

#nwait(n = 1) ⇒ Object

E: Alert



471
472
473
474
475
# File 'lib/function/HTMLElement.rb', line 471

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

#refreshObject

Refresh



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

def refresh
	$ff.refresh
end

#setCheckboxid(name) ⇒ Object

Checkbox



357
358
359
360
# File 'lib/function/HTMLElement.rb', line 357

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

#setCheckboxname(name) ⇒ Object



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

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

#setCheckboxvalue(name) ⇒ Object



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

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

#setfilefieldid(text1, text2) ⇒ Object

Filefield



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

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

#setfilefieldname(text1, text2) ⇒ Object



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

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

#setFTextfieldid(fr, text) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
# File 'lib/function/HTMLElement.rb', line 172

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



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

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

#setRadiovalue(value) ⇒ Object

Radio



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

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,



380
381
382
383
384
385
386
387
# File 'lib/function/HTMLElement.rb', line 380

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



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

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



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

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



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

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

#verifyTextfieldid(text1, text2) ⇒ Object



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

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

#verifyTextfieldname(text1, text2) ⇒ Object



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

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



524
525
526
# File 'lib/function/HTMLElement.rb', line 524

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

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

0.0.7



233
234
235
236
237
238
239
240
241
242
243
# File 'lib/function/HTMLElement.rb', line 233

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

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

0.0.7



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/function/HTMLElement.rb', line 209

def waitFFilefied(fr,text,typeF,typeT = "id") #0.0.7
	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



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/function/HTMLElement.rb', line 184

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



221
222
223
224
225
226
227
228
229
230
231
# File 'lib/function/HTMLElement.rb', line 221

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



196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/function/HTMLElement.rb', line 196

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
 puts i
	end
end

#xxxObject



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

def xxx
	$ff.close
end