Disable log trace in Marionette driver

可紊 提交于 2019-12-06 04:57:50

问题


When MarionetteDriver is launched it's print log statement for each and every operation.Like

1465882610065   Marionette  TRACE   conn0 -> [0,138,"executeScript",{"args":[],"newSandbox":false,"script":"return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight,document.body.offsetHeight, document.documentElement.offsetHeight,document.body.clientHeight, document.documentElement.clientHeight);","scriptTimeout":null,"specialPowers":false}]
1465882610066   Marionette  TRACE   conn0 <- [1,138,null,{"value":895}]
1465882610070   Marionette  TRACE   conn0 -> [0,139,"executeScript",{"args":[],"newSandbox":false,"script":"window.devicePixelRatio = window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI; var pr = window.devicePixelRatio; if (pr != undefined && pr != null) return pr; else return 1.0;","scriptTimeout":null,"specialPowers":false}]
1465882610071   Marionette  TRACE   conn0 <- [1,139,null,{"value":1}]
1465882610319   Marionette  TRACE   conn0 -> [0,140,"findElements",{"using":"css selector","value":".logOut"}]
1465882610321   Marionette  TRACE   conn0 <- [1,140,null,[{"element-6066-11e4-a52e-4f735466cecf":"f9d9adc3-58df-446a-953d-eb793ac27025","ELEMENT":"f9d9adc3-58df-446a-953d-eb793ac27025"}]]
1465882610325   Marionette  TRACE   conn0 -> [0,141,"isElementDisplayed",{"id":"f9d9adc3-58df-446a-953d-eb793ac27025"}]
1465882610335   Marionette  TRACE   conn0 <- [1,141,null,{"value":true}]
1465882610338   Marionette  TRACE   conn0 -> [0,142,"isElementEnabled",{"id":"f9d9adc3-58df-446a-953d-eb793ac27025"}]
1465882610340   Marionette  TRACE   conn0 <- [1,142,null,{"value":true}]
1465882610343   Marionette  TRACE   conn0 -> [0,143,"clickElement",{"id":"f9d9adc3-58df-446a-953d-eb793ac27025"}]
1465882610372   Marionette  TRACE   conn0 <- [1,143,null,{}]
1465882610398   Marionette  TRACE   conn0 -> [0,144,"quitApplication",{"flags":["eForceQuit"]}]
1465882610399   Marionette  TRACE   conn0 <- [1,144,null,{}]
1465882610404   addons.xpi  DEBUG   Calling bootstrap method shutdown on @spritzfirefox version 4.1.5b
1465882610415   addons.xpi  DEBUG   Calling bootstrap method shutdown on e10srollout@mozilla.org version 1.0
1465882610416   addons.xpi  DEBUG   Calling bootstrap method shutdown on firefox@getpocket.com version 1.0.2
1465882610416   addons.xpi  DEBUG   Calling bootstrap method shutdown on loop@mozilla.org version 1.3.2

And I'm launching the MarionetteDriver by

System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
WebDriver driver = new MarionetteDriver();

Is there any capabilities to disable the logs


回答1:


Firefox is supposed to have an option to set the logging level for Marionette in the about:config property marionette.logging, but this apparently is not present in builds up to and including 47.

Apparently Marionette is not officially supported in build 47, which is unfortunate because FirefoxDriver also no longer works on this build either. Currently the only supported options are to downgrade (and use FirefoxDriver) or wait for updates.

It is theorized that this will be fixed in 47.0.1 or 48 and might already be in the nightlies.

Source: https://github.com/mozilla/geckodriver/issues/89




回答2:


You can use the following lines of code to not display the marionette 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();



回答3:


Here are all the ways I've seen to do it online, the only part that seems to do ANYTHING AT ALL is setting the browser log file to /dev/null :(

            // ----------- BEGIN NIGHTMARISH AMOUNT OF CODE TO SET THE LOG LEVEL ------------
            boolean detailedLogs = false;

            File profileDirectory = new File(Settings.FireFoxProfilePath);
            System.setProperty("webdriver.gecko.driver", "Drivers/geckodriver-linux64");
            //System.setProperty("webdriver.gecko.driver","src/main/resources/drivers/geckodriver.exe");
            if (!detailedLogs) {
                System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
                System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
            }
            FirefoxProfile profile = null;
            FirefoxOptions options = new FirefoxOptions();
            if (profileDirectory.exists()) {
                profile = new FirefoxProfile(profileDirectory);
                profile.setPreference("marionette.log.level", detailedLogs?"trace":"warn");
                profile.setPreference("marionette.logging", detailedLogs);
                options.setProfile(profile);
            }
            options.setLogLevel(FirefoxDriverLogLevel.WARN);
            LoggingPreferences logs = new LoggingPreferences();
            logs.enable(LogType.BROWSER, detailedLogs? Level.ALL : Level.WARNING);
            logs.enable(LogType.CLIENT, detailedLogs? Level.ALL : Level.WARNING);
            logs.enable(LogType.DRIVER, detailedLogs? Level.ALL : Level.WARNING);
            logs.enable(LogType.PERFORMANCE, detailedLogs? Level.ALL : Level.WARNING);
            logs.enable(LogType.PROFILER, detailedLogs? Level.ALL : Level.WARNING);
            logs.enable(LogType.SERVER, detailedLogs? Level.ALL : Level.WARNING);
            //LEGACY: DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
            //desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
            options.setCapability(CapabilityType.LOGGING_PREFS, logs);
            options.addPreference("extensions.logging.enabled", false);
            options.addPreference("marionette.log.level", detailedLogs?"trace":"warn");
            options.addPreference("marionette.logging", detailedLogs); // from https://github.com/mozilla/geckodriver/issues/89
            // ----------- END NIGHTMARISH AMOUNT OF CODE TO SET THE LOG LEVEL ------------
            driver = new FirefoxDriver(options);


来源:https://stackoverflow.com/questions/37803781/disable-log-trace-in-marionette-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!