本文介绍了如何使用Selenium和JavaFX禁用ChromeDriver的日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行我的应用程序时,java总是在写如下内容:
When I run my app java is always writing things like:
Starting ChromeDriver 2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5) on port 19943
Only local connections are allowed.
сен 27, 2018 11:18:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
如何预防?我现在不需要了.
How can I prevent it? I don't need it now.
推荐答案
您提到的这些日志是默认的 ChromeDriver 启动日志.由于在创建会话之前未配置日志级别,因此您无法控制这些日志的生成.
These logs you mentioned are the default ChromeDriver startup logs. As the log level is not configured until a session is created you don't have any control over the generation of these logs.
在执行测试期间继续查看更少的日志,您只需将-silent 参数传递给 chromedriver服务器,如下所示:
Moving forward, during Test Execution to see lesser logs you can simply pass --silent argument to the chromedriver server as follows:
-
代码块:
Code Block:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class A_Chrome_General
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
System.setProperty("webdriver.chrome.silentLogging", "true");
WebDriver driver = new ChromeDriver();
driver.get("https://stackoverflow.com");
System.out.println("Page Title is : "+driver.getTitle());
driver.quit();
}
}
您可以在以下位置找到几个相关的详细讨论:
You can find a couple of relevant detailed discussions in:
这篇关于如何使用Selenium和JavaFX禁用ChromeDriver的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!