关闭登录Selenium(来自Python)

2024-04-16 16:37:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近继承了一些Selenium Webdriver代码,是用Python 2.7编写的。它将大量数据记录到Ubuntu上的/tmp中,以至于它成为了一个问题。我想把它关掉(或者至少关小点)。

我一直在尝试RTFM,但这是Selenium(2.19.0)的新版本,手册还没有写好!

我可以看到有一个名为^{}的方法听起来很有前途,但是要实现它,我需要实例化一个selenium.selenium.selenium对象。否则我不需要实例化其中一个,它需要很多参数(哪个主机?哪个港口?)我不想提供。

显然,我有点误会。

有人能解释一下(a)如何关闭日志记录,或者(b)selenium.selenium.selenium.selenium.selenium是什么服务吗(我可能已经忘乎所以了,对不起!)想谈谈吗?


相关问题:In Selenium, how do I turn off logging? 这是Selenium的一个旧版本,我相信它是从脚本语言调用的。

Tags: 数据实例方法代码版本ubuntuselenium记录
3条回答

你用伐木机吗?我也有类似的问题? 我使用了一个简单的logging.basicConfig,但是Selenium也这样做。 我的解决方案是定义自己的记录器。

也许你可以打印一些代码样本。

import logging
selenium_logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
# Only display possible problems
selenium_logger.setLevel(logging.WARNING)

以下是帮助我克服这个问题的原因:

import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING)

注意:这个代码应该放在webdriver初始化之前。

希望能有所帮助。

相关问题 更多 >