Created
January 25, 2013 20:51
-
-
Save abotalov/4637735 to your computer and use it in GitHub Desktop.
Simple script to post answer for http://stackoverflow.com/q/14527556/841064
This file contains 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
<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> |
This file contains 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 '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