I\'ve spent the last few days messing around with Selenium, Tor, and Firefox as a combination for multiple tasks. I\'ve managed to write a simple script in Python that takes
You can set headless mode through webdriver.FirefoxOptions()
, just like you did with Chrome:
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.add_argument('headless')
driver = webdriver.Firefox(options=options)
P.S. If you use Selenium < 3.8.0, you have to replace webdriver.FirefoxOptions()
with webdriver.firefox.options.Options()
(see PR #5120).
Besides, use enviroment variable MOZ_HEADLESS
will do the same thing:
import os
from selenium import webdriver
os.environ['MOZ_HEADLESS'] = '1' # <- this line
driver = webdriver.Firefox()