This is the code that I tried to run
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('log-level=3')
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
input()
and this is the output
DevTools listening on ws://127.0.0.1:62699/devtools/browser/8462948e-49fc-4e39-aa2b-bc89d4e3d0e4
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1751797016.966696 65184 voice_transcription.cc:58] Registering VoiceTranscriptionCapability
the DevTools listening part is fine but I have no idea where this warning is coming from. I want to remove this warning and stop the log as it has no relevance to what I am doing and it is causing noise in the console.
The selenium version is 4.34.0 and I have not installed abseil so the warning likely comes from selenium or the chromedriver and I cant really tell where this warning is from.
I tried googling this and this log seems to come from the abseil library. I found one similar issue but it is about Gemini API and not selenium. This is a link to that question.
How do I get rid of the annoying terminal warning when using Gemini API?
I tried the solution there, which is to set these environmental variables
import os
# Suppress logging warnings
os.environ["GRPC_VERBOSITY"] = "ERROR"
os.environ["GLOG_minloglevel"] = "2"
but it did not work.
another solution proposed in the answers of the question is to install a specific version of grpcio. I did not attempt to do that as I do not have grpcio installed so installing grpcio is likely not going to do anything.
I have also tried redirecting stdout and stderr by doing this
import sys
log = []
class writer(object):
def write(self, data):
log.append(data)
sys.stdout = writer()
sys.stderr = writer()
but it still did not work
google-chromedirectly in console but I don't see it when I run Selenium. Maybe my Selenium useschromiuminstead ofgoogle-chrome/chromebecausechromiumdoesn't show this message when I run it directly in console.google-chromewithout showing warning but the samegoogle-chromeshows warning when I run it directly in console. I checked version and path to executable inchrome://version/. But Selenim used more arguments in command line. I thought Selenium can downloaddriver, notbrowser. I would have to test it :)