0

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

4
  • funny thing: I see this message when I run google-chrome directly in console but I don't see it when I run Selenium. Maybe my Selenium uses chromium instead of google-chrome / chrome because chromium doesn't show this message when I run it directly in console. Commented Jul 6 at 13:10
  • @furas, Selenium will use Chrome or Chromium depending on which it finds it finds on your PATH. If it can't find either, it will download and use Chrome-for-Testing. Commented Jul 7 at 2:35
  • @CoreyGoldberg on my computer it can find both :) but it seems it used google-chrome without showing warning but the same google-chrome shows warning when I run it directly in console. I checked version and path to executable in chrome://version/. But Selenim used more arguments in command line. I thought Selenium can download driver, not browser. I would have to test it :) Commented Jul 7 at 2:43
  • @furas, it will pick up whichever browser appears on PATH first. Selenium can download browser and driver. Commented Jul 7 at 11:16

1 Answer 1

1

To suppress the startup warning message from Abseil (such as "All log messages before absl::InitializeLog() is called are written to STDERR"), note that this message is emitted by the native Chrome/Chromedriver binary, not by Selenium or your Python code. It is hardcoded at a lower system level (C++ logging) and is written directly to the terminal's stderr stream, bypassing Python’s sys.stderr.

Setting ChromeOptions with log-level, using environment variables like GLOG_minloglevel, or even redirecting sys.stderr in Python will not suppress it, because this message is not part of standard Python logging or Selenium output — it comes from compiled native libraries like Abseil or gRPC, used internally in newer Chromium builds (often related to voice recognition or media features).

There is currently no clean or officially supported way to suppress this warning unless:

  • You use a custom Chrome build without those features compiled in.

  • Or redirect Python’s entire process-level stderr using subprocess.Popen(..., stderr=subprocess.DEVNULL) or OS-level redirection, which is a workaround rather than a fix.

While annoying, the message is harmless and does not affect functionality. Until upstream Chromium suppresses it or adds a flag to disable it, the best option is to ignore or filter it from your logs if you're capturing stdout/stderr at a higher level.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.