Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sleep function in Capybara/Cucumber?

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?

like image 601
blim8183 Avatar asked Oct 15 '12 17:10

blim8183


People also ask

What is cucumber capybara?

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.

How do you set up a cucumber in rails?

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 .

What is cucumber Ruby?

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.


Video Answer


1 Answers

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...
like image 62
Zach Kemp Avatar answered Sep 19 '22 08:09

Zach Kemp