#1672 introduced behaviour which tries to make sure that resetting the session is going to close any alerts from a beforeunload handler. Unfortunately, if such an alert is already open, there's a race condition where Capybara never navigates to about:blank and thus gets stuck in a loop trying to check for no content, which never happens. This causes the session reset to time out with an error like:
/Users/jonasnicklas/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/capybara-2.7.0/lib/capybara/selenium/driver.rb:114:in `reset!': Timed out waiting for Selenium session reset (Capybara::ExpectationNotMet)
from /Users/jonasnicklas/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/capybara-2.7.0/lib/capybara/session.rb:109:in `reset!'
from test.rb:10:in `<main>'
I have a repro here. I'll try to submit a fix.