Skip to content

Instantly share code, notes, and snippets.

@jeromew21
Last active March 4, 2021 19:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromew21/1f1b3aa567dee7a51827b4aa5b3645a0 to your computer and use it in GitHub Desktop.
Save jeromew21/1f1b3aa567dee7a51827b4aa5b3645a0 to your computer and use it in GitHub Desktop.
[Python] Start Selenium Firefox driver in headless (invisible) mode.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
options = Options()
options.set_headless(True)
binary = FirefoxBinary("/usr/bin/firefox") #Linux. In Windows/Mac this is different
driver = webdriver.Firefox(firefox_options=options, firefox_binary=binary)
print("started firefox in headless mode")
#Drive the invisible browser
driver.get('http://google.com/')
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment