Module: Vapir::Firefox::Container

Includes:
Container
Included in:
PageContainer
Defined in:
lib/vapir-firefox/container.rb

Instance Method Summary collapse

Instance Method Details

#element_by_xpath(xpath) ⇒ Object

Returns the first element that matches the given xpath expression or query.



69
70
71
72
# File 'lib/vapir-firefox/container.rb', line 69

def element_by_xpath(xpath)
  # TODO: move this to common; should work the same for IE 
  base_element_class.factory(element_object_by_xpath(xpath), extra_for_contained)
end

#element_object_by_xpath(xpath) ⇒ Object

Returns the first element object that matches the given XPath query.

Refer: http://developer.mozilla.org/en/docs/DOM:document.evaluate


64
65
66
# File 'lib/vapir-firefox/container.rb', line 64

def element_object_by_xpath(xpath)
  document_object.evaluate(xpath, containing_object, nil, jssh_socket.Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, nil).singleNodeValue
end

#element_objects_by_xpath(xpath) ⇒ Object

Returns array of element objects that match the given XPath query.

Refer: https://developer.mozilla.org/en/DOM/document.evaluate


53
54
55
56
57
58
59
60
# File 'lib/vapir-firefox/container.rb', line 53

def element_objects_by_xpath(xpath)
  elements=[]
  result=document_object.evaluate(xpath, containing_object, nil, jssh_socket.Components.interfaces.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE, nil)
  while element=result.iterateNext
    elements << element.store_rand_object_key(@browser_jssh_objects)
  end
  elements
end

#elements_by_xpath(xpath) ⇒ Object

Returns the array of elements that match the given xpath query.



75
76
77
78
79
80
81
# File 'lib/vapir-firefox/container.rb', line 75

def elements_by_xpath(xpath)
  # TODO/FIX: shouldn't this return an ElementCollection? tests seem to expect it not to, addressing it with 0-based indexing, but that seems insconsistent with everything else. 
  # TODO: move this to common; should work the same for IE 
  element_objects_by_xpath(xpath).map do |element_object|
    base_element_class.factory(element_object, extra_for_contained)
  end
end

#extra_for_containedObject



46
47
48
# File 'lib/vapir-firefox/container.rb', line 46

def extra_for_contained
  default_extra_for_contained.merge(:jssh_socket => jssh_socket)
end