selenium: [π Bug]: Unable to hide DevTools listening on ws
What happened?
Iβm working on a Selenium script to automate browser tasks, and Iβve run into an issue regarding the DevTools message. When I use the --headless option, the following message keeps appearing in the console:
βDevTools listening on ws://127.0.0.1:51481/devtools/browser/505e7f66-fd69-494b-a733-0cce438dec53β
However, the message successfully disappears when I remove the --headless option.
How can we reproduce the issue?
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ['enable-logging'])
options.add_argument("--log-level=3")
options.add_argument("start-maximized")
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
input("")
Relevant log output
DevTools listening on ws://127.0.0.1:51481/devtools/browser/505e7f66-fd69-494b-a733-0cce438dec53
Operating System
Windows 11
Selenium version
Python 3.11.4 selenium 4.15.1
What are the browser(s) and version(s) where you see this issue?
Chrome Version 119.0.6045.106 (Official Build) (64-bit)
What are the browser driver(s) and version(s) where you see this issue?
Chrome Version 119.0.6045.106 (Official Build) (64-bit)
Are you using Selenium Grid?
no
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 2
- Comments: 32 (13 by maintainers)
Fixed for me:
Output is now:
Nice and tidy. To anyone reading I downgraded to driver version 117 with:
options.set_capability("browserVersion", "117")
Full code example is:
This will disable the debug output for a short term fix. Thanks @titusfortner. You need anything else from me do let me know.
@titusfortner will do. If it makes a difference I actually updated selenium in an effort to fix this. It was an old install.
@TomKranenburg whenever we get the next release of Python out, it would be great if you could run it with logging on, I want to see what arguments the driver is getting started with.
hmm, would be nice if we logged the arguments we started the driver with. I can add that for a future release. So, makes sense it records it when driver starts. Driver & Browser versions match, which might have been an issue.
Iβm really not sure.
If you set
browser_version = "118"
or β117β do you still get it? Curious if something changed in the driver.Ohβ¦ maybe a windows thing
Hi there,
@titusfortner your reply dont work for me, the log still show up all errors and console output.
Add the exceptions worked for me:
options.add_argument(βlog-level=3β)
I see the message DevTools listening on ws://127.0.0.1 but the rest of the logs, dont show to me, its great.