How to set verbosity of marionette driver?

2019-03-02 02:03发布

问题:

Unable to manage verbosity of marionette driver!!

Environment:

Gecko driver 0.17.0
Selenium java 3.5.3
Firefox 52.3

Tried:

FirefoxOptions options = new FirefoxOptions();
options.addPreference("log", "{level: info}");
DesiredCapabilities ffCapabilities = DesiredCapabilities.firefox();
ffCapabilities.setCapability("moz:firefoxOptions", options);
ffCapabilities.setCapability("marionette", true);                                         
driver = new FirefoxDriver(ffCapabilities);

Log Info:

INFO: Preferring the firefox binary in these options (/Applications/Firefox.app/Contents/MacOS/firefox-bin rather than /Applications/Firefox.app/Contents/MacOS/firefox-bin)
Sep 01, 2017 3:41:19 PM org.openqa.selenium.firefox.FirefoxOptions toCapabilities
INFO: Preferring the firefox binary in these options (/Applications/Firefox.app/Contents/MacOS/firefox-bin rather than /Applications/Firefox.app/Contents/MacOS/firefox-bin)
1504276879424   geckodriver     INFO    Listening on 127.0.0.1:3902
1504276879955   addons.manager  DEBUG   Application has been upgraded
1504276879998   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1504276880006   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1504276880014   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm
1504276880017   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm
1504276880018   addons.manager  DEBUG   Starting provider: XPIProvider
1504276880019   addons.xpi      DEBUG   startup
1504276880019   addons.xpi      INFO    SystemAddonInstallLocation directory is missing
1504276880021   addons.xpi      INFO    Mapping aushelper@mozilla.org to /Applications/Firefox.app/Contents/Resources/browser/features/aushelper@mozilla.org.xpi
1504276880021   addons.xpi      INFO    Mapping e10srollout@mozilla.org to /Applications/Firefox.app/Contents/Resources/browser/features/e10srollout@mozilla.org.xpi
1504276880023   addons.xpi      INFO    Mapping firefox@getpocket.com to /Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi
1504276880024   addons.xpi      INFO    Mapping webcompat@mozilla.org to /Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi
1504276880025   addons.xpi      INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
1504276880026   addons.xpi      DEBUG   checkForChanges
1504276880027   addons.xpi      INFO    SystemAddonInstallLocation directory is missing
1504276880029   addons.xpi      DEBUG   Loaded add-on state from prefs: {}
1504276880031   addons.xpi      DEBUG   New add-on aushelper@mozilla.org in app-system-defaults
1504276880034   addons.xpi      DEBUG   getModTime: Recursive scan of aushelper@mozilla.org
1504276880035   addons.xpi      DEBUG   New add-on e10srollout@mozilla.org in app-system-defaults
1504276880036   addons.xpi      DEBUG   getModTime: Recursive scan of e10srollout@mozilla.org
1504276880037   addons.xpi      DEBUG   New add-on firefox@getpocket.com in app-system-defaults
1504276880038   addons.xpi      DEBUG   getModTime: Recursive scan of firefox@getpocket.com
1504276880038   addons.xpi      DEBUG   New add-on webcompat@mozilla.org in app-system-defaults
1504276880040   addons.xpi      DEBUG   getModTime: Recursive scan of webcompat@mozilla.org
1504276880043   addons.xpi      DEBUG   New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1504276880044   addons.xpi      DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1504276880045   addons.xpi      DEBUG   getInstallState changed: true, state: {"app-system-defaults":{"aushelper@mozilla.org":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/aushelper@mozilla.org.xpi","st":1504018117000},"e10srollout@mozilla.org":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/e10srollout@mozilla.org.xpi","st":1504018117000},"firefox@getpocket.com":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi","st":1504018117000},"webcompat@mozilla.org":{"d":"/Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi","st":1504018117000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","st":1504018117000}}}
1504276880065   addons.xpi-utils        DEBUG   Opening XPI database /var/folders/6x/hw5060n54m7gfvnvd9zn_9q40000gn/T/rust_mozprofile.cnQmhI7DMu0T/extensions.json
1504276880067   addons.xpi-utils        DEBUG   New add-on aushelper@mozilla.org installed in app-system-defaults
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1504276880091   DeferredSave.extensions.json    DEBUG   Save changes
1504276880093   addons.xpi-utils        DEBUG   New add-on e10srollout@mozilla.org installed in app-system-defaults
1504276880098   DeferredSave.extensions.json    DEBUG   Starting timer
1504276880101   DeferredSave.extensions.json    DEBUG   Save changes
1504276880102   addons.xpi-utils        DEBUG   New add-on firefox@getpocket.com installed in app-system-defaults
1504276880118   DeferredSave.extensions.json    DEBUG   Save changes
1504276880118   addons.xpi-utils        DEBUG   New add-on webcompat@mozilla.org installed in app-system-defaults
1504276880129   DeferredSave.extensions.json    DEBUG   Save changes
1504276880131   addons.xpi-utils        DEBUG   New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
1504276880136   DeferredSave.extensions.json    DEBUG   Save changes
1504276880137   addons.manager  DEBUG   Registering startup change 'installed' for aushelper@mozilla.org
1504276880160   addons.xpi      DEBUG   Loading bootstrap scope from /Applications/Firefox.app/Contents/Resources/browser/features/aushelper@mozilla.org.xpi
1504276880171   addons.xpi      DEBUG   Calling bootstrap method install on aushelper@mozilla.org version 2.0
1504276880174   addons.xpi-utils        DEBUG   Make addon app-system-defaults:aushelper@mozilla.org visible
1504276880176   DeferredSave.extensions.json    DEBUG   Save changes
1504276880177   addons.manager  DEBUG   Registering startup change 'installed' for e10srollout@mozilla.org
1504276880179   addons.xpi      DEBUG   Loading bootstrap scope from /Applications/Firefox.app/Contents/Resources/browser/features/e10srollout@mozilla.org.xpi
1504276880186   addons.xpi      DEBUG   Calling bootstrap method install on e10srollout@mozilla.org version 1.10
1504276880192   addons.xpi-utils        DEBUG   Make addon app-system-defaults:e10srollout@mozilla.org visible
1504276880201   DeferredSave.extensions.json    DEBUG   Save changes
1504276880204   addons.manager  DEBUG   Registering startup change 'installed' for firefox@getpocket.com
1504276880209   addons.xpi      DEBUG   Loading bootstrap scope from /Applications/Firefox.app/Contents/Resources/browser/features/firefox@getpocket.com.xpi
1504276880213   addons.xpi      DEBUG   Calling bootstrap method install on firefox@getpocket.com version 1.0.5
1504276880213   addons.xpi-utils        DEBUG   Make addon app-system-defaults:firefox@getpocket.com visible
1504276880214   DeferredSave.extensions.json    DEBUG   Save changes
1504276880215   addons.manager  DEBUG   Registering startup change 'installed' for webcompat@mozilla.org
1504276880217   addons.xpi      DEBUG   Loading bootstrap scope from /Applications/Firefox.app/Contents/Resources/browser/features/webcompat@mozilla.org.xpi
1504276880223   addons.xpi      DEBUG   Calling bootstrap method install on webcompat@mozilla.org version 1.0
1504276880225   addons.xpi-utils        DEBUG   Make addon app-system-defaults:webcompat@mozilla.org visible
1504276880229   DeferredSave.extensions.json    DEBUG   Save changes
1504276880230   addons.xpi-utils        DEBUG   Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible

回答1:

The default log level for geckodriver on release builds of Mozilla Firefox is set to INFO level. Perhaps your framework or the language binding you are using (Java) is overriding the default settings.

We can set the log level at either of the following levels:

  • All
  • CONFIG
  • FINE
  • FINER
  • FINEST
  • INFO
  • OFF
  • SEVERE
  • WARNING

Here is the code block to set log level to OFF:

package demo;

import java.util.logging.Level;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;

public class Gecko_TRACE_LOGS 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
        FirefoxOptions options = new FirefoxOptions();
        options.setLogLevel(Level.OFF);
        WebDriver driver =  new FirefoxDriver(options);
        driver.get("https://stackoverflow.com");
        System.out.println("Application opened");
        System.out.println("Page Title is : "+driver.getTitle());
        driver.quit();
    }
}