title: SpecFlow Teardown Opens and Closes Multiple Blank Browsers
body: <p>I am in the process of converting a bunch of selenium test cases over to SpecFlow. Everything is working well but what is driving me crazy is that I am using an after scenario to do a driver.quit. When that executes, I have roughly 4-6 browsers opening and closing. In looking at the task manager, it is killing all of the chromedriver.exe (a second one is opened somewhere) and chrome.exe processes successfully which is great. If I run the same test in selenium, I just have one browser and it closes. When SpecFlow runs now, it basically adds 10-20 seconds onto my runs as it opens and closes browsers.</p>
  
  <p>If I change my browser to Firefox I get the same thing. One browser opens and at completion, several blank firefox browsers open and close.</p>
  
  <p>Any ideas what could be causing this behavior? I have searched all over and no one seems to have ever experienced this but me. </p>
  
  <p>Appreciate the help.</p>
  
  <p>Here is teardown code. I have it in a basetestobject class and it is inherited by the specflow classes. I have tried removing the [TestCleanup] but the same result applies. </p>
  
  <p>BaseTestObject.cs</p>
  
  <pre><code>    public class BaseTestObject
       {
      private IWebDriver seleniumDriver;
      private IDriver testDriver;
  
      [TestInitialize]
      public virtual void Setup()
      {
          TestDriver.goToUrl(ConfigProperties.StartUrl);
      }
  
      [AfterScenario]
      public void ScenarioTearDown()
      {
       TestDriver.Quit();
      }
  
      [TestCleanup]
      public void CleanUp()
      {
          TestDriver.Quit();
  
      }
  
  
      public IWebDriver SeleniumDriver
      {
          get
          {
              if (seleniumDriver == null)
              {
                  seleniumDriver = GetDriver();
              }
              return seleniumDriver;
          }
      }
  
      public IDriver TestDriver
      {
          get
          {
              if (testDriver == null)
              {
                  testDriver = new UiDriver(SeleniumDriver);
              }
              return testDriver;
          }
      }
  
  
      public CurrentPageObjectScope On
      {
          get
          {
              return new CurrentPageObjectScope(TestDriver);
          }
      }
  
      public static String GetTimestamp()
      {
          return DateTime.Now.ToString("yyyyMMddhhmmssfff");
      }
  
      public static String GetTimestamp2()
      {
          return DateTime.Now.ToString("M/d/yyyy");
      }
  
      private IWebDriver GetDriver()
      {
          switch (ConfigProperties.Browser.ToLower())
          {
              case "firefox":
                  return new FirefoxDriver();
              case "chrome":
  
  
                  ChromeOptions options = new ChromeOptions();
                  ChromeDriverService service =                ChromeDriverService.CreateDefaultService(@"../Chrome/");
                  service.SuppressInitialDiagnosticInformation = true;
                  service.HideCommandPromptWindow = true;
                  options.AddArguments("test-type");
                  options.AddArgument("--start-maximized");
                  return new ChromeDriver(service, options);
  
  
  
              case "ie":
              case "internetexplorer":
  
                  return new InternetExplorerDriver(@"../IE/");
  
  
              default:
                  throw new NotImplementedException("Unknown browser string in Config properties " + ConfigProperties.Browser);
          }
  
  
      }
  </code></pre>
  
  <p>Edit 9.15.14</p>
  
  <p>resolved by adding the below in my baseTestObject. Thanks for the help.</p>
  
  <pre><code>    [AfterScenario]
      public void CleanUp()
      {
          if (seleniumDriver != null)
          {
              SeleniumDriver.Dispose();
              seleniumDriver = null;
          }
      }
  </code></pre>