Set Chrome Options With Remote Driver
So there's a nice long list of switches that can be passed to the chromedriver. I would like to use some of them, specifically --disable-logging. I do no want to (only) use chromed
Solution 1:
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())
Solution 2:
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
)
Solution 3:
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']
}
Solution 4:
ChromeOptions() that works for passing additional arguments. try this to disable chromedriver.log
driver = webdriver.Chrome(service_log_path='/dev/null')
Post a Comment for "Set Chrome Options With Remote Driver"