Class: IEgrip::HTMLElement

Inherits:
Node show all
Includes:
ElementChild, ElementParent, GetElements
Defined in:
lib/iegrip.rb

Overview

HTML Element

Constant Summary

Constants inherited from Node

Node::NODETYPE_DIC

Instance Method Summary collapse

Methods included from GetElements

#getElementByName, #getElementByText, #getElementByTitle, #getElementByValue, #getElementsByName, #getElementsByTagName, #getElementsByText, #getElementsByTitle, #getElementsByValue

Methods included from ElementChild

#childElements, #childNodes, #contains, #firstChild, #hasChildElements, #hasChildNodes, #isEqualNode, #lastChild, #nextSibling, #previousSibling, #struct

Methods included from ElementParent

#getParentForm, #parentElement, #parentNode

Methods inherited from Node

#nodeName, #nodeType, #nodeTypeName

Methods inherited from GripWrapper

#initialize, #ole_methodNames, #raw

Constructor Details

This class inherits a constructor from IEgrip::GripWrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class IEgrip::GripWrapper

Instance Method Details

#addElement(new_element) ⇒ Object



504
505
506
507
508
509
510
511
512
# File 'lib/iegrip.rb', line 504

def addElement(new_element)
  parent = self.parentElement
  next_element = self.nextSibling
  if next_element
    parent.insertBefore(new_element, next_element)
  else
    parent.appendChild(new_element)
  end
end

#allObject



450
451
452
# File 'lib/iegrip.rb', line 450

def all
  HTMLElementCollection.new(@raw_object.all, @ie_obj)
end

#appendChild(newElement) ⇒ Object



492
493
494
# File 'lib/iegrip.rb', line 492

def appendChild(newElement)
  @raw_object.appendChild(toRaw(newElement))
end

#clickObject



440
441
442
443
444
445
446
447
448
# File 'lib/iegrip.rb', line 440

def click
  @ie_obj.before_wait()
  if @ie_obj.version >= 10
    @raw_object.click(false)
  else
    @raw_object.click
  end
  @ie_obj.wait_stable()
end

#documentObject



514
515
516
# File 'lib/iegrip.rb', line 514

def document
  Document.new(@raw_object.document, @ie_obj)
end

#export(filename) ⇒ Object



455
456
457
458
459
460
461
462
463
464
# File 'lib/iegrip.rb', line 455

def export(filename)
  case self.tagName.downcase
  when "img"
    @ie_obj.export(self.src, filename)
  when "a"
    @ie_obj.export(self.href, filename)
  else
    raise "export() is not support."
  end
end

#getAttribute(attr_name) ⇒ Object



470
471
472
# File 'lib/iegrip.rb', line 470

def getAttribute(attr_name)
  @raw_object.getAttribute(attr_name)
end

#getAttributeNode(attr_name) ⇒ Object



474
475
476
477
# File 'lib/iegrip.rb', line 474

def getAttributeNode(attr_name)
  raw_attr = @raw_object.getAttributeNode(attr_name)
  raw_attr ? Attr.new(raw_attr, @ie_obj) : nil
end

#insertBefore(newElement, anchor_element = nil) ⇒ Object



488
489
490
# File 'lib/iegrip.rb', line 488

def insertBefore(newElement, anchor_element=nil)
  @raw_object.insertBefore(toRaw(newElement), toRaw(anchor_element))
end

#inspectObject



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/iegrip.rb', line 416

def inspect()
  case tagName
  when "SELECT"
    innerHTML = replace_cr_code(self.innerHTML)
    "<#{self.class}, TAG:#{tagName}, [#{self.innerHTML}]"
  when "INPUT", "IMG", "A"
    outerHTML = replace_cr_code(self.outerHTML)
    "<#{self.class}, TAG:#{tagName}, [#{self.outerHTML}]"
  when "TR", "TD"
    innerText = replace_cr_code(self.innerText)
    "<#{self.class}, TAG:#{tagName}, [#{innerText}]"
  else
    "<#{self.class}, TAG:#{tagName}>"
  end
end

#removeAttribute(attr_name) ⇒ Object



479
480
481
# File 'lib/iegrip.rb', line 479

def removeAttribute(attr_name)
  @raw_object.removeAttribute(attr_name)
end

#removeAttributeNode(attr) ⇒ Object



483
484
485
486
# File 'lib/iegrip.rb', line 483

def removeAttributeNode( attr )
  raw_attr = @raw_object.removeAttributeNode( toRaw(attr) )
  raw_attr ? Attr.new(raw_attr, @ie_obj) : nil
end

#removeChild(element) ⇒ Object



496
497
498
# File 'lib/iegrip.rb', line 496

def removeChild(element)
  @raw_object.removeChild(toRaw(element))
end

#replaceChild(newElement, oldElement) ⇒ Object



500
501
502
# File 'lib/iegrip.rb', line 500

def replaceChild(newElement, oldElement)
  @raw_object.replaceChild(toRaw(newElement), toRaw(oldElement))
end

#setAttributeNode(attribute) ⇒ Object



466
467
468
# File 'lib/iegrip.rb', line 466

def setAttributeNode(attribute)
  @raw_object.setAttributeNode(toRaw(attribute));
end

#tagnameObject



392
393
394
395
396
397
398
# File 'lib/iegrip.rb', line 392

def tagname
  if self.nodeType == 8
    "comment"
  else
    @raw_object.tagName.downcase
  end
end

#text=(set_text) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/iegrip.rb', line 400

def text=(set_text)
  case self.tagname
  when "select"
    option_list = elements("OPTION")
    option_list.each {|option_element|
      if option_element.innerText == set_text
        option_element.selected = true
        break
      end
    }
  else
    @raw_object.value = set_text
  end
end

#to_sObject



432
433
434
# File 'lib/iegrip.rb', line 432

def to_s
  @raw_object.value
end

#valueObject Also known as: text



435
436
437
# File 'lib/iegrip.rb', line 435

def value
  @raw_object.value
end