I have a ask_a_question page with the onbeforeunload function to warn the user before leaving something unsaved (e.g. SO: P). I am testing it with a cucumber with capybara and webdriver, adding an @javascript tag because it uses a lot of javascript. The cucumber function might look like this:
@javascript Scenario: add a question Given I login as "Mauricio" And I go to the create question page Then I should see "Ask a Question" within "header"
But as soon as the test patches, Capybara (or WebDriver, I dunno) tries to reuse the same browser window for other tests, then an onbeforeunload warning pops up, which has sent the next test.
As my function does not close or exit the page itself. I donβt think it would be nice to add something to accept the warning. But honestly, Iβm completely lost.
How can I tell capybara to use a new browser window for each @javascript test or automatically close the onbeforeunload warning?
Thanx
source share