我试图禁用输出到控制台的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);
产量
Started ChromeDriver port=26703 version=23.0.1240.0
log=/Brett/workspace/TestNG/chromedriver.log
[1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends
[1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends
[1214/161331:ERROR:ipc_sync_channel.cc(378)] Canceling pending
sendsBlockquote
解决方法:
在这个Chromedriver ticket(关于静默选项)的暗示中,我查看了ChromeDriverService.java
的源代码,并找到了对“webdriver.chrome.logfile”的引用.
将-Dwebdriver.chrome.logfile =“/ dev / null”添加到我的java命令后,日志再次变得可读:无用的ChromeDriver日志已经消失,而系统.out.println调用和异常仍然显示在控制台中.
我使用以下参数启动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 / batch脚本中使用),我在变量DIR中声明了公共目录.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。