关闭Selenium中的日志记录(从Python) [英] Turning off logging in Selenium (from Python)

查看:791
本文介绍了关闭Selenium中的日志记录(从Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近继承了一些用Python 2.7编写的Selenium Webdriver代码.它正在Ubuntu上将大量数据记录到/tmp-太多了,这已经成为一个问题.我正在尝试将其关闭(或至少关闭).

I've recently inherited some Selenium Webdriver code, written in Python 2.7. It is logging copious amounts of data to /tmp on Ubuntu - so much that it is becoming a problem. I am trying to turn it off (or at least down).

我一直在尝试RTFM,但这是Selenium(2.19.0)的新版本,手册尚未编写!

I have been running around trying to RTFM, but this is a new version of Selenium (2.19.0) and the manuals aren't written yet!

我可以看到有一种名为的方法set_browser_log_level(logLevel) 听起来很有希望,但是要实现它,我需要实例化一个selenium.selenium.selenium对象.否则我不必实例化其中之一,它不需要很多参数(哪个主机?哪个端口?).

I can see there is a method called set_browser_log_level(logLevel) which sounds promising, but to get to it, I need to instantiate a selenium.selenium.selenium object. I don't otherwise have to instantiate one of these, and it takes a lot of parameters (which host? what port?) that I am not expecting to have to provide.

很明显,我误会了一些东西.

Clearly, I am misunderstanding something.

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

Can someone please explain either (a) how to turn off logging, or (b) what service is it that selenium.selenium.selenium.selenium.selenium (I may have got carried away there, sorry!) wants to talk to?


相关问题:在Selenium中,如何关闭日志记录? 我相信这是Selenium的较旧版本,我相信它是从脚本语言调用的.


Related question: In Selenium, how do I turn off logging? This is an older version of Selenium, and calling it from the scripting language, I believe.

推荐答案

以下是帮助我克服问题的方法:

Here's what helped me to overcome the problem:

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

注意:此代码应放在webdriver初始化之前.

Note: this code should be put before webdriver initialization.

希望有帮助.

这篇关于关闭Selenium中的日志记录(从Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆