public void ClosingWindows() { IBrowser b = new BrowserWrapper(new Browser(Helper.GetAllways200RequestMocker( new List<Tuple<string, string>>() { Tuple.Create("^/otherpage", "<html></html>"), Tuple.Create("^.*", @" <html> <a href=""/otherpage"" target=""_blank"" id=""blanklink"">click</a> </html>"), } ))); var dr = new SimpleBrowserDriver((IBrowser)b); dr.Navigate().GoToUrl("http://blah/"); dr.FindElement(By.Id("blanklink")).Click(); Assert.That(dr.Url == "http://blah/"); Assert.That(dr.WindowHandles.Count == 2); string otherWindowName = dr.WindowHandles.First(n => n != dr.CurrentWindowHandle); var otherDr = dr.SwitchTo().Window(otherWindowName); Assert.That(otherDr.Url == "http://blah/otherpage"); // Now we will close the first window and see that everything behaves as expected dr.Close(); Assert.That(otherDr.WindowHandles.Count == 1); Assert.That(otherDr.Url == "http://blah/otherpage"); // still there Assert.Throws<ObjectDisposedException>(() => { var a = dr.Url; }); }