简体   繁体   English

如何使用python selenium chromedriver隐藏cmd窗口

[英]How to hide cmd window with python selenium chromedriver

When I run my selenium application, a cmd window pops up, followed by a chrome window.当我运行 selenium 应用程序时,会弹出一个 cmd 窗口,然后是一个 chrome 窗口。 I want to hide the cmd window.我想隐藏 cmd 窗口。 So far I have tried code from this website and code from this question .到目前为止,我已经尝试过来自这个网站的代码和来自这个问题的代码。 None of them helped.他们都没有帮助。 I also found someone trying to do this is C# .我还发现有人试图这样做是 C# He seemed to find a solution.他似乎找到了解决办法。 Is there a way to do this in python with selenium chromedriver?有没有办法在 python 中使用 selenium chromedriver 做到这一点? Here is a picture of the cmd window:这是cmd窗口的图片:

弹出的cmd窗口

I also want to make it clear that the app runs completely fine with this window open.我还想明确指出,该应用程序在此窗口打开时完全正常运行。 I just think the app would more usable without it.我只是认为没有它该应用程序会更有用。

Thanks for your time and help.感谢您的时间和帮助。

I met the same problem.我遇到了同样的问题。 Change a parameter value actually works for me.更改参数值实际上对我有用。

Location: inside virtual environment \\Lib\\site-packages\\selenium\\webdriver\\common , find the services.py file.位置:在虚拟环境\\Lib\\site-packages\\selenium\\webdriver\\common ,找到services.py文件。
Find the start() function, add parameter creationflags=134217728 .找到start()函数,添加参数creationflags=134217728

   self.process = subprocess.Popen(cmd, env=self.env,
                                   close_fds=platform.system() != 'Windows',
                                   stdout=self.log_file,
                                   stderr=self.log_file,
                                   stdin=PIPE,creationflags=134217728)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM