Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reduce the verbosity of chromedriver logs when running it under selenium?

My jenkins failure reports for my functional tests are full of lines like this:

selenium.webdriver.remote.remote_connection: DEBUG: Finished Request
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:52932/session/60d406aa8e55ac841cf4efb4a43e63be/element {"using": "css selector", "sessionId": "60d406aa8e55ac841cf4efb4a43e63be", "value": "#Login input[name=email]"}

I don't care about them and there are hundreds of these lines of output for every line of stacktrace that I actually want to see. How do I turn them off?

Things I have tried so far that don't work:

from selenium import webdriver
driver = webdriver.Chrome(
    service_args=['--silent'], 
    service_log_path='/tmp/throwaway.log')

And...

from selenium import webdriver
driver = webdriver.Chrome(
    service_args=['2>/dev/null'])

And...

from selenium import webdriver
driver = webdriver.Chrome(
    service_args=['>', '/dev/null', '2>&1'])

All without reducing any of the output.

like image 890
aychedee Avatar asked Dec 25 '22 09:12

aychedee


1 Answers

You need to set the logging level on the remote_connection higher than DEBUG:

from selenium.webdriver.remote.remote_connection import LOGGER, logging
LOGGER.setLevel(logging.WARNING)

FYI, based on this answer.

like image 79
alecxe Avatar answered Jan 04 '23 23:01

alecxe