python - 更改 Geckodriver for Python Selenium 的日志级别

标签 python selenium firefox geckodriver

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

我想阻止这一切发生。我查看了各种 Github 线程以寻找答案,但找不到适用于 Firefox for Python 的任何内容。我在 geckodriver --help 中可以找到的是将日志级别设置为以下任何一项:

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

但是,我不确定该怎么做。也许对 webdriver.Firefox() 使用 desired_capabilitiesservice_args 之类的东西?

最佳答案

这对我有用 icw geckodriver 0.19.1

from selenium.webdriver.firefox.options import Options

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

关于python - 更改 Geckodriver for Python Selenium 的日志级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43102811/

相关文章:

python - 使用 psycopg2 删除索引在提交之前或之后生效?

python - pytorch autograd 阻止脚本终止

python - 如何将一系列对象转换为单个 DataFrame?

python - Selenium Python : clicking links produced by JSON application

java - 如何在 Java 中使用 Selenium webdriver 下载 .docx 文件?

python - Internet Explorer WebDriver 未在机器人框架中启动

css - 在 div 中时,表单字段在 firefox 上不起作用

jquery - 为什么 jQuery.position() 在 webkit 和 firefox/MSIE 之间表现不同

python - select from where mysql 语句中的语法错误

javascript - 检测 Firefox 插件何时被阻止