Python: How to hide output message?











up vote
1
down vote

favorite
1












What I want to do:



I want to open chrome browser using selenium-chromeDriver.



What I did:



from selenium import webdriver
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Output:



C:Usersu1Documentsscripts>python test.py

DevTools listening on ws://127.0.0.1:50605/devtools/browser/11c9063a-44ce-4b39-9566-9e6c6270025c


What I tried to solve this:



I wanted to hide the output message "DevTools listening on ... "



Using contextlib



from selenium import webdriver
import contextlib

with contextlib.redirect_stdout(None):
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Using devnull



from selenium import webdriver
import subprocess

devnull = subprocess.DEVNULL
subprocess.Popen(open_browser(), stdout=devnull, stderr=devnull)
def open_browser():
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


But still the message is getting displayed. How to hide the output message "DevTools listening on ... " in python?










share|improve this question






















  • Check this discussion stackoverflow.com/questions/52245604/…
    – DebanjanB
    Nov 19 at 11:22










  • I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 12:45















up vote
1
down vote

favorite
1












What I want to do:



I want to open chrome browser using selenium-chromeDriver.



What I did:



from selenium import webdriver
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Output:



C:Usersu1Documentsscripts>python test.py

DevTools listening on ws://127.0.0.1:50605/devtools/browser/11c9063a-44ce-4b39-9566-9e6c6270025c


What I tried to solve this:



I wanted to hide the output message "DevTools listening on ... "



Using contextlib



from selenium import webdriver
import contextlib

with contextlib.redirect_stdout(None):
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Using devnull



from selenium import webdriver
import subprocess

devnull = subprocess.DEVNULL
subprocess.Popen(open_browser(), stdout=devnull, stderr=devnull)
def open_browser():
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


But still the message is getting displayed. How to hide the output message "DevTools listening on ... " in python?










share|improve this question






















  • Check this discussion stackoverflow.com/questions/52245604/…
    – DebanjanB
    Nov 19 at 11:22










  • I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 12:45













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





What I want to do:



I want to open chrome browser using selenium-chromeDriver.



What I did:



from selenium import webdriver
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Output:



C:Usersu1Documentsscripts>python test.py

DevTools listening on ws://127.0.0.1:50605/devtools/browser/11c9063a-44ce-4b39-9566-9e6c6270025c


What I tried to solve this:



I wanted to hide the output message "DevTools listening on ... "



Using contextlib



from selenium import webdriver
import contextlib

with contextlib.redirect_stdout(None):
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Using devnull



from selenium import webdriver
import subprocess

devnull = subprocess.DEVNULL
subprocess.Popen(open_browser(), stdout=devnull, stderr=devnull)
def open_browser():
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


But still the message is getting displayed. How to hide the output message "DevTools listening on ... " in python?










share|improve this question













What I want to do:



I want to open chrome browser using selenium-chromeDriver.



What I did:



from selenium import webdriver
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Output:



C:Usersu1Documentsscripts>python test.py

DevTools listening on ws://127.0.0.1:50605/devtools/browser/11c9063a-44ce-4b39-9566-9e6c6270025c


What I tried to solve this:



I wanted to hide the output message "DevTools listening on ... "



Using contextlib



from selenium import webdriver
import contextlib

with contextlib.redirect_stdout(None):
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


Using devnull



from selenium import webdriver
import subprocess

devnull = subprocess.DEVNULL
subprocess.Popen(open_browser(), stdout=devnull, stderr=devnull)
def open_browser():
driver = webdriver.Chrome(r'C:Usersu1Documentsscriptschromedriver.exe')


But still the message is getting displayed. How to hide the output message "DevTools listening on ... " in python?







python python-3.x selenium selenium-webdriver selenium-chromedriver






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 10:21









Dipankar Nalui

2161416




2161416












  • Check this discussion stackoverflow.com/questions/52245604/…
    – DebanjanB
    Nov 19 at 11:22










  • I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 12:45


















  • Check this discussion stackoverflow.com/questions/52245604/…
    – DebanjanB
    Nov 19 at 11:22










  • I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 12:45
















Check this discussion stackoverflow.com/questions/52245604/…
– DebanjanB
Nov 19 at 11:22




Check this discussion stackoverflow.com/questions/52245604/…
– DebanjanB
Nov 19 at 11:22












I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
– Dipankar Nalui
Nov 19 at 12:45




I already checked that answer. That answer did not solve this issue. So, I try to solve it in a different way.
– Dipankar Nalui
Nov 19 at 12:45












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Those are chrome messages, so you need to set the options for the Chrome-Log Level to hide those messages, setting the log-level to --log-level=3 should be enough (only fatal log messages.



from selenium.webdriver.chrome.options import Options
[...]
chrome-options = Options()
chrome-options.add_argument("--log-level=3")
driver = webdriver.Chrome(chrome_options=chrome-options)


Also out of curiosity, might I ask why?






share|improve this answer





















  • I already used this code. That message is still displayed. This does not solve my problem.
    – Dipankar Nalui
    Nov 19 at 10:49










  • I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 10:51










  • Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
    – Bernhard
    Nov 19 at 12:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372520%2fpython-how-to-hide-output-message%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Those are chrome messages, so you need to set the options for the Chrome-Log Level to hide those messages, setting the log-level to --log-level=3 should be enough (only fatal log messages.



from selenium.webdriver.chrome.options import Options
[...]
chrome-options = Options()
chrome-options.add_argument("--log-level=3")
driver = webdriver.Chrome(chrome_options=chrome-options)


Also out of curiosity, might I ask why?






share|improve this answer





















  • I already used this code. That message is still displayed. This does not solve my problem.
    – Dipankar Nalui
    Nov 19 at 10:49










  • I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 10:51










  • Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
    – Bernhard
    Nov 19 at 12:01















up vote
0
down vote













Those are chrome messages, so you need to set the options for the Chrome-Log Level to hide those messages, setting the log-level to --log-level=3 should be enough (only fatal log messages.



from selenium.webdriver.chrome.options import Options
[...]
chrome-options = Options()
chrome-options.add_argument("--log-level=3")
driver = webdriver.Chrome(chrome_options=chrome-options)


Also out of curiosity, might I ask why?






share|improve this answer





















  • I already used this code. That message is still displayed. This does not solve my problem.
    – Dipankar Nalui
    Nov 19 at 10:49










  • I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 10:51










  • Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
    – Bernhard
    Nov 19 at 12:01













up vote
0
down vote










up vote
0
down vote









Those are chrome messages, so you need to set the options for the Chrome-Log Level to hide those messages, setting the log-level to --log-level=3 should be enough (only fatal log messages.



from selenium.webdriver.chrome.options import Options
[...]
chrome-options = Options()
chrome-options.add_argument("--log-level=3")
driver = webdriver.Chrome(chrome_options=chrome-options)


Also out of curiosity, might I ask why?






share|improve this answer












Those are chrome messages, so you need to set the options for the Chrome-Log Level to hide those messages, setting the log-level to --log-level=3 should be enough (only fatal log messages.



from selenium.webdriver.chrome.options import Options
[...]
chrome-options = Options()
chrome-options.add_argument("--log-level=3")
driver = webdriver.Chrome(chrome_options=chrome-options)


Also out of curiosity, might I ask why?







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 10:23









Bernhard

847115




847115












  • I already used this code. That message is still displayed. This does not solve my problem.
    – Dipankar Nalui
    Nov 19 at 10:49










  • I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 10:51










  • Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
    – Bernhard
    Nov 19 at 12:01


















  • I already used this code. That message is still displayed. This does not solve my problem.
    – Dipankar Nalui
    Nov 19 at 10:49










  • I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
    – Dipankar Nalui
    Nov 19 at 10:51










  • Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
    – Bernhard
    Nov 19 at 12:01
















I already used this code. That message is still displayed. This does not solve my problem.
– Dipankar Nalui
Nov 19 at 10:49




I already used this code. That message is still displayed. This does not solve my problem.
– Dipankar Nalui
Nov 19 at 10:49












I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
– Dipankar Nalui
Nov 19 at 10:51




I googled and found this same solution earlier. Many people suggested this solution in stackoverflow. But this did not solve my problem. So, I wanted to solve it in a different way.
– Dipankar Nalui
Nov 19 at 10:51












Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
– Bernhard
Nov 19 at 12:01




Thought that would help. btw I'd put the fact that you found a "solution" that worked for somebody else and that it did not work for you in the question with a link.
– Bernhard
Nov 19 at 12:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372520%2fpython-how-to-hide-output-message%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Costa Masnaga