Class: IEgrip::HTMLElement

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

Overview

HTML Element

Constant Summary

Constants included from Retry

Retry::RETRY_INTERVAL

Constants inherited from Node

Node::NODETYPE_DIC

Instance Method Summary collapse

Methods included from Retry

#retryCheck, #retryGetTarget

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



578
579
580
581
582
583
584
585
586
# File 'lib/iegrip.rb', line 578

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



523
524
525
526
# File 'lib/iegrip.rb', line 523

def all
  all_element = retyGetElement { @raw_object.all }
  HTMLElementCollection.new(all_element, @ie_obj)
end

#appendChild(newElement) ⇒ Object



566
567
568
# File 'lib/iegrip.rb', line 566

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

#clickObject



514
515
516
517
518
519
520
521
# File 'lib/iegrip.rb', line 514

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

#documentObject



588
589
590
591
# File 'lib/iegrip.rb', line 588

def document
  document = retryGettarget { @raw_object.document }
  document ? Document.new(document, @ie_obj) : nil
end

#export(filename) ⇒ Object



529
530
531
532
533
534
535
536
537
538
# File 'lib/iegrip.rb', line 529

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



544
545
546
# File 'lib/iegrip.rb', line 544

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

#getAttributeNode(attr_name) ⇒ Object



548
549
550
551
# File 'lib/iegrip.rb', line 548

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



562
563
564
# File 'lib/iegrip.rb', line 562

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

#inspectObject



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/iegrip.rb', line 490

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



553
554
555
# File 'lib/iegrip.rb', line 553

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

#removeAttributeNode(attr) ⇒ Object



557
558
559
560
# File 'lib/iegrip.rb', line 557

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

#removeChild(element) ⇒ Object



570
571
572
# File 'lib/iegrip.rb', line 570

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

#replaceChild(newElement, oldElement) ⇒ Object



574
575
576
# File 'lib/iegrip.rb', line 574

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

#setAttributeNode(attribute) ⇒ Object



540
541
542
# File 'lib/iegrip.rb', line 540

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

#tagnameObject



466
467
468
469
470
471
472
# File 'lib/iegrip.rb', line 466

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

#text=(set_text) ⇒ Object



474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/iegrip.rb', line 474

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



506
507
508
# File 'lib/iegrip.rb', line 506

def to_s
  @raw_object.value
end

#valueObject Also known as: text



509
510
511
# File 'lib/iegrip.rb', line 509

def value
  @raw_object.value
end