Python selenium: DevTools listening on ws://127.0.0.1
Asked Answered
I

5

31

Today I got this message on the console when running selenium using the chromedriver. How do I suppress this?

DevTools listening on ws://127.0.0.1:12740/devtools/browser/97101fe4-3b1f-42b0-b5c8-373cc18040b6

Relevant code:

from selenium import webdriver
driver = webdriver.Chrome(executable_path='c:/bin/chromedriver233')

I get the same message using version 2.30 of chromedriver.

I have not previously received this message. The only change I've made is updating chrome to Version 62.0.3202.94 (Official Build) (64-bit)

Python 3.6.3 64, selenium 3.4.3, Windows 7 64.

EDIT: I posted a question to the Chrome product forum at https://productforums.google.com/forum/#!topic/chrome/Dlk2j_JpmxE;context-place=forum/chrome

Infantilism answered 20/11, 2017 at 12:46 Comment(1)
Possible duplicate of Chrome devmode suddenly turning on in seleniumBrightness
M
67

I had the same issue, did a bit of digging and finally found a working solution. This should remove the DevTools message popping up:

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path='<path-to-chrome>', options=options)

As per the solution from this chromium issue.

Melisa answered 1/6, 2019 at 17:10 Comment(5)
If you are using C#, use: codeoptions.AddExcludedArgument("enable-logging");codeUnroll
I'm trying this in 9/29/22 and this is not working. Other attempts such as: options.add_argument('--log-level=3') options.add_argument('--disable-extensions') ; Did not work as wellAgglutinative
For future googlers, executable_path is now deprecated, instead you can put the chromedriver in the chrome install path and just omit the executable_path parameter. Everything else in the answer is still the sameDioptase
As at 03 May '23, this works great | chromedriver\win32\112.0.5615.49 using webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)Hermilahermina
only the second like should be enough, no? I can't get it to work in javascript.Fosterling
S
0

Not sure if you are aware but try:

options.add_argument('--log-level=3')

Mind you I'm using headless, though I believe you could configure this for normal browser. It feels better :). I was amazed at how annoying that notification message was.

Serious answered 20/11, 2017 at 23:36 Comment(9)
Alas, that didn't help, I still got the message.Infantilism
@Infantilism Did you try what I referenced with the link word for word, it works for me.Serious
@Infantilism This is likely attributed to new chrome. I have done a fresh reinstall and I cannot get it to work either. Interesting, this command used to work. I wonder whySerious
@Infantilism I am curious to ask them but I can't comment as I'm not 50. Ask them if updating chrome gave issue. Otherwise there's something I'm missingSerious
@ tyson dogerzonda I believe it was updating to the latest chrome that caused the problem, as it was working fine last week and that was my only change. Who should I ask?Infantilism
@Infantilism I'm not sure either. I've tried suppressing console output, cmd. But I believe it's likely a chrome issue. So perhaps try using older chrome but that's not really viable long term either. I suppose you'll have to just put up with it. There might be a way to get around it through chrome options but I cannot find much on this issue. I believe its a new issue so not much to findSerious
with luck they'll fix selenium or the chromedriverInfantilism
@Infantilism I should hope so. Maybe report it on chrome forums and I'm sure there's some out there who knows how to fix this. Just a matter of asking question to right person I guess or building a tolerance to annoying messages. Whichever works :)Serious
I am facing the same issue with 64.0.3282.186. Any luck?Inadvisable
D
0

It might be due to chromedriver no longer supports chrome version installed on your machine. Update your Chromedriver to more up to date version.

Dungeon answered 10/2, 2020 at 9:25 Comment(0)
S
0

try adding the second and third lines to your code and you should be able to see the devtools messages in your command prompt.

chrome_options=webdriver.ChromeOptions() chrome_options.add_experimental_option('excludeSwitch',['enable-logging']) chrome_options.add_argument('--log-level=3') driver=webdriver.Chrome(executable_path='<path_of_chrome-driver>', options=chrome_options)

Sextuple answered 11/1 at 11:4 Comment(0)
D
-5

a workaround: :)

sys.stdout.write("\033[F") #back to previous line
sys.stdout.write("\033[K") #clear line
Detach answered 11/12, 2019 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.