Created
May 12, 2010 16:52
-
-
Save bernerdschaefer/398817 to your computer and use it in GitHub Desktop.
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
def wait_conditionally_until | |
if page.driver.wait? | |
page.wait_until do | |
begin | |
yield | |
rescue Selenium::WebDriver::Error::WebDriverError => e | |
# do nothing - continue to wait for timeout | |
end | |
end | |
else | |
yield | |
end | |
end | |
# before: this can find the field before it's been checked! | |
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector| | |
with_scope(selector) do | |
[true, 'checked'].should_not include(find_field(label)['checked']) | |
end | |
end | |
# after: so capybara now has real methods for this! | |
Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do |label, selector| | |
with_scope(selector) do | |
page.should have_unchecked_field(label) | |
end | |
end | |
# before: all does not implement waiting! | |
Then /^the "([^\"]*)" list should have (\d) items?$/ do |list, num| | |
all(:css, "#{list} li").count.should == num.to_i | |
end | |
# after | |
Then /^the "([^\"]*)" list should have (\d) items?$/ do |list, num| | |
wait_conditionally_until do | |
all(:css, "#{list} li").count == num.to_i | |
end.should be_true | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment