Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Simple script to post answer for http://stackoverflow.com/q/14527556/841064

View test.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<table>
<tr>
<td>Sara</td>
<td>2.3</td>
<td>4.3</td>
</tr>
<tr>
<td>Mike</td>
<td>4.5</td>
<td>1.1</td>
</tr>
<tr>
<td>Alex</td>
<td>1</td>
<td>8</td>
</tr>
</table>
View test.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
require 'capybara'
require 'capybara/dsl'
require 'rspec/expectations'
 
Capybara.app_host = "file:///path/to/folder/with/file"
Capybara.run_server = false
Capybara.current_driver = :selenium
 
include Capybara::DSL # It's a bad practice in general but good enough for simple script
include RSpec::Matchers
 
visit '/test.html'
 
def cell_text(n)
find(:xpath, "./td[#{n}]").text
end
 
h = {2 => 4.5, 3 => 1.1}
 
within 'table' do
all('tr').each do |row|
within row do
if cell_text(1) == 'Mike'
h.each { |i, value| cell_text(i).should == value.to_s }
else
h.each { |i, value| cell_text(i).should_not == value.to_s }
end
end
end
end
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.