Selenium Python configuration for Chrome in headless mode

Here is what worked for me related to Chrome in headless mode:

First import a few modules:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

Then set the driver:

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
self.driver = webdriver.Chrome(executable_path="C:/webdriver/chromedriver.exe",chrome_options=chrome_options)

Please make sure to change the binary location to where Chrome is installed on your system. Also, you will need the latest chromedriver.exe executable (downloadable from here : https://sites.google.com/a/chromium.org/chromedriver/.). You will need to put its location in the executable_path. You will need Selenium 3.8.0 approximately as well.