Python中的硒单元测试-我的日志文件在哪里? [英] Selenium unit tests in Python -- where is my log file?

查看:70
本文介绍了Python中的硒单元测试-我的日志文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我将一些单元测试从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆