When /^I reload the page$/ do
# puts "DEBUG - The page for #{current_path}"
case Capybara::current_driver
when :selenium
visit page.driver.browser.current_url
when :racktest
visit [ current_path, page.driver.last_request.env['QUERY_STRING'] ].reject(&:blank?).join('?')
when :culerity
page.driver.browser.refresh
else
raise "unsupported driver, use rack::test or selenium/webdriver"
end
end

  • http://opinionatedprogrammer.com/ Jo Liss

    It’s an old post, but: Simply calling “visit current_path” should work in all drivers. If not, perhaps something is wrong with a driver — in which case I’d recommend you tell people about your use case on the mailing list.

  • http://www.solitr.com/blog/ Jo Liss

    It’s an old post, but: Simply calling “visit current_path” should work in all drivers. If not, perhaps something is wrong with a driver — in which case I’d recommend you tell people about your use case on the mailing list.

  • cymen

    Calling “visit current_path” for me doesn’t visit the full URL — it doesn’t include the part after the hashmark. So if you’re using cucumber to test something that does use the hashmark for an important part (like a lot of JavaScript pages), it doesn’t do what one would want.

    Thanks to xunker — this was useful to me.

  • Pavel Kalashnikov

    for rack_test -v 0.6.2

    visit [current_path, page.driver.request.env['QUERY_STRING']].reject(&:blank?).join(‘?’)

  • JD Guzman

    or use current_url