我用硒开始测试鼻涕
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=Error
或Default
,但它不起作用
答案 0 :(得分:1)
问题在于硒。我添加了几行代码,这解决了这个问题。
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING) # this line should be before webdriver initialization