Reputation: 470
I am running tests for a Rails app with Capybara, Cucumber and Selenium Webdriver (Ruby). I have a question: why Capybara doesn't close browser when Net::ReadTimeout happens even I had a hook which asked browser to quit after each test scenario? How can I force it to close the browser when Net::ReadTimeout occurs?
This is my hooks.rb
after do |scenario|
if scenario.failed?
page.driver.browser.save_screenshot("#{scenario.__id__}.png")
end
Capybara.current_session.driver.browser.manage.delete_all_cookies
Capybara.current_session.driver.quit
end
Upvotes: 3
Views: 1061
Reputation: 26
I have another solution that works for me.
add gem capybara-screenshot
configure your spec_helper.rb
in such way:
Capybara::Screenshot.autosave_on_failure = true
Capybara::Screenshot.prune_strategy = :keep_last_run
Capybara.default_wait_time = 60
Upvotes: 1