title: Protractor. How to restart browser between tests?
body: <p>I wrote a pack of tests and separately each of them works correctly (for each test I created separate file - it important for my case) , but when I try to run them all together I have some problems:
  At the first I tried to restart browser after each test with <code>“restartBrowserBetweenTests: true”</code> option but as a result I receive next error:</p>
  <blockquote>
  <p>Failed: This driver instance does not have a valid session ID (did you
  call WebDriver.quit()?) and may no longer be used.</p>
  </blockquote>
  <p>I read some advice for this situation, but nothing helped me.</p>
  <p>Basically, I can get without restarting browser but in this case I want to close all active tabs after each test and I also don’t know ho to do it. With the help of this function:</p>
  <pre><code>browser.getAllWindowHandles().then((handles) =&gt; {
      browser.driver.switchTo().window(handles[1]);
      browser.driver.close();
      browser.driver.switchTo().window(handles[0]);
  });
  </code></pre>
  <p>I can close active tab and return for the previous but the function works only if I  place this code in the test spec, that's not comfortable for me (copy it for each test) and if I call it from special file with functions it works incorrectly due to the</p>
  <blockquote>
  <p>“Failed: no such window: target window already closed
  from unknown error: web view not found”</p>
  </blockquote>
  <p>errors (a consequence of a lost context).</p>