title: Selenium, FluentAutomation & NUnit - How do I switch browsers for each TestCase?
body: <p>Currently, openGoogle() does get called for each test case with the correct parameters.  The problem is that setBrowser does not appear to be working properly.  It does set the first time and completes the test successfully.  However, when openGoogle() gets invoked for the second time it continues to use the first browser instead of using the new browser specified. </p>
  
  <blockquote>
    <p>using NFramework = NUnit.Framework;
    ...</p>
  
  <pre><code>   [NFramework.TestFixture]
      public class SampleTest : FluentAutomation.FluentTest
      {
          string path;
          private Action&lt;TinyIoCContainer&gt; currentRegistration;
          public TestContext TestContext { get; set; }
  
          [NFramework.SetUp]
          public void Init()
          {
              FluentAutomation.Settings.ScreenshotOnFailedExpect = true;
              FluentAutomation.Settings.ScreenshotOnFailedAction = true;
              FluentAutomation.Settings.DefaultWaitTimeout = TimeSpan.FromSeconds(1);
              FluentAutomation.Settings.DefaultWaitUntilTimeout = TimeSpan.FromSeconds(30);
              FluentAutomation.Settings.MinimizeAllWindowsOnTestStart = false;
              FluentAutomation.Settings.ScreenshotPath = path = "C:\\ScreenShots";
          }
  
          [NFramework.Test]
          [NFramework.TestCase(SeleniumWebDriver.Browser.Firefox)]
          [NFramework.TestCase(SeleniumWebDriver.Browser.InternetExplorer)]
          public void openGoogle(SeleniumWebDriver.Browser browser)
          {
              setBrowser(browser);
  
              I.Open("http://www.google.com/");
              I.WaitUntil(() =&gt; I.Expect.Exists("body"));
              I.Enter("Unit Testing").In("input[name=q]");
              I.TakeScreenshot(browser + "EnterText");
  
              I.Click("button[name=btnG]");
              I.WaitUntil(() =&gt; I.Expect.Exists(".mw"));
              I.TakeScreenshot(browser + "ClickSearch");
          }
  
          public SampleTest()
          {
              currentRegistration = FluentAutomation.Settings.Registration;
          }
  
          private void setBrowser(SeleniumWebDriver.Browser browser)
          {
              switch (browser)
              {
                  case SeleniumWebDriver.Browser.InternetExplorer:
                  case SeleniumWebDriver.Browser.Firefox:
                      FluentAutomation.SeleniumWebDriver.Bootstrap(browser);
                      break;
              }
          }
      }
  </code></pre>
  </blockquote>
  
  <p>Note:  Doing it this way below DOES work correctly - opening a separate browser for each test.</p>
  
  <blockquote>
    <p>public class SampleTest : FluentAutomation.FluentTest {
        string path;
        private Action currentRegistration;
        public TestContext TestContext { get; set; }</p>
  
  <pre><code>private void ie()
  {
      FluentAutomation.SeleniumWebDriver.Bootstrap(FluentAutomation.SeleniumWebDriver.Browser.InternetExplorer);
  }
  private void ff()
  {
      &gt;FluentAutomation.SeleniumWebDriver.Bootstrap(FluentAutomation.SeleniumWebDriver.Browser.Firefox);
  }
  
  public SampleTest()
  {
      //ff
      FluentAutomation.SeleniumWebDriver.Bootstrap();
      currentRegistration = FluentAutomation.Settings.Registration;
  }
  
  [TestInitialize]
  public void Initialize()
  {
      FluentAutomation.Settings.ScreenshotOnFailedExpect = true;
      FluentAutomation.Settings.ScreenshotOnFailedAction = true;
      FluentAutomation.Settings.DefaultWaitTimeout = TimeSpan.FromSeconds(1);
      FluentAutomation.Settings.DefaultWaitUntilTimeout = TimeSpan.FromSeconds(30);
      FluentAutomation.Settings.MinimizeAllWindowsOnTestStart = false;
      path = TestContext.TestResultsDirectory;
      FluentAutomation.Settings.ScreenshotPath = path;
  }
  
  [TestMethod]
  public void OpenGoogleIE()
  {
      ie();
      openGoogle("IE");
  }
  [TestMethod]
  public void OpenGoogleFF()
  {
      ff();
      openGoogle("FF");
  }
  private void openGoogle(string browser)
  {
      I.Open("http://www.google.com/");
      I.WaitUntil(() =&gt; I.Expect.Exists("body"));
      I.Enter("Unit Testing").In("input[name=q]");
      I.TakeScreenshot(browser + "EnterText");
  
      I.Click("button[name=btnG]");
      I.WaitUntil(() =&gt; I.Expect.Exists(".mw"));
      I.TakeScreenshot(browser + "ClickSearch");
  
  } }
  </code></pre>
  </blockquote>