当前位置: 首页 > 面试题库 >

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

万博涛
2023-03-14
问题内容

我正在尝试禁用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);

输出量

已启动的ChromeDriver端口= 26703版本= 23.0.1240.0 log = / Brett / workspace / TestNG
/ chromedriver.log
[1214/161331:ERROR:ipc_sync_channel.cc(378)]取消待处理的发送[1214/161331:ERROR:ipc_sync_channel.cc(
378)]取消挂起的发送[1214/161331:ERROR:ipc_sync_channel.cc(378)]取消挂起的sendsBlockquote


问题答案:

在这张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/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脚本中),我在变量中声明了common目录DIR



 类似资料:
  • 问题内容: 我正在尝试禁用Chrome控制台的输出。如果我通过–start-maximized选项,则可以正常工作。我可能输入了错误的命令? 我也试过 输出量 已启动的ChromeDriver端口= 26703版本= 23.0.1240.0日志= / Brett / workspace / TestNG / chromedriver.log [1214/161331:ERROR:ipc_sync_

  • 本文向大家介绍如何使用Python将选项传递给Selenium Chrome驱动程序?,包括了如何使用Python将选项传递给Selenium Chrome驱动程序?的使用技巧和注意事项,需要的朋友参考一下 我们可以使用Python将选项传递给Selenium Chrome驱动程序。这可以借助ChromeOptions和DesiredCapabilities类的帮助。对于ChromeOptions

  • 本文向大家介绍awk 使用-v选项将参数传递给程序,包括了awk 使用-v选项将参数传递给程序的使用技巧和注意事项,需要的朋友参考一下 示例 该选项-v后再加上变量= value形式的赋值可用于将参数传递给awk程序。下面的惩罚程序对此进行了说明,该程序的作用是写计数乘以句子“我不会在课堂上讲话”。在标准输出上。以下示例使用值100,该值在教师中非常流行: 可以重复使用-v标志来传递多个参数: 没

  • 问题内容: 在过去的两天里,我一直在寻找一种使用java设置chrome驱动程序的驱动程序首选项的方法,但是运气不好。 但是,我在ruby VIA RubyBindings中找到了一种解决方案,想知道是否可以使用Java等效行。 红宝石代码如下: 在搜索时,我发现chrome没有像FirefoxProfile类那样可以使用的探查器,因此我开始使用DesireCapabilities类。在进一步研究

  • 问题内容: 我正在尝试运行一个ruby文件,该文件将使用seleniumwebdriver启动chrome驱动程序。我有selenium独立服务器2.35.0。和chromedriver可执行文件已安装。我正在通过运行服务器来启动 两个会话正在启动,chrome驱动程序无法启动。 这是在我使用以下文件运行文件之后 我对此并不陌生,无法找出问题所在。而且,我也试图让它无头运行,所以我正在运行Xvfb

  • 我试图运行一个ruby文件,这将启动chrome驱动程序使用selenium WebDriver。我有selenium独立服务器2.35.0。和chromedriver可执行文件安装。我通过运行来启动服务器, 这是在我使用 我对此很陌生,不知道哪里出了问题。我也试图无头运行它,所以我有Xvfb运行。有人能帮我指出我犯的错误并启动chromedriver吗? 更新: 谁能帮我弄清楚出了什么问题吗?