Java 使用phantom js和selenium的无头测试中不必要的日志

Java 使用phantom js和selenium的无头测试中不必要的日志,java,selenium,selenium-webdriver,phantomjs,headless,Java,Selenium,Selenium Webdriver,Phantomjs,Headless,在使用phantom js执行无头测试时,我收到了太多不必要的红色日志 如何删除所有红色日志 以下是抑制信息日志所需执行的操作: File src = new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe"); System.setProperty("phantomjs.binary.path", src.getAbsolutePath()); DesiredCapabilities dcap = new Des

在使用
phantom js
执行无头测试时,我收到了太多不必要的红色日志

如何删除所有红色日志


以下是抑制信息日志所需执行的操作:

File src = new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path", src.getAbsolutePath());

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

driver.get("https://www.facebook.com/");

让我知道它是否适合您。

我的程序没有任何主方法。所以这就是投掷错误。在哪里写这封信code@heardm您可以在任何地方使用代码。如果您使用的是TestNG,那么可以将代码放在任何被测试的方法或类似的注释中。根据你的具体要求提出一个新问题,我很乐意帮助你。谢谢
File src = new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path", src.getAbsolutePath());

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

driver.get("https://www.facebook.com/");