I run tests using Cucumber in conjunction with Capybara and Selenium-Webdriver. I want restart browser after each scenario. Here is my env.rb. I can add in After section something like this:
After do |scenario|
onError scenario if scenario.failed?
page.driver.browser.close
end
but this kills browser after first scenario passed and all other scenarios failed with reasonable error:
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 7055
Is there way to refactor my env.rb to use Before hook to start browser on every scenario?