Java PhantomJSDriver禁用控制台中的所有日志

我正在使用Selenium开发一个小型控制台应用程序,我需要关闭它的所有日志。

我试过了phantomJSDriver.setLogLevel(Level.OFF); 但它不起作用。 我需要帮助。

如何禁用使用Selenium和Phantomjs(GhostDriver)的控制台应用程序中的所有日志?

 PhantomJSDriverService service = new PhantomJSDriverService.Builder() .usingPhantomJSExecutable(new File(VariableClass.phantomjs_file_path)) .withLogFile(null) .build(); 

这个对我有用。

 DesiredCapabilities dcap = new DesiredCapabilities(); String[] phantomArgs = new String[] { "--webdriver-loglevel=NONE" }; dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs); PhantomJSDriver phantomDriver = new PhantomJSDriver(dcap); 

在调试时查看org.openqa.selenium.phantomjs.PhanomJSDriverService的源文件,我发现它实际上忽略了ghostdriver本身的文档日志级别。 这样做会禁用大量的ghostdriver输出:

 Logger.getLogger(PhantomJSDriverService.class.getName()).setLevel(Level.OFF); 

似乎应该更新GhostDriver以便不记录时间

 phantomJSCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARG‌​S, "--webdriver-loglevel=NONE"); 

用来。