Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable Firefox logging in Selenium using Geckodriver?

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.

like image 340
maxbfuer Avatar asked Dec 29 '16 22:12

maxbfuer


People also ask

Can we disable low level Geckodriver logs when we run Selenium script on Firefox?

New Selenium IDE After the execution of tests, there are logs generated because of Firefox logging in with geckodriver. This log generation by Firefox can be disabled by certain parameters setting. We can stop these logs from being recorded in the console and capture them in a different file.

Which Firefox browser needs Geckodriver in Selenium?

Selenium users must update to version 3.11 or later to use geckodriver.

What is Firefox Geckodriver?

GeckoDriver is a web browser engine which is used in many applications developed by Mozilla Foundation and the Mozilla Corporation. GeckoDriver is the link between your tests in Selenium and the Firefox browser. GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers.


1 Answers

To not see the logs in the console you can use the following:

System.setProperty("webdriver.gecko.driver","src/main/resources/drivers/geckodriver.exe");
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"/dev/null");

return new FirefoxDriver();
like image 73
Michael Medina Avatar answered Sep 21 '22 22:09

Michael Medina