class Arachni::Element::GenericDOM
Represents generic DOM
elements, basically anything that can be part of a {Page::DOM::Transition}, and is used just for wrapping them in something that presents an interface compatible with the other, more traditional, elements when logging {Issue issues}.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Attributes
@return [Page::DOM::Transition]
Public Class Methods
@param [Hash] data
Data returned from {#to_rpc_data}.
@return [GenericDOM]
Restored element.
# File lib/arachni/element/generic_dom.rb, line 110 def from_rpc_data( data ) instance = allocate data.each do |name, value| value = case name when 'transition' Arachni::Page::DOM::Transition.from_rpc_data( value ) when 'initialization_options' value = value.is_a?( Hash ) ? value.my_symbolize_keys(false) : value value[:transition] = Arachni::Page::DOM::Transition.from_rpc_data( value[:transition] ) value else value end instance.instance_variable_set( "@#{name}", value ) end instance end
@param [Hash] options @option options [String] :url @option options [Page::DOM::Transition] :transition
Arachni::Element::Capabilities::WithSource::new
# File lib/arachni/element/generic_dom.rb, line 29 def initialize( options = {} ) super @transition = options[:transition] fail 'Missing element locator.' if !@transition self.source = element.to_s @initialization_options = options end
Public Instance Methods
@return [Hash]
Element attributes.
@see Browser::Element::Locator#attributes
# File lib/arachni/element/generic_dom.rb, line 60 def attributes element.attributes end
@return [Browser::Element::Locator]
Locator for the logged element.
@see Page::DOM::Transition#element
# File lib/arachni/element/generic_dom.rb, line 52 def element transition.element end
@return [Symbol]
DOM event.
@see Page::DOM::Transition#event
# File lib/arachni/element/generic_dom.rb, line 43 def event transition.event end
@return [String, nil]
Name or ID from the {#attributes} if any are defined.
# File lib/arachni/element/generic_dom.rb, line 66 def name attributes['name'] || attributes['id'] end
@return [Hash]
Arachni::Element::Capabilities::WithSource#to_h
# File lib/arachni/element/generic_dom.rb, line 80 def to_h super.merge( transition: transition.to_h.tap { |h| h[:element] = h[:element].to_h } ) end
@return [Hash]
Data representing the state and data of the element to be passed to {.from_rpc_data}.
Arachni::Element::Capabilities::WithSource#to_rpc_data
# File lib/arachni/element/generic_dom.rb, line 95 def to_rpc_data data = super data['initialization_options'] = data['initialization_options'].dup data['initialization_options']['transition'] = data['initialization_options']['transition'].to_rpc_data data end
@return [Symbol]
Element tag name.
@see Browser::Element::Locator#tag_name
# File lib/arachni/element/generic_dom.rb, line 88 def type element.tag_name end
@return [String, nil]
Element value (in case of an input) from the {#transition} {Page::DOM::Transition#options}.
# File lib/arachni/element/generic_dom.rb, line 74 def value transition.options[:value] end