3
votes


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
1

1 Answers

1
votes

I have another solution that works for me.

  1. add gem capybara-screenshot

  2. 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