Skip to content

Instantly share code, notes, and snippets.

@jarib
Created April 19, 2011 21:43
Show Gist options
  • Save jarib/929779 to your computer and use it in GitHub Desktop.
Save jarib/929779 to your computer and use it in GitHub Desktop.
require 'watir-webdriver'
path = File.expand_path "test.html"
File.open(path, "w") { |io| io << DATA.read }
begin
b = Watir::Browser.new
b.goto "file://#{path}"
first_row = b.table(:class => "sortable")[0]
p first_row.text
wanted_row = b.tr(:id => "account_1")
wanted_row.click
ensure
sleep 2
b.close
end
__END__
<html>
<head><title>Test</title></head>
<body>
<table class="sortable">
<thead>
<tr id="">
<th> </th>
<th class="sort" > Name </th>
<th class="sort" > Number </th>
</tr>
</thead>
<tbody>
<tr id="account_1" onclick="alert('foo')">
<td></td>
<td class="sortTd">Test Account</td>
<td class="sortTd">1</td>
</tr>
</tbody>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment