Python中的硒单元测试-我的日志文件在哪里? [英] Selenium unit tests in Python -- where is my log file?
问题描述
因此,我将一些单元测试从Selenium IDE导出到了Python.现在,我正在尝试调试某些内容,并且我注意到Selenium使用logging
模块.我真的很想在selenium.webdriver.remote.remote_connection
中有一行特定的输出.它是:
So I exported some unit tests from the Selenium IDE to Python. Now I'm trying to debug something, and I've noticed that Selenium uses the logging
module. There is one particular line in selenium.webdriver.remote.remote_connection
that I would really like to see the output of. It is:
LOGGER.debug('%s %s %s' % (method, url, data))
文件顶部的另一行显示:
At the top of the file is another line that reads:
LOGGER = logging.getLogger(__name__)
那么该日志文件在哪里?我想看看.
So where is this log file? I want to look at it.
推荐答案
在单元测试脚本中,放置
In your unit test script, place
import logging
logging.basicConfig(filename = log_filename, level = logging.DEBUG)
其中log_filename
是您想要将日志文件写入的位置的路径.
where log_filename
is a path to wherever you'd like the log file written to.
如果没有调用logging.basicConfig
或进行类似的调用来设置日志记录处理程序,则LOGGER.debug
命令将不执行任何操作.
Without the call to logging.basicConfig
or some such call to setup a logging handler, the LOGGER.debug
command does nothing.
这篇关于Python中的硒单元测试-我的日志文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!