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

2024/9/8 9:11:47

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.

Answer

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.

https://en.xdnf.cn/q/73156.html

Related Q&A

How to model python properties in UML diagram

What is a good practice to model Python properties in a UML class diagram? Properties themselves are class objects, their getter and setter are class functions. From Outside the class they look like i…

Linear regression with tensorflow

I trying to understand linear regression... here is script that I tried to understand: A linear regression learning algorithm example using TensorFlow library. Author: Aymeric Damien Project: https://g…

Are null bytes allowed in unicode strings in PostgreSQL via Python?

Are null bytes allowed in unicode strings?I dont ask about utf8, I mean the high level object representation of a unicode string.BackgroundWe store unicode strings containing null bytes via Python in …

Why the irrelevant code made a difference?

I am thinking to make a progress bar with python in terminal. First, I have to get the width(columns) of terminal window. In python 2.7, there is no standard library can do this on Windows. I know mayb…

What values to use for FastCGI maxrequests, maxspare, minspare, maxchildren?

Im running a Django app using FastCGI and lighttpd.Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren?These options are not…

How to calculate the Silhouette Score for each cluster separately in python

You can easily extract the silhouette score with 1 line of code that averages the scores for all your clusters but how do you extract each of the intermediate scores from the scikit learn implementatio…

Can I tell python to put an existing figure in a new figure?

Creating a certain plot is a lot of work, so I would like to automate this by create a function f() that returns a figure.I would like to call this function so that I can put the result in a subplot. …

django-crispy-forms have field and button on same row

I am needing to have a bootstrap PrependedText field with a button on the same row. I can get it on the same row but it shows the button before the textbox and I want it after. What am I doing wrong an…

Uploading file in python flask

I am trying to incorporate uploading a basic text/csv file on my web app which runs flask to handle http requests. I tried to follow the baby example in flasks documentation running on localhost here. …

Diagonal stacking in numpy?

So numpy has some convenience functions for combining several arrays into one, e.g. hstack and vstack. Im wondering if theres something similar but for stacking the component arrays diagonally?Say I h…