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)

Most upvoted comments

Fixed for me:

Selenium Manager binary found at: C:\Python310\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe
Executing process: C:\Python310\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser MicrosoftEdge --browser-version 117 --debug --output json
msedgedriver not found in PATH
MicrosoftEdge detected at C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
Running command: wmic datafile where name='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' get Version /value
Output: "\r\r\n\r\r\nVersion=119.0.2151.44\r\r\n\r\r\n\r\r\n\r"
Detected browser: MicrosoftEdge 119.0.2151.44
Discovered MicrosoftEdge version (119) different to specified browser version (117)
Checking MicrosoftEdge releases on https://edgeupdates.microsoft.com/api/products/?view=enterprise
Required browser: MicrosoftEdge 117.0.2045.60
Downloading MicrosoftEdge 117.0.2045.60 from https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/04953c72-9e0d-420a-950c-15e0e659a225/MicrosoftEdgeEnterpriseX64.msi
Installing MicrosoftEdgeEnterpriseX64.msi
MicrosoftEdge 117.0.2045.60 is available at C:\Program Files (x86)\Microsoft\Edge\Application\117.0.2045.60\msedge.exe
Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_117_WINDOWS
Required driver: msedgedriver 117.0.2045.60
Downloading msedgedriver 117.0.2045.60 from https://msedgedriver.azureedge.net/117.0.2045.60/edgedriver_win64.zip
Driver path: C:\Users\Citadel\.cache\selenium\msedgedriver\win64\117.0.2045.60\msedgedriver.exe
Browser path: C:\Program Files (x86)\Microsoft\Edge\Application\117.0.2045.60\msedge.exe
Using driver at: C:\Users\Citadel\.cache\selenium\msedgedriver\win64\117.0.2045.60\msedgedriver.exe
Started executable: `C:\Users\Citadel\.cache\selenium\msedgedriver\win64\117.0.2045.60\msedgedriver.exe` in a child process with pid: 26052
POST http://localhost:61619/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "MicrosoftEdge", "pageLoadStrategy": "normal", "browserVersion": null, "ms:edgeOptions": {"excludeSwitches": ["enable-logging"], "extensions": [], "binary": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\117.0.2045.60\\msedge.exe", "args": ["--log-level=3", "--headless", "start-maximized"]}}}}
Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"msedge","browserVersion":"117.0.2045.60","fedcm:accounts":true,"ms:edgeOptions":{"debuggerAddress":"localhost:61815"},"msedge":{"msedgedriverVersion":"117.0.2045.60 (a31cef5dc4c1f66dc0bb957c3250ba527e99b945)","userDataDir":"C:\\Windows\\SystemTemp\\scoped_dir26052_679090411"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:extension:minPinLength":true,"webauthn:extension:prf":true,"webauthn:virtualAuthenticators":true},"sessionId":"155950ccf5ff262896e5a230ff91081b"}} | headers=HTTPHeaderDict({'Content-Length': '831', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
Finished Request
DELETE http://localhost:61619/session/155950ccf5ff262896e5a230ff91081b {}
Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
Finished Request

Output is now:

ConEmu64_DTseq0OkVs

Nice and tidy. To anyone reading I downgraded to driver version 117 with:

options.set_capability("browserVersion", "117")

Full code example is:

from selenium import webdriver

options = webdriver.EdgeOptions()
options.add_experimental_option("excludeSwitches", ['enable-logging'])
options.add_argument("--log-level=3")
options.add_argument("--headless")
options.set_capability("browserVersion", "117")
options.add_argument("start-maximized")

driver = webdriver.Edge(options=options)
driver.quit()

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.