set chrome options with remote driver

From the source code it looks like the only way this would be possible is to pass it through desired_capabilities. This dictionary is sent directly to the remove driver via a POST request.

After looking at how to start chromium with specific flags, maybe something like this would work:

desired_capabilities = {
    'browserName': 'chrome',
    'chrome.switches': ['--disable-logging']
}

This should give you the flags available:

from selenium import webdriver
options = webdriver.ChromeOptions()
# set some options
# for example:
# options.add_argument('--disable-logging')
driver = webdriver.Remote(desired_capabilities=options.to_capabilities())

Just my two cents on this since the selenium remote and chrome webdrivers changed.

import os
from selenium import webdriver


class RemoteBrowser:

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('whitelisted-ips')
    chrome_options.add_argument('headless')
    chrome_options.add_argument('no-sandbox')
    chrome_options.add_argument('window-size=1200x800')

    def __init__(self):
        self.hub_url = os.environ['HUB_URL']
        self.driver = webdriver.Remote(
            command_executor='http://' + self.hub_url + '/wd/hub',
            desired_capabilities = {'browserName': 'chrome'},
            options=self.chrome_options
        )