Class: PageObjectify::DOM
- Inherits:
-
Object
- Object
- PageObjectify::DOM
- Includes:
- Logging
- Defined in:
- lib/page-objectify/dom.rb
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.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/page-objectify/dom.rb', line 9 def initialize(html) @html = html @doc = Nokogiri::HTML(@html) @accessors = [] @tags_to_accessors = {} @input_types_to_accessors = {} @types = %i(text password checkbox button image reset submit radio hidden file) @ignored_tags = %i(meta style body script) # that could possibly have an HTML id generate_mapping end |
Instance Method Details
#to_accessors ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/page-objectify/dom.rb', line 21 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 |