title: How to run headless firefox browser on remote server over SSH connection?
body: <p>I have a remote server and I wish to run a headless session of Firefox there. I login into the remote server and execute the command. Even if the commands are headless, still it opens my machine's Firefox and performs actions within it. Any idea what could be the reason? I wish to perform these actions remotely without my display machine (like my laptop) being connected to it.</p>
  
  <pre><code>from selenium.webdriver import Firefox
  from selenium.webdriver.common.by import By
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.firefox.options import Options
  from selenium.webdriver.support import expected_conditions as expected
  from selenium.webdriver.support.wait import WebDriverWait
  
  if __name__ == "__main__":
      options = Options()
      options.add_argument('-headless')
      driver = Firefox(executable_path='/path/to/geckodriver', firefox_options=options)
      wait = WebDriverWait(driver, timeout=10)
      driver.get('http://www.google.com')
      wait.until(expected.visibility_of_element_located((By.NAME, 'q'))).send_keys('headless firefox' + Keys.ENTER)
      wait.until(expected.visibility_of_element_located((By.CSS_SELECTOR, '#ires a'))).click()
      print(driver.page_source)
      driver.quit()
  </code></pre>