鼻子跳过调试消息
Nose skip debug messages
我开始使用 selenium 作为
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
但它不起作用
问题出在硒中。我添加了几行代码,这解决了问题。
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING) # this line should be before webdriver initialization
我开始使用 selenium 作为
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
但它不起作用
问题出在硒中。我添加了几行代码,这解决了问题。
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING) # this line should be before webdriver initialization