Created
January 13, 2010 19:06
-
-
Save darrinholst/276478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
html = <<EOS | |
<html> | |
<head> | |
<title>test</title> | |
</head> | |
<body> | |
<table id="some_id"> | |
<thead> | |
<tr><th>header</th></tr> | |
</thead> | |
<tbody> | |
<tr><td>row 1</td></tr> | |
<tr><td>row 2</td></tr> | |
<tr><td>row 3</td></tr> | |
</tbody> | |
</table> | |
</body> | |
</html> | |
EOS | |
expected = 4 | |
count = 0 | |
while true | |
count += 1 | |
rows = Nokogiri::HTML(html).search('table#some_id tr').size | |
puts "got #{rows} rows, expected #{expected} on try #{count}" unless rows == expected | |
break unless rows == expected | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment