我正在尝试禁用 chrome 控制台的输出。如果我通过 --start-maximized 选项,它就可以正常工作。我可能命令错误?
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--silent"));
chrome = new ChromeDriver(_chromeservice,capabilities);
我也尝试过
ChromeOptions options = new ChromeOptions();
options.addArguments("silent");
chrome = new ChromeDriver(options);
Output
已启动 ChromeDriver 端口=26703 版本=23.0.1240.0
日志=/Brett/workspace/TestNG/chromedriver.log
[1214/161331:错误:ipc_sync_channel.cc(378)] 取消挂起的发送
[1214/161331:错误:ipc_sync_channel.cc(378)] 取消挂起的发送
[1214/161331:错误:ipc_sync_channel.cc(378)] 取消挂起
发送块引用
以此暗示Chromedriver 票证(有关silent
选项),我查看了来源ChromeDriverService.java,并找到了参考"webdriver.chrome.logfile"
.
添加后-Dwebdriver.chrome.logfile="/dev/null"
to my java
命令后,日志再次可读:无用的 ChromeDriver 日志消失了,而System.out.println
调用和异常仍然显示在控制台中。
I start java
具有以下参数(Linux / Mac):
DIR=path/to/dir/containing/selenium/and/stuff
cd "$DIR" && java -cp "$DIR\
:$DIR/output\
:$DIR/bin/selenium-server-standalone-2.33.0.jar" \
-Dwebdriver.chrome.driver="$DIR/bin/chromedriver" \
-Dwebdriver.chrome.args="--disable-logging" \
-Dwebdriver.chrome.logfile="/dev/null" \
AllTests
如果您使用的是 Windows:
set DIR=path\to\dir\containing\selenium\and\stuff
cd "%DIR%" && java -cp "%DIR%;%DIR%\output;%DIR%\bin\selenium-server-standalone-2.33.0.jar" ^
-Dwebdriver.chrome.driver="%DIR%\bin\chromedriver.exe" ^
-Dwebdriver.chrome.args="--disable-logging" ^
-Dwebdriver.chrome.logfile=NUL ^
AllTests
我的类路径的组成说明(-cp
):我的测试位于“$DIR/output”目录中。 Selenium jar 文件位于“$DIR/bin/selenium-server-standalone-2.33.0.jar”中。 “AllTests”是我的班级名称,其中包含public static void main(String[] args)
- 这启动了我的测试。
其他参数都是不言自明的,根据您的需要进行调整。为了方便起见(在 shell/批处理脚本中使用),我在变量中声明了公共目录DIR
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)