python - 如何通过 selenium p 隐藏 chromedriver 登录控制台

标签 python python-3.x selenium windows-10 selenium-chromedriver

如何隐藏控制台窗口?

我在 GUI 应用程序中使用 headless Chrome 和 Selenium 从一个网页中抓取数据。
启动应用程序时,打开控制台窗口,然后显示 chromedriver 的日志。

有没有办法在启动应用程序时隐藏控制台上的 chromedriver 登录?

操作系统:windows10
python :3.6.3
Selenium 3.8.0
chromedriver:2.33
Google Chrome 金丝雀

最佳答案

Lib\site-packages\selenium\webdriver\common\services.py文件中

服务类别中

在 func start 中添加creationflags参数

try:
        cmd = [self.path]
        cmd.extend(self.command_line_args())
        self.process = subprocess.Popen(cmd, env=self.env,
                                       close_fds=platform.system() != 'Windows', 
                                       stdout=self.log_file, 
                                       stderr=self.log_file,
                                       creationflags=0x08000000,
                                       stdin=PIPE)
except TypeError: ...

关于python - 如何通过 selenium p 隐藏 chromedriver 登录控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47755571/

相关文章:

python - 将 Python 3 ResourceWarnings 转换为异常

python - 无法使用 selenium 取消选择已选择的空白区域

ruby - 无法使用 Selenium WebDriver 在 Safari 中单击按钮

java - 使用 ChromeDriver 和 Chrome 通过 CLI 执行测试时出现 NoSuchMethodError : com. google.common.base.Preconditions.checkState(ZLjava/lang/String;)

python - Docker 容器正在运行。但页面在本地主机 URL 中不起作用(页面未发送任何数据)

python - 安装枕头 - 错误 : ld returned 1 - windows

Python:SocketServer没有套接字

java - 拖放没有发生

python - Numpy 选择 : shape-mismatch error

python - 如何在 Networkx 中绘制图形的长度