Created
December 30, 2009 17:31
-
-
Save lenny/266218 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
When I select the following previous correspondence items: | |
| type | date | filename | | |
| CTA | 01Jan09 | EMAIL | | |
When /^I select the following previous correspondence items:$/ do |table| | |
checkboxes = PreviousCorrespondenceSteps.get_checkboxes_for(table) | |
checkboxes.each {|b| b.set(true) } | |
end | |
class PreviousCorrespondenceSteps | |
extend Capybara | |
def self.get_checkboxes_for(table) | |
raise "unsupported criteria" unless (table.headers - %w(type date note filename)).empty? | |
checkboxes = [] | |
table.hashes.each do |criteria| | |
row = all("//*[@id='prev-corr-selection-table']//tr").find do |tr| | |
if type = criteria['type'] | |
next unless tr.find('//td', :text => /\b#{type}\b/) | |
end | |
if date = criteria['date'] | |
next unless tr.find(:text => date) | |
end | |
if note = criteria['note'] | |
next unless tr.find(:text =>/#{note}/) | |
end | |
true | |
end | |
raise "#{criteria.inspect} not found" unless row | |
checkboxes << row.find("//*[contains(@class, 'file-item')]//input[@type='checkbox']") | |
end | |
checkboxes | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment