Selenium Python configuration for Firefox in headless mode

This worked for me :

Import few modules:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FFOptions

then set the driver:

options = FFOptions()
options.add_argument('--headless')
self.driver = webdriver.Firefox(firefox_options=options)

Please note that you have to have the latest FF (57 will do) and selenium 3.8.0 approximately.