The Python Oracle

set chrome options with remote driver

This video explains
set chrome options with remote driver

--

Become part of the top 3% of the developers by applying to Toptal
https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Book End

--

Chapters
00:00 Question
02:35 Accepted answer (Score 27)
02:52 Answer 2 (Score 5)
03:29 Answer 3 (Score 2)
03:59 Answer 4 (Score 0)
04:18 Thank you

--

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

Question links:
[long list of switches]: http://peter.sh/experiments/chromium-com.../
[see any other arguments]: http://selenium-python.readthedocs.org/e...
["Starting Chromium with Specific Flags"]: http://code.google.com/p/selenium/wiki/C...

Answer 2 links:
[sent directly to the remove driver]: http://code.google.com/p/selenium/source...

--

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