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?
cucumber is a BDD tool that expresses testing scenarios in a business-readable, domain-specific language. capybara is an automated testing tool (often used) for ROR applications.
Let's create an empty directory cucumber-app for our application. cd cucumber-app In the directory we initiate bundler by calling bundle init . This will create a Gemfile for us. Let's add the Cucumber gem gem "cucumber" and install it by running bundle .
Cucumber is a test framework for behavior-driven Ruby development. Cucumber scenarios are written using the Gherkin syntax and stored in . feature files. Each scenario has multiple steps that link to step definitions representing Ruby blocks.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With