5

启动时MarionetteDriver,它是每个操作的打印日志语句。像

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

我正在启动MarionetteDriverby

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

是否有任何功能可以禁用日志

4

4 回答 4

3

您可以使用以下代码行不显示木偶日志:

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();
于 2017-09-19T20:29:21.373 回答
1

Firefox 应该有一个选项可以在 about:config 属性中设置 Marionette 的日志记录级别marionette.logging,但这显然不存在于 47 及以下的构建中。

显然 Marionette 在 build 47 中没有得到官方支持,这很不幸,因为 FirefoxDriver 也不再适用于这个 build。目前唯一支持的选项是降级(并使用 FirefoxDriver)或等待更新。

理论上,这将在 47.0.1 或 48 中修复,并且可能已经在 nightlies 中。

来源:https ://github.com/mozilla/geckodriver/issues/89

于 2016-06-15T16:58:17.053 回答
0

这是我在网上看到的所有方法,唯一似乎可以做任何事情的部分是将浏览器日志文件设置为 /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);
于 2018-09-23T00:24:00.920 回答
0

为 2021 年,marionette.log.level移至remote.log.level,其值为大写且区分大小写。

请参阅: https ://firefox-source-docs.mozilla.org/testing/marionette/Prefs.html 和 https://firefox-source-docs.mozilla.org/remote/Prefs.html

于 2021-12-03T06:16:30.957 回答