28

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

foosion
  • 7,619
  • 25
  • 65
  • 102
  • 1
    Possible duplicate of [Chrome devmode suddenly turning on in selenium](https://stackoverflow.com/questions/46423361/chrome-devmode-suddenly-turning-on-in-selenium) – Walter Feb 12 '18 at 10:05

4 Answers4

61

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.

Enioluwa Segun
  • 911
  • 8
  • 12
  • If you are using C#, use: `code`options.AddExcludedArgument("enable-logging");`code` – Suneth Thotagamuwa Jul 08 '21 at 13:10
  • 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 well – Brad123 Sep 29 '22 at 17:22
  • 1
    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 same – mrblue6 Mar 10 '23 at 00:15
  • As at 03 May '23, this works great | chromedriver\win32\112.0.5615.49 using `webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)` – semmyk-research May 03 '23 at 17:08
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.

  • 1
    Alas, that didn't help, I still got the message. – foosion Nov 21 '17 at 15:40
  • @foosion Did you try what I referenced with the link word for word, it works for me. –  Nov 21 '17 at 22:11
  • @foosion 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 why –  Nov 21 '17 at 22:51
  • @foosion 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 missing –  Nov 21 '17 at 22:52
  • @ 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? – foosion Nov 22 '17 at 00:01
  • 1
    @foosion 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 find –  Nov 22 '17 at 00:03
  • with luck they'll fix selenium or the chromedriver – foosion Nov 22 '17 at 00:07
  • @foosion 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 :) –  Nov 22 '17 at 00:12
  • I am facing the same issue with 64.0.3282.186. Any luck? – Mohy Eldeen Aug 04 '18 at 01:24
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.

Rob
  • 415
  • 4
  • 12
-5

a workaround: :)

sys.stdout.write("\033[F") #back to previous line
sys.stdout.write("\033[K") #clear line
Dude80
  • 1