Posted over 8 years ago. Visible to the public.

Use the back button in Cucumber

In order to go back one page in your Cucumber tests, you can use the following step definition for Capybara:

Copy
When(/^I go back$/) do visit page.driver.request.env['HTTP_REFERER'] end

If you're on Webrat, this should work:

Copy
When(/^I go back$/) do visit request.env["HTTP_REFERER"]) end

An improved version of this step is now part of our gem spreewald on Github.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Thomas Eisenbarth
Last edit:
over 5 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Eisenbarth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more