title: How to get rid of new empty chrome window that opens up while running in headless mode
body: <p>I have a selenium/gauge automation project and using java for the code.  In my driver factory, I have it set to run headless, however; when I run it, an empty chrome window launches for some reason.  How can I make it stop launching this window?</p>
  
  <p>public static WebDriver getDriver() {</p>
  
  <pre><code>    String browser = System.getenv("BROWSER");
      if (browser == null) {
          WebDriverManager.chromedriver().setup();
          DesiredCapabilities capabilities = DesiredCapabilities.chrome();
          capabilities.setJavascriptEnabled(true);
          ChromeOptions options = new ChromeOptions();
          options.addArguments("chrome.switches","disable-extensions", "ignore-certificate-errors", "no-sandbox");
          options.addArguments("--disable-popup-blocking"); //Global driver.switchTo().alert().accept();
          options.addArguments("start-maximized");
          options.addArguments("headless");
          capabilities.setCapability(ChromeOptions.CAPABILITY, options);
          return new ChromeDriver(capabilities);
      }
  </code></pre>
  
  <p>public class AppLauncher {</p>
  
  <pre><code>public static String APP_URL = System.getenv("APP_URL");
  
  @Step("Launch Qualitrac")
  public void launchQualitrac() {
      webDriver.get(AppLauncherObjects.getMapPageNames().get("Qualitrac"));
      assertEquals("Qualitrac", webDriver.getTitle());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>public class Driver {</p>
  
  <pre><code>// Holds the WebDriver instance
  public static WebDriver webDriver;
  public static HashMap globalStash;
  
  // Initialize a webDriver instance of required browser
  // Since this does not have a significance in the application's business domain, the BeforeSuite hook is used to instantiate the webDriver
  @BeforeSuite
  public void initializeDriver() {
      webDriver = DriverFactory.getDriver();
      webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      globalStash = new HashMap&lt;String,String&gt;();
  }
  
  // Close the webDriver instance
  @AfterSuite
  public void closeDriver(){
      webDriver.quit();
  }
  </code></pre>
  
  <p>}</p>