class AutomationObject::Driver::NokogiriAdapter::Element
Element
for nokogiri Conforms to Element
interface for an XML source using Nokogiri
Public Class Methods
@param [AutomationObject::Driver::NokogiriAdapter::Driver] driver @param [Nokogiri::XML::Node] element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 14 def initialize(driver, element) @driver = driver @subject = element end
Public Instance Methods
Set or Get attribute @param key [String] key of element @param value [String, nil] set value or leave blank @return [String, nil]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 23 def attribute(key, value = nil) @subject[key] = value if value @subject[key] end
@return [BoxCoordinates] :x1, :x2, :y1, :y2 coordinates of a box
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 125 def box_coordinates BoxCoordinates.new(x1: 0, y1: 0, x2: 0, y2: 0) end
Clear the element field @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 60 def clear @subject['value'] = '' end
Perform a click action on the element @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 92 def click @driver.session.request(:get, href, {}, attribute('target') == '_blank') if href && @subject['tag'] == 'a' # In case it's a button inside the form submit if find_form(@subject) end
@param _second_element_object [Object] element to compare to @param _collision_tolerance [Numeric, FalseClass] pixel tolerance of collisions @return [Boolean] element collides with other
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 132 def collides_with_element?(_second_element_object, _collision_tolerance = false) false end
Content of element @return [String, nil]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 46 def content @subject.content end
@return [Point] :x, :y coordinates
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 120 def element_center Point.new(x: 0, y: 0) end
@return [Numeric] height of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 115 def height 0 end
Hover over element @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 138 def hover; end
@return [String] href of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 34 def href @subject['href'] end
@return [String] id of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 29 def id @subject['id'] end
@return [Boolean]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 68 def invisible?; end
Get the location @return [Point]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 72 def location; end
Scroll the element into view @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 88 def scroll_into_view; end
Type into an element @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 52 def send_keys(string) @subject['value'] = @subject[key] + string if @subject['value'].is_a?(String) @subject['value'] = value end
Get the size of an element @return [Dimension]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 76 def size; end
Perform a submit action on an element @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 80 def submit form_element = find_form(@subject) raise NoSuchElementError unless form_element @driver.session.request(form.request_method, form.url, form.params, form_element.new_window?) end
Helper method to switch to this element's iframe @return [void]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 142 def switch_to_iframe # TODO: finish end
Text of element @return [String, nil]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 40 def text @subject.content end
@return [Boolean]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 65 def visible?; end
@return [Numeric] width of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 110 def width 0 end
@return [Numeric] x position of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 100 def x 0 end
@return [Numeric] y position of element
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 105 def y 0 end
Private Instance Methods
@return [AutomationObject::Driver:NokogiriAdapter::Form]
# File lib/automation_object/driver/nokogiri_adapter/element.rb, line 149 def find_form(element) return nil unless element return AutomationObject::Driver::NokogiriAdapter::Form.new(element) if element.name == 'form' find_form(element.parent) end