class Lebowski::Foundation::DOMElement

Represents a DOM element. Primarily used by the CoreQuery object. Use this object to acquire details about a given element.

Attributes

handle[R]
index[R]

Public Class Methods

new(handle, index, driver) click to toggle source

Create an instance.

@param handle {Number} the handle used by a core query object @param index {Number} the index to the element in the core query object @param driver {object} used to communicate with the selenium server

# File lib/lebowski/foundation/dom_element.rb, line 26
def initialize(handle, index, driver)
  @handle = handle
  @index = index
  @driver = driver
end

Public Instance Methods

action_locator_args() click to toggle source
# File lib/lebowski/foundation/dom_element.rb, line 32
def action_locator_args()
  return [@handle, @index]
end
action_target() click to toggle source
# File lib/lebowski/foundation/dom_element.rb, line 36
def action_target()
  return :core_query_element
end
attribute(val) click to toggle source

Used to get the value of specific attribute belonging to the element

@param val {String} the name of the attribute on the element

# File lib/lebowski/foundation/dom_element.rb, line 98
def attribute(val)
  return @driver.get_sc_core_query_element_attribute(@handle, @index, val)
end
classes() click to toggle source

Returns the classes of the element as a string

# File lib/lebowski/foundation/dom_element.rb, line 43
def classes()
  return @driver.get_sc_core_query_element_classes(@handle, @index)
end
has_class?(klass) click to toggle source

Checks if this DOM element has a given CSS class

@return true if the element has the class, otherwise false is returned

# File lib/lebowski/foundation/dom_element.rb, line 52
def has_class?(klass)
  return has_classes? [klass]
end
has_classes?(klasses) click to toggle source

Checks if this DOM element has a set of given CSS classes

@return true if the element has all teh given classes, otherwise false is returned

# File lib/lebowski/foundation/dom_element.rb, line 61
def has_classes?(klasses)
  klasses1 = klasses.kind_of?(Array) ? klasses : klasses.split
  klasses2 = classes.split
  for k in klasses1 do
    if not klasses2.find_index(k)
      return false
    end
  end
  return true
end
height() click to toggle source

@override Lebowski::Foundation::Mixins::PositionedElement#height

# File lib/lebowski/foundation/dom_element.rb, line 113
def height()
  return @driver.get_sc_element_height(action_target, *action_locator_args)
end
html() click to toggle source

Returns the raw HTML of this element as a string

# File lib/lebowski/foundation/dom_element.rb, line 75
def html()
  return @driver.get_sc_core_query_element_html(@handle, @index)
end
method_missing(sym, *args, &block) click to toggle source

If the method can not be found then assume we are trying to get the value of an attribute on the element.

Calls superclass method
# File lib/lebowski/foundation/dom_element.rb, line 121
def method_missing(sym, *args, &block)
  return attribute(sym.to_s) if not sym.to_s =~ /\?$/
  super
end
position() click to toggle source

@override Lebowski::Foundation::Mixins::PositionedElement#position

# File lib/lebowski/foundation/dom_element.rb, line 103
def position()
  return @driver.get_sc_element_window_position(action_target, *action_locator_args)
end
tag() click to toggle source

Returns the HTML tag of this element (e.g. IMG, A, DIV)

# File lib/lebowski/foundation/dom_element.rb, line 89
def tag()
  return @driver.get_sc_core_query_element_tag(@handle, @index)
end
text() click to toggle source

Returns the text of this element

# File lib/lebowski/foundation/dom_element.rb, line 82
def text()
  return @driver.get_sc_core_query_element_text(@handle, @index)
end
width() click to toggle source

@override Lebowski::Foundation::Mixins::PositionedElement#width

# File lib/lebowski/foundation/dom_element.rb, line 108
def width()
  return @driver.get_sc_element_width(action_target, *action_locator_args)
end