<legend id='Z8vju'><style id='Z8vju'><dir id='Z8vju'><q id='Z8vju'></q></dir></style></legend>

    1. <tfoot id='Z8vju'></tfoot>
    2. <small id='Z8vju'></small><noframes id='Z8vju'>

      <i id='Z8vju'><tr id='Z8vju'><dt id='Z8vju'><q id='Z8vju'><span id='Z8vju'><b id='Z8vju'><form id='Z8vju'><ins id='Z8vju'></ins><ul id='Z8vju'></ul><sub id='Z8vju'></sub></form><legend id='Z8vju'></legend><bdo id='Z8vju'><pre id='Z8vju'><center id='Z8vju'></center></pre></bdo></b><th id='Z8vju'></th></span></q></dt></tr></i><div id='Z8vju'><tfoot id='Z8vju'></tfoot><dl id='Z8vju'><fieldset id='Z8vju'></fieldset></dl></div>
          <bdo id='Z8vju'></bdo><ul id='Z8vju'></ul>
      1. 将选项传递给 chrome 驱动程序 selenium

        时间:2023-09-28

        • <bdo id='ibhRd'></bdo><ul id='ibhRd'></ul>

              <tbody id='ibhRd'></tbody>
            <tfoot id='ibhRd'></tfoot>
            • <small id='ibhRd'></small><noframes id='ibhRd'>

              <i id='ibhRd'><tr id='ibhRd'><dt id='ibhRd'><q id='ibhRd'><span id='ibhRd'><b id='ibhRd'><form id='ibhRd'><ins id='ibhRd'></ins><ul id='ibhRd'></ul><sub id='ibhRd'></sub></form><legend id='ibhRd'></legend><bdo id='ibhRd'><pre id='ibhRd'><center id='ibhRd'></center></pre></bdo></b><th id='ibhRd'></th></span></q></dt></tr></i><div id='ibhRd'><tfoot id='ibhRd'></tfoot><dl id='ibhRd'><fieldset id='ibhRd'></fieldset></dl></div>
              <legend id='ibhRd'><style id='ibhRd'><dir id='ibhRd'><q id='ibhRd'></q></dir></style></legend>

                  本文介绍了将选项传递给 chrome 驱动程序 selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试禁用 Chrome 控制台的输出.如果我通过 --start-maximized 选项它工作正常.我可能有错误的命令?

                  I am trying to disable the output to the console for chrome. If I pass the --start-maximized option it works fine. I may have the wrong command?

                  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日志=/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)] 取消挂起发送块引用

                  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(关于 silent 选项),我查看了 ChromeDriverService.java,找到了的引用"webdriver.chrome.logfile".

                  Hinted by this Chromedriver ticket (about the silent option), I looked in the source of ChromeDriverService.java, and found a reference to "webdriver.chrome.logfile".

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

                  After adding -Dwebdriver.chrome.logfile="/dev/null" to my java command, the logs became readable again: The usless ChromeDriver logs were gone, while theSystem.out.println calls and exceptions are still shown in the console.

                  我用以下参数启动java(Linux/Mac):

                  I start java with the following parameters (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:

                  If you're on Windows:

                  set DIR=path	odircontainingseleniumandstuff
                  cd "%DIR%" && java -cp "%DIR%;%DIR%output;%DIR%inselenium-server-standalone-2.33.0.jar" ^
                  -Dwebdriver.chrome.driver="%DIR%inchromedriver.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) 的类的名称 - 这会启动我的测试.


                  Explanation for the composition of my classpath (-cp): My tests are located in a directory at "$DIR/output". The Selenium jar file is placed in "$DIR/bin/selenium-server-standalone-2.33.0.jar". "AllTests" is the name of my class containing public static void main(String[] args) - this launches my tests.

                  其他参数不言自明,请根据需要进行调整.为方便起见(在 shell/批处理脚本中使用),我在变量 DIR 中声明了公共目录.

                  The other parameters are self-explanatory, adjust it to your needs. For convenience (used in a shell/batch script), I've declared the common directory in a variable DIR.

                  这篇关于将选项传递给 chrome 驱动程序 selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 Selenium WebDriver 在 Chrome 中激活 AdBlocke 下一篇:ChromeDriver:自定义 Chrome 可执行文件路径

                  相关文章

                  最新文章

                      <bdo id='Ix7uB'></bdo><ul id='Ix7uB'></ul>
                  1. <small id='Ix7uB'></small><noframes id='Ix7uB'>

                  2. <tfoot id='Ix7uB'></tfoot>
                    <legend id='Ix7uB'><style id='Ix7uB'><dir id='Ix7uB'><q id='Ix7uB'></q></dir></style></legend>
                    <i id='Ix7uB'><tr id='Ix7uB'><dt id='Ix7uB'><q id='Ix7uB'><span id='Ix7uB'><b id='Ix7uB'><form id='Ix7uB'><ins id='Ix7uB'></ins><ul id='Ix7uB'></ul><sub id='Ix7uB'></sub></form><legend id='Ix7uB'></legend><bdo id='Ix7uB'><pre id='Ix7uB'><center id='Ix7uB'></center></pre></bdo></b><th id='Ix7uB'></th></span></q></dt></tr></i><div id='Ix7uB'><tfoot id='Ix7uB'></tfoot><dl id='Ix7uB'><fieldset id='Ix7uB'></fieldset></dl></div>