title: Passing Webdriver As An Instance
body: <p>What I'm trying to do with this is to allow one section of the app to allow the user to run a few tests with webdriver. Then, without closing that window, making changes to the web app and then kicking off a separate method to perform other actions.</p>
  
  <p>What I've created is class BrowserAgent that holds a Webdriver object like so:</p>
  
  <pre><code> public class BrowserAgent
  {
      private static BrowserAgent instance = new BrowserAgent();
      private boolean BrowserAgentBusy = false;
      private static boolean BrowserAgentActive = false;
      private static WebDriver driver;
  ...
  </code></pre>
  
  <p>Now when I get the instance of the driver I am simply calling BrowserAgent.getDriver() which is implemented like so:</p>
  
  <pre><code>public static WebDriver getDriver()
      {    
          if(BrowserAgentActive &amp;&amp; driver != null)
          {
              return driver;
          }
          else
          {
              BrowserAgentActive = true;
              return new FirefoxDriver();
          }
  
      }
  </code></pre>
  
  <p>However, for some reason, every time I call getDriver(), a new window opens, and all of the context from the first window is now lost. What am I doing wrong?</p>