问题描述
我使用的是:
- firefox版本50.1.0
- geckodriver版本0.11.1
- selenium-java 3.0.1
我试过了
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(webdriver.log.browser.ignore,true);
profile.setPreference(webdriver.log.driver.ignore,true);
profile.setPreference(webdriver.log.profiler.ignore,true);
FirefoxDriver driver = new FirefoxDriver();
和
LoggingPreferences偏好设置= new LoggingPreferences();
preferences.enable(LogType.BROWSER,Level.OFF);
preferences.enable(LogType.CLIENT,Level.OFF);
preferences.enable(LogType.DRIVER,Level.OFF);
preferences.enable(LogType.PERFORMANCE,Level.OFF);
preferences.enable(LogType.SERVER,Level.OFF);
DesiredCapabilities功能= DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.LOGGING_PREFS,preferences);
FirefoxDriver驱动程序=新的FirefoxDriver(功能);
这些方法都不会做任何事情来停止记录。 对于那些疑惑的人,在我的 澄清:当我说记录我的意思是在IntelliJ IDEA的控制台输出。我正在使用Java。 您可以在geckodriver.exe中通过命令行定义所需的日志记录级别。 如果您使用selenium中的geckodriver,您有两个选项: $ ec $ OFF
这里是控制台的输出,如果有帮助的话:
.gecko.driver 系统属性:
$ b pom.xml
中有log4j 1.2.17,但没有 log4j.properties
或 log4j .xml
,我根本不使用它。
geckodriver.exe -help
用法:
geckodriver.exe [FLAGS] [OPTIONS]
...
选项:
--log< LEVEL>
设置Gecko日志级别[值:致命,错误,警告,信息,配置,
调试,跟踪]
ECHO启动geckodriver:
$ p <$ p $ b $ p $例子:geckodriver wrapper bat文件(用于windows) %0%*
。\ GeckoDriver \geckodriver.exe --log fatal%*>在Java中,您可以通过 webdriver来定义geckodriver可执行文件的路径,在 webdriver
System.setProperty(webdriver.gecko.driver,c: /selenium/geckodriver/gdrvwrapper.bat);
I am using:
- firefox version 50.1.0
- geckodriver version 0.11.1
- selenium-java 3.0.1
I have tried
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.log.browser.ignore", true);
profile.setPreference("webdriver.log.driver.ignore", true);
profile.setPreference("webdriver.log.profiler.ignore", true);
FirefoxDriver driver = new FirefoxDriver();
and
LoggingPreferences preferences = new LoggingPreferences();
preferences.enable(LogType.BROWSER, Level.OFF);
preferences.enable(LogType.CLIENT, Level.OFF);
preferences.enable(LogType.DRIVER, Level.OFF);
preferences.enable(LogType.PERFORMANCE, Level.OFF);
preferences.enable(LogType.SERVER, Level.OFF);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.LOGGING_PREFS, preferences);
FirefoxDriver driver = new FirefoxDriver(capabilities);
neither of these methods does anything to stop logging.Here is console output if that helps somehow:
- first method: http://pastebin.com/23nate2G
- second method: http://pastebin.com/NwmWEeXT
For those wondering, i have log4j 1.2.17 in my pom.xml
but have no log4j.properties
or log4j.xml
and I do not use it at all.
To clarify: when I say logging I mean the console output in IntelliJ IDEA. I am using Java.
You can define the desired logging level over command line in geckodriver.exe.
geckodriver.exe -help
USAGE:
geckodriver.exe [FLAGS] [OPTIONS]
...
OPTIONS:
--log <LEVEL>
Set Gecko log level [values: fatal, error, warn, info, config,
debug, trace]
If you use geckodriver from selenium, you have two option:
- Start geckodriver.exe separately with custom arguments, and use it from selenium over RemoteWebDriver
- Create a custom wrapper, to add extra parameters to geckodriver.exe
Example geckodriver wrapper bat file (for windows):
@ECHO OFF
ECHO Starting geckodriver: %0 %*
.\GeckoDriver\geckodriver.exe --log fatal %* > NUL 2>&1
In java you can define the geckodriver executable path, over webdriver.gecko.driver system property:
System.setProperty("webdriver.gecko.driver", "c:/selenium/geckodriver/gdrvwrapper.bat");
这篇关于如何使用Geckodriver在Selenium中禁用Firefox日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!