I have multiple features when run together throw this error. If I run the scenarios by them self there is no issue. I think the issue is that popups are generated during the test run and are not closed properly. I have code in an After hook that closes all open windows except the very first window opened.
Error: **Session [2c50a228-3ad7-a544-a6ca-5d173b86bc86] has no driver. The browser window may have been closed. (Selenium::WebDriver::Error::UnknownError)**
I have added a bunch of print statements in my code to get the current state:
<br>
After:Session -> #<>Capybara::Session:0x00000100f811b8><br>
Before:Driver -> selenium<br>
Before:Session Object -#<>Capybara::Session:0x00000100f811b8><br>
Before: (start) Driver Object #<>Capybara::Selenium::Driver:0x000001028ad790>
The scenario before this particular scenario fails, this HAS to be the culprit, but why? Can anyone point me in the right direction?
<br>
<br>
**After hook**<br>
<code>
#assume ONLY last window opened is to be closed
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
page.execute_script "window.close();"
#switch back to first window opened, make it the default window now
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
</code>
<br>
***Env:
capybara (2.0.3)<br>
cucumber (1.1.9)<br>
selenium-webdriver (2.29.0)<br>
ruby 1.9.3p0***