当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
我正在推出MarionetteDriver
System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
WebDriver driver = new MarionetteDriver();
是否有任何禁用日志的功能
答案 0 :(得分:1)
Firefox应该可以选择在about:config属性marionette.logging
中设置Marionette的日志记录级别,但这显然不存在于包括47的构建中。
显然,构建版47中没有正式支持Marionette,这很不幸,因为FirefoxDriver也不再适用于此版本。目前唯一支持的选项是降级(并使用FirefoxDriver)或等待更新。
理论上,这将在47.0.1或48中修复,可能已经在夜间。
答案 1 :(得分:1)
您可以使用以下代码行来显示牵线木偶日志:
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();
答案 2 :(得分: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);