title: The right way to run Firefox in headless mode (Selenium, Python)
body: <p>I was wondering how to run hidden Firefox window when testing a page in Selenium and came across <a href="https://stackoverflow.com/a/50828726/7550772">this solution</a>. It says that I can run Firefox in headless mode like this:</p>
  
  <pre><code>from selenium import webdriver
  import os
  os.environ['MOZ_HEADLESS'] = '1'
  driver = webdriver.Firefox()
  driver.get("https://www.google.com/")
  driver.close()
  </code></pre>
  
  <p>But it earned no votes whatsoever. It seems like people think it is a wrong answer. <strong><em>Why?</em></strong></p>
  
  <p>Also, in official documentation I found that it can be done like this:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.firefox.options import Options
  options = Options()
  options.add_argument('-headless')
  driver = webdriver.Firefox(options=options)
  driver.get("https://www.google.com/")
  driver.close()
  </code></pre>
  
  <p>Can someone explain the difference between the two ways?</p>