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
Public Class Methods
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
# File lib/lebowski/foundation/dom_element.rb, line 32 def action_locator_args() return [@handle, @index] end
# File lib/lebowski/foundation/dom_element.rb, line 36 def action_target() return :core_query_element end
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
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
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
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
@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
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
If the method can not be found then assume we are trying to get the value of an attribute on the element.
# 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
@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
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
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
@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