Ruby-on-rails – Sleep function in Capybara/Cucumber

capybaracucumberrubyruby-on-rails

I have a page on my site that I'm trying to test that requires that a user spend at least five seconds on the page before proceeding. Is there a way with Capybara to get my Cucumber tests to pause on that page and wait five seconds before proceeding with the next step I describe?

Best Answer

I have this in my step definitions:

Given /^I wait for (\d+) seconds?$/ do |n|
  sleep(n.to_i)
end

In your feature:

Given I am on the whatever page
And I wait for 5 seconds
And I follow "A Link"
# etc...
Related Topic