The Python Oracle

set chrome options with remote driver

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Quiet Intelligence

--

Chapters
00:00 Set Chrome Options With Remote Driver
02:07 Accepted Answer Score 27
02:21 Answer 2 Score 2
02:44 Answer 3 Score 6
03:06 Thank you

--

Full question
https://stackoverflow.com/questions/1322...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #selenium #webdriver #seleniumchromedriver

#avk47



ACCEPTED ANSWER

Score 27


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())



ANSWER 2

Score 6


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
        )



ANSWER 3

Score 2


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']
}