Skip to content

dom tree leaves end up on the wrong branches #76

@patrickhno

Description

@patrickhno

I had to add this to our massive project to make it work with the Akephalos driver.
I guess this most likely will need to be passed on to some of the gems deeper down.
I would guess htmlunit passes pure html to nokogiri so the htmlunit side of things should be fine I guess.
What really bugs me is that this works fine with the selenium driver.

I think I can provide the raw html for a page that needs this workaround upon request.

This function seem to suffer a lot on pages with massive tables.

# Workaraound for a bug in the Akephalos driver
# Akephalos some times makes:
#   <tr>
#     <td><..><..><..></td>
#   </tr>
# into:
#   <tr>
#     <td><..></td>
#     <..>
#     <..>
#   </tr>
def self.akephalos_bug_workaround row
  ret = row.dup
  if row.name == 'tr'
    if row.children.size > 0 && row.children[0].respond_to?(:name) && row.children[0].name == 'td'
      ret.children = Nokogiri::XML::NodeSet.new(row.document)
      row.children.each do |td|
        if td.name == 'td'
          ret << td.dup
        else
          ret.children.last << td.dup
        end
      end
    end
  end
  ret
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions