How to disable logging using Selenium with Python binding

A simple question: how to completely disable logging when using Selenium from Python, ex code bindings as follows:

browser = webdriver.Chrome()

I tried things like:

options = webdriver.ChromeOptions();
options.add_argument('--log-level 3') 
browser = webdriver.Chrome(chrome_options=options)

or even:

options = webdriver.ChromeOptions();
options.add_argument('--disable-logging') 
browser = webdriver.Chrome(chrome_options=options)

but still the damned chromedriver.log file still appears in every new test run.

+5
source share
2 answers

The source code for the Chrome web browser shows the existence of an option named service_log_path.

So, if you want to get rid of the file, you can set this property as

  • /dev/nullif you are running Linux / Unix;
  • NUL under the windows

Hope this helps

+1
source
driver = webdriver.Chrome(service_log_path='/dev/null')
+5
source

All Articles