为Python Selenium更改Geckodriver的日志级别

2024-09-27 21:28:45 发布

您现在位置:Python中文网/ 问答频道 /正文

似乎Selenium 3.0及以上版本需要geckodriver,而我现在已经安装了python2.7.下的Firefox。但是,使用Firefox运行Selenium现在会自动在运行Python脚本的目录中创建文件geckodriver.log。在

我想阻止这一切发生。我查看了各种各样的Github线程来寻找答案,但是没有找到适合firefoxforpython的任何东西。我可以在geckodriver --help中找到的方法是将日志级别设置为以下任意值:

   --log <LEVEL>
        Set Gecko log level [values: fatal, error, warn, info, config, debug,
        trace]

但是,我不知道该怎么做。用什么来代替cd6?在


Tags: 文件方法答案版本github目录脚本log
2条回答

这对我来说是个好主意,壁虎0.19.1

from selenium.webdriver.firefox.options import Options

opties = Options()
opties.log.level = 'trace'
browser = webdriver.Firefox(options=opties)

我只是在尝试增加这个日志级别时遇到了麻烦,但是阻止它记录任何内容的最简单方法是重定向到/tmp(甚至是/dev/null):

webdriver.Firefox(log_path='/tmp/geckodriver.log')

相关问题 更多 >

    热门问题