Skip to content

Instantly share code, notes, and snippets.

@biot023
Created February 4, 2010 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biot023/294797 to your computer and use it in GitHub Desktop.
Save biot023/294797 to your computer and use it in GitHub Desktop.
# My page wrote alert p elements to the body (due to a hack to allow alerts in my app that wouldn't upset cuke flow),
# but iterating through them with all() didn't work, as when I called the text() method, it returned nil, even though
# there was text there -- so I used this instead.
#
# Get all alert p's off the page and dump their contents.
#
def _dump_alerts
doc = Nokogiri.HTML( page.body )
doc.xpath( "//p[@class = 'alert']" ).reverse.each do |p|
puts p.content
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment