将选项传递给Chrome驱动程序selenium

将选项传递给Chrome驱动程序selenium,第1张

将选项传递给Chrome驱动程序selenium

在这张Chromedriver票证(关于该

silent
选件)的提示下,我查看了的来源
ChromeDriverService.java
,并找到了对的引用
"webdriver.chrome.logfile"

添加

-Dwebdriver.chrome.logfile="/dev/null"
到我的
java
命令后,日志再次变得可读:无用的ChromeDriver日志消失了,而
System.out.println
调用和异常仍显示在控制台中。

我从

java
以下参数开始(Linux / Mac):

DIR=path/to/dir/containing/selenium/and/stuffcd "$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=pathtodircontainingseleniumandstuffcd "%DIR%" && java -cp "%DIR%;%DIR%output;%DIR%binselenium-server-standalone-2.33.0.jar" ^-Dwebdriver.chrome.driver="%DIR%binchromedriver.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 voidmain(String[] args)
这将启动我的测试。

其他参数不言自明,请根据需要进行调整。为了方便起见(用于shell / batch脚本中),我在变量中声明了common目录

DIR



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5622295.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存