title: Codeception + selenium, automatically closed window causes error
body: <p>I'm testing a payment process flow using codeception 2.2.9 with webdriver/selenium .</p>
  
  <p>This is the interaction overview:</p>
  
  <ul>
  <li>user makes his order on our site</li>
  <li>after selecting payment provider, new window is opened with payment providers website in it (this is controlled by payment provider)</li>
  <li>user fills out his payment details on site of payment provider</li>
  <li>the last button click on payment providers website causes the window to be closed (this is where the problem is)</li>
  <li>we get confirmation form payment provider on the background</li>
  <li>user is being taken back to our site</li>
  </ul>
  
  <p>Everything works fine, except when the window gets automatically closed as the last step of the flow by payment provider. I get a warning inside selenium server:</p>
  
  <blockquote>
    <p>WARN - Exception: Window not found. The browser window may have been closed.</p>
  </blockquote>
  
  <p>and an error inside codeception output:</p>
  
  <blockquote>
    <p>[Facebook\WebDriver\Exception\NoSuchWindowException]
    Window not found. The browser window may have been closed.</p>
  </blockquote>
  
  <p>After payment providers window gets automatically opened I'm switching to it like this:</p>
  
  <pre><code>$I-&gt;switchToNextTab();
  </code></pre>
  
  <p>The problem is caused by clicking a 'confirm' button on payment providers site which causes the window to get closed automatically like this:</p>
  
  <pre><code>$I-&gt;click('.form-submitter'); // now the window is gone
  </code></pre>
  
  <p>Is there anything I can do to prevent this error?
  Is there a way to expect the window to get closed?</p>
  
  <p>Thank you for your help!</p>