1

无法管理木偶司机的冗长!

环境:

Gecko driver 0.17.0
Selenium java 3.5.3
Firefox 52.3

试过:

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);

日志信息:

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
4

1 回答 1

1

geckodriverMozilla Firefox 发布版本的默认日志级别设置为INFOlevel。也许您的框架或您正在使用的语言绑定 ( Java) 覆盖了默认设置。

我们可以将日志级别设置为以下任一级别:

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

这是将日志级别设置为的代码块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();
    }
}
于 2017-09-02T11:08:04.170 回答