Class: PageObjectify::DOM
- Inherits:
-
Object
- Object
- PageObjectify::DOM
- Includes:
- Logging
- Defined in:
- lib/page-objectify/dom.rb
Instance Attribute Summary collapse
-
#input_types_to_accessors ⇒ Object
readonly
Returns the value of attribute input_types_to_accessors.
-
#tags_to_accessors ⇒ Object
readonly
Returns the value of attribute tags_to_accessors.
Instance Method Summary collapse
-
#initialize(html) ⇒ DOM
constructor
A new instance of DOM.
- #to_accessors ⇒ Object
Methods included from Logging
Constructor Details
#initialize(html) ⇒ DOM
Returns a new instance of DOM.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/page-objectify/dom.rb', line 11 def initialize(html) @html = html @doc = Nokogiri::HTML(@html) @accessors = [] = {} @input_types_to_accessors = {} @types = i(text password checkbox image reset submit radio hidden file) = i( style body script thead tbody) # that could possibly have an HTML id generate_mapping end |
Instance Attribute Details
#input_types_to_accessors ⇒ Object (readonly)
Returns the value of attribute input_types_to_accessors.
9 10 11 |
# File 'lib/page-objectify/dom.rb', line 9 def input_types_to_accessors @input_types_to_accessors end |
#tags_to_accessors ⇒ Object (readonly)
Returns the value of attribute tags_to_accessors.
9 10 11 |
# File 'lib/page-objectify/dom.rb', line 9 def end |
Instance Method Details
#to_accessors ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/page-objectify/dom.rb', line 23 def to_accessors # Grab only nodes with non-empty HTML id @doc.xpath("//*[@id!='']").each do |node| accessor = accessor_for(node) @accessors << { accessor: accessor, id: node.attributes["id"].to_s } if accessor end logger.info "DOM nodes convertable to PageObject::Accessors: #{@accessors.count}" @accessors end |