Module: Qh
- Defined in:
- lib/function/HTMLElement.rb
Overview
B: HTML
Instance Method Summary collapse
- #clearCheckboxid(name) ⇒ Object
- #click_javascript_button ⇒ Object
- #clickalertButtonid(name) ⇒ Object
- #clickalertButtonname(name) ⇒ Object
- #clickalertElement(name) ⇒ Object
- #clickalertImageid(text) ⇒ Object
- #clickalertImagesrc(text) ⇒ Object
- #clickalertLinkclass(name) ⇒ Object
- #clickalertLinkid(name) ⇒ Object
-
#clickalertLinktext(name) ⇒ Object
Alert.
- #clickalertLinktitle(name) ⇒ Object
-
#clickButtonid(text) ⇒ Object
Button.
- #clickButtonname(text) ⇒ Object
-
#clickButtonvalue(text) ⇒ Object
0.0.7.
- #clickDivid(text) ⇒ Object
-
#clickDivtext(text) ⇒ Object
0.0.7.
-
#clickImagesrc(text) ⇒ Object
Image.
- #clickLinkclass(text) ⇒ Object
- #clickLinkhref(name) ⇒ Object
- #clickLinkid(text) ⇒ Object
-
#clickLinktext(text) ⇒ Object
Link.
- #clickLinktitle(text) ⇒ Object
- #clickSpanclass(text) ⇒ Object
-
#clickSpanid(text) ⇒ Object
Span.
-
#clickSpantext(text) ⇒ Object
0.0.7.
- #clickSpanxpath(text) ⇒ Object
-
#fire_event(element, type = 1) ⇒ Object
Javascript event:
type = 1: onMouseOver(d). - #getAttachtitle(title) ⇒ Object
-
#getAttachurl(url) ⇒ Object
Attach 0.0.8.
-
#getDivclass(text) ⇒ Object
Div.
- #getDivid(text) ⇒ Object
- #getFormaction(text) ⇒ Object
- #getFormid(text) ⇒ Object
-
#getFrameid(text) ⇒ Object
Frame.
- #getFrameindex(text) ⇒ Object
- #getFramesrc(text) ⇒ Object
- #getSelectlistid(text) ⇒ Object
-
#getTableid(text) ⇒ Object
Table.
-
#goto(url) ⇒ Object
Goto url.
-
#nwait(n = 1) ⇒ Object
E: Alert.
-
#refresh ⇒ Object
Refresh.
-
#removeAllCookies ⇒ Object
Remove all Cookies on Browser.
-
#setCheckboxid(name) ⇒ Object
Checkbox.
- #setCheckboxname(name) ⇒ Object
- #setCheckboxvalue(name) ⇒ Object
-
#setfilefieldid(text1, text2) ⇒ Object
Filefield.
- #setfilefieldname(text1, text2) ⇒ Object
- #setFTextfieldid(fr, text) ⇒ Object
- #setRadioid(id) ⇒ Object
-
#setRadiovalue(value) ⇒ Object
Radio.
-
#setSelectlistid(name, value, type = 1) ⇒ Object
Select_list:
type = 1: text(d),
type = 2: value,
. -
#setTextfieldclass(text1, text2, type = 1) ⇒ Object
Set TextField (Class),
text1 = name,
text2 = String,
type = 1: set(d),
type = 2:value,
type = 3:append
. -
#setTextfieldid(text1, text2, type = 1) ⇒ Object
Textfield Set TextField “ID”
type = 1: set(d)
type = 2:value
type = 3:append
type = 4:focus
. -
#setTextfieldname(text1, text2, type = 1) ⇒ Object
Set TextField (Name),
text1 = name,
text2 = String,
type = 1: set(d),
type = 2:value,
type = 3:append
. -
#submitFormid(text) ⇒ Object
Form.
- #submitFormname(text) ⇒ Object
- #verifyTextfieldid(text1, text2) ⇒ Object
- #verifyTextfieldname(text1, text2) ⇒ Object
-
#wait_ut(text) ⇒ Object
Wait Element show use class Waiter.
-
#waitFButton(fr, text, typeF, typeB = "id") ⇒ Object
0.0.7.
-
#waitFFilefield(fr, text, typeF, typeT = "id") ⇒ Object
0.0.8.
-
#waitFLink(fr, text, typeF, typeL = "text") ⇒ Object
0.0.7.
-
#waitFSpan(fr, text, typeF, typeS = "id") ⇒ Object
0.0.7.
-
#waitFTextfield(fr, text, typeF, typeT = "id") ⇒ Object
0.0.7.
- #xxx ⇒ Object
Instance Method Details
#clearCheckboxid(name) ⇒ Object
376 377 378 379 |
# File 'lib/function/HTMLElement.rb', line 376 def clearCheckboxid(name) waitExists($ff.checkbox(:id,name)) $ff.checkbox(:id,name).clear end |
#click_javascript_button ⇒ Object
466 467 468 469 470 471 |
# File 'lib/function/HTMLElement.rb', line 466 def () path = File.join(File.dirname(__FILE__), "javascriptPopup.rb") Thread.new { system("ruby \"#{path}\"") } yield sleep(3) end |
#clickalertButtonid(name) ⇒ Object
434 435 436 437 438 |
# File 'lib/function/HTMLElement.rb', line 434 def clickalertButtonid(name) waitExists($ff.(:id,name)) $ff.startClicker("OK") $ff.(:id,name).click end |
#clickalertButtonname(name) ⇒ Object
440 441 442 443 444 |
# File 'lib/function/HTMLElement.rb', line 440 def clickalertButtonname(name) waitExists($ff.(:name,name)) $ff.startClicker("OK") $ff.(:name,name).click end |
#clickalertElement(name) ⇒ Object
446 447 448 449 450 |
# File 'lib/function/HTMLElement.rb', line 446 def clickalertElement(name) waitExists(name) $ff.startClicker("OK") name.click end |
#clickalertImageid(text) ⇒ Object
459 460 461 462 463 464 |
# File 'lib/function/HTMLElement.rb', line 459 def clickalertImageid(text) waitExists( $ff.image(:id,text) ) $ff.startClicker("OK") $ff.image(:id,text).click sleep(2) end |
#clickalertImagesrc(text) ⇒ Object
452 453 454 455 456 457 |
# File 'lib/function/HTMLElement.rb', line 452 def clickalertImagesrc(text) waitExists( $ff.image(:src,text) ) $ff.startClicker("OK") $ff.image(:src,text).click sleep(2) end |
#clickalertLinkclass(name) ⇒ Object
428 429 430 431 432 |
# File 'lib/function/HTMLElement.rb', line 428 def clickalertLinkclass(name) waitExists($ff.link(:class,name)) $ff.startClicker("OK") $ff.link(:class,name).click end |
#clickalertLinkid(name) ⇒ Object
416 417 418 419 420 |
# File 'lib/function/HTMLElement.rb', line 416 def clickalertLinkid(name) waitExists($ff.link(:id,name)) $ff.startClicker("OK") $ff.link(:id,name).click end |
#clickalertLinktext(name) ⇒ Object
Alert
410 411 412 413 414 |
# File 'lib/function/HTMLElement.rb', line 410 def clickalertLinktext(name) waitExists($ff.link(:text,name)) $ff.startClicker("OK") $ff.link(:text,name).click end |
#clickalertLinktitle(name) ⇒ Object
422 423 424 425 426 |
# File 'lib/function/HTMLElement.rb', line 422 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.(:id,text)) $ff.(:id,text).click end |
#clickButtonname(text) ⇒ Object
49 50 51 52 |
# File 'lib/function/HTMLElement.rb', line 49 def clickButtonname(text) waitExists($ff.(:name,text)) $ff.(: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.(:value,text)) $ff.(:value,text).click end |
#clickDivid(text) ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/function/HTMLElement.rb', line 269 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
284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/function/HTMLElement.rb', line 284 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
330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/function/HTMLElement.rb', line 330 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
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/function/HTMLElement.rb', line 300 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
315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/function/HTMLElement.rb', line 315 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
345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/function/HTMLElement.rb', line 345 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)
504 505 506 507 508 509 |
# File 'lib/function/HTMLElement.rb', line 504 def fire_event(element,type = 1) waitExists(element) if type == 1 then element.fire_event("onMouseOver") end end |
#getAttachtitle(title) ⇒ Object
492 493 494 495 496 497 498 499 500 |
# File 'lib/function/HTMLElement.rb', line 492 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
482 483 484 485 486 487 488 489 490 |
# File 'lib/function/HTMLElement.rb', line 482 def getAttachurl(url) begin ff1 = $ff.attach(:url,url) rescue Exception => e sleep(1) retry end return ff1 end |
#getDivclass(text) ⇒ Object
Div
257 258 259 260 261 |
# File 'lib/function/HTMLElement.rb', line 257 def getDivclass(text) waitExists( $ff.div(:class,text) ) nwait(1) return $ff.div(:class,text) end |
#getDivid(text) ⇒ Object
263 264 265 266 267 |
# File 'lib/function/HTMLElement.rb', line 263 def getDivid(text) waitExists( $ff.div(:id,text) ) nwait(2) return $ff.div(:id,text) end |
#getFormaction(text) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/function/HTMLElement.rb', line 154 def getFormaction(text) waitExists($ff.form(:action,text)) nwait(1) sleep(1) return $ff.form(:action,text) end |
#getFormid(text) ⇒ Object
149 150 151 152 |
# File 'lib/function/HTMLElement.rb', line 149 def getFormid(text) waitExists($ff.form(:id,text)) return $ff.form(:id,text) end |
#getFrameid(text) ⇒ Object
Frame
162 163 164 165 |
# File 'lib/function/HTMLElement.rb', line 162 def getFrameid(text) waitExists($ff.frame(:id,text)) return $ff.frame(:id,text) end |
#getFrameindex(text) ⇒ Object
167 168 169 170 |
# File 'lib/function/HTMLElement.rb', line 167 def getFrameindex(text) waitExists($ff.frame(:index,text)) return $ff.frame(:index,text) end |
#getFramesrc(text) ⇒ Object
172 173 174 175 |
# File 'lib/function/HTMLElement.rb', line 172 def getFramesrc(text) waitExists($ff.frame(:src,text)) return $ff.frame(:src,text) end |
#getSelectlistid(text) ⇒ Object
393 394 395 396 397 |
# File 'lib/function/HTMLElement.rb', line 393 def getSelectlistid(text) waitExists($ff.select_list(:id,text)) nwait(1) return $ff.select_list(:id,text) end |
#getTableid(text) ⇒ Object
Table
250 251 252 253 254 |
# File 'lib/function/HTMLElement.rb', line 250 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
475 476 477 478 479 |
# File 'lib/function/HTMLElement.rb', line 475 def nwait(n=1) for i in 1..n $ff.wait end end |
#refresh ⇒ Object
Refresh
9 10 11 |
# File 'lib/function/HTMLElement.rb', line 9 def refresh $ff.refresh end |
#removeAllCookies ⇒ Object
Remove all Cookies on Browser
517 518 519 520 |
# File 'lib/function/HTMLElement.rb', line 517 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
361 362 363 364 |
# File 'lib/function/HTMLElement.rb', line 361 def setCheckboxid(name) waitExists($ff.checkbox(:id,name)) $ff.checkbox(:id,name).set end |
#setCheckboxname(name) ⇒ Object
366 367 368 369 |
# File 'lib/function/HTMLElement.rb', line 366 def setCheckboxname(name) waitExists($ff.checkbox(:name,name)) $ff.checkbox(:name,name).set end |
#setCheckboxvalue(name) ⇒ Object
371 372 373 374 |
# File 'lib/function/HTMLElement.rb', line 371 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
177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/function/HTMLElement.rb', line 177 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
405 406 407 408 |
# File 'lib/function/HTMLElement.rb', line 405 def setRadioid(id) waitExists($ff.radio(:id,id)) $ff.radio(:id,id).set end |
#setRadiovalue(value) ⇒ Object
Radio
400 401 402 403 |
# File 'lib/function/HTMLElement.rb', line 400 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,
384 385 386 387 388 389 390 391 |
# File 'lib/function/HTMLElement.rb', line 384 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 |
#submitFormname(text) ⇒ Object
144 145 146 147 |
# File 'lib/function/HTMLElement.rb', line 144 def submitFormname(text) waitExists($ff.form(:name,text)) $ff.form(:name,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
512 513 514 |
# File 'lib/function/HTMLElement.rb', line 512 def wait_ut(text) Watir::Waiter.wait_until($timeout) { text } end |
#waitFButton(fr, text, typeF, typeB = "id") ⇒ Object
0.0.7
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/function/HTMLElement.rb', line 237 def waitFButton(fr,text,typeF,typeB = "id") #0.0.7 i = 0 frame = getFrameid("#{fr}") while !$ff.frame(:"#{typeF}",fr).(:"#{typeB}",text).exists? do sleep(1) i +=1 if i>=$timeout then assert( $ff.frame(:"#{typeF}",fr).(:"#{typeB}",text).exists? ) end end end |
#waitFFilefield(fr, text, typeF, typeT = "id") ⇒ Object
0.0.8
213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/function/HTMLElement.rb', line 213 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 |
#waitFLink(fr, text, typeF, typeL = "text") ⇒ Object
0.0.7
189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/function/HTMLElement.rb', line 189 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
225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/function/HTMLElement.rb', line 225 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
201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/function/HTMLElement.rb', line 201 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 |
#xxx ⇒ Object
13 14 15 |
# File 'lib/function/HTMLElement.rb', line 13 def xxx $ff.close end |