鼻子跳过调试消息

时间:2017-03-20 11:28:33

标签: python selenium testing nose

我用硒开始测试鼻涕

python my_test.py  --tests=my_test --with-xunit  --xunit-file=my_output.xml

我得到了很多无用的输出,如:

selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:42919/session/23784289y34ui2hi2u3hi2u/elements {"using": "xpath", "sessionId": "23784289y34ui2hi2u3hi2u", "value": "//span[@class='somename']"}
selenium.webdriver.remote.remote_connection: DEBUG: Finished Request
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:22919/session/2i3ur2oirhi2u3hri2uhri/element/0.37232323248244116-1/click {"sessionId": "2i3ur2oirhi2u3hri2uhri", "id": "0.37232323248244116-1"}

如何跳过所有这些调试消息并仅获取有关错误的消息? 我曾尝试使用--logging-level=ErrorDefault,但它不起作用

1 个答案:

答案 0 :(得分:1)

问题在于硒。我添加了几行代码,这解决了这个问题。

import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING) # this line should be before webdriver initialization