【问题标题】:How to hide cmd window with python selenium chromedriver如何使用 python selenium chromedriver 隐藏 cmd 窗口
【发布时间】:2020-11-02 17:40:53
【问题描述】:
当我运行我的 selenium 应用程序时,会弹出一个 cmd 窗口,然后是一个 chrome 窗口。我想隐藏 cmd 窗口。到目前为止,我已经尝试了来自this website 的代码和来自this question 的代码。他们都没有帮助。我还发现有人试图做this is C#。他似乎找到了解决办法。有没有办法在 python 中使用 selenium chromedriver 做到这一点?这是cmd窗口的图片:
我还想明确一点,在此窗口打开的情况下,应用程序运行完全正常。我只是认为没有它,该应用程序会更有用。
感谢您的时间和帮助。
【问题讨论】:
标签:
python
python-3.x
selenium
cmd
selenium-chromedriver
【解决方案1】:
我遇到了同样的问题。
更改参数值实际上对我有用。
位置:在虚拟环境\Lib\site-packages\selenium\webdriver\common内,找到services.py文件。
找到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)