Java PhantomJSDriver disable all logs in console

和自甴很熟 提交于 2019-12-04 23:32:52
PhantomJSDriverService service = new PhantomJSDriverService.Builder()
        .usingPhantomJSExecutable(new File(VariableClass.phantomjs_file_path))
        .withLogFile(null)
        .build();
Hery

This one works for me.

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

Looking at the source files of org.openqa.selenium.phantomjs.PhanomJSDriverService while debugging, I discovered that it's actually ignoring documented log levels for ghostdriver itself. Doing this disables the bulk of ghostdriver output:

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

Seems that GhostDriver should be be updated to not log when

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

is used.

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