关闭登录 Selenium(来自 Python) [英] Turning off logging in Selenium (from Python)

查看:29
本文介绍了关闭登录 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天全站免登陆