Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.