How to disable Marionette / gecko driver logs in selenium 3

I need to disable Marionette / GeckoDriver logging; is there any way to do this? I searched a lot, but I did not get the right answer. INFO Magazines:

1484653905833 geckodriver INFO Listening on 127.0.0.1:15106 Jan 17, 2017 5:21:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Attempting bi-dialect session, assuming Postel Law holds true on the remote end 1484653906715 mozprofile::profile INFO Using profile path C:\Users\vtiger\AppData\Local\Temp\3\rust_mozprofile.7d2LEwDKoE8J 1484653906720 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe 1484653906731 geckodriver::marionette INFO Connecting to Marionette on localhost:58602 1484653908388 addons.manager DEBUG Application has been upgraded 1484653908843 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"] 1484653908846 addons.manager DEBUG Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"] 1484653908852 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm 1484653908855 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm 1484653908857 addons.manager DEBUG Starting provider: XPIProvider 1484653908857 addons.xpi DEBUG startup 1484653908858 addons.xpi INFO SystemAddonInstallLocation directory 

How to disable this logging?

+10
source share
6 answers

I tried the following code but did not work. bug seems to be in selenium 3.0

  LoggingPreferences pref = new LoggingPreferences(); pref.enable(LogType.BROWSER, Level.OFF); pref.enable(LogType.CLIENT, Level.OFF); pref.enable(LogType.DRIVER, Level.OFF); pref.enable(LogType.PERFORMANCE, Level.OFF); pref.enable(LogType.PROFILER, Level.OFF); pref.enable(LogType.SERVER, Level.OFF); DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox(); desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, pref); WebDriver driver = new FirefoxDriver(desiredCapabilities); driver.get("https://www.google.com/"); driver.findElement(By.id("lst-ib")).sendKeys("something"); Thread.sleep(2000); driver.quit(); 
+3
source

You can use the following lines of code to not display puppet logs:

 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(); 
+22
source

One option that worked for some is suggested here and uses a batch file to pass into the command line arguments to the executable. Unfortunately, this often leads to the discovery of additional processes (geckodriver.exe, cmd.exe), and a solution to this next problem has not yet been proposed ...

+2
source
  GeckoDriverService gecko = new GeckoDriverService(new File("c:/selenium/geckodriver.exe"), 4444, ImmutableList.of("--log=fatal"), ImmutableMap.of()); gecko.sendOutputTo(new FileOutputStream("gecko_log.txt")); gecko.start(); FirefoxOptions opts = new FirefoxOptions().setLogLevel(Level.OFF); DesiredCapabilities capabilities = opts.addTo(DesiredCapabilities.firefox()); capabilities.setCapability("marionette", true); FirefoxDriver driver = new FirefoxDriver(gecko, capabilities); 
+1
source

If you don't need gecko driver logs, you can simply add this line before:

System.setProperty (FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "false");

and then start with this part:

driver = new FirefoxDriver ();

+1
source

A working solution on Windows and Linux.

 # python 3 # windows PATH_TO_DEV_NULL = 'nul' FIREFOX_DRIVER_PATH = 'D:\\path\\to\\geckodriver.exe' # linux PATH_TO_DEV_NULL = '/dev/null' FIREFOX_DRIVER_PATH = '/path/to/geckodriver' # start browser driver = webdriver.Firefox(executable_path=FIREFOX_DRIVER_PATH, service_log_path=PATH_TO_DEV_NULL) 
0
source

Source: https://habr.com/ru/post/1262926/


All Articles