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

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

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

        <small id='qomaz'></small><noframes id='qomaz'>

      1. 通过 Selenium Chromedriver 自动授予对 Chrome 48 中视频

        时间:2023-09-28

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

            <small id='yUzyT'></small><noframes id='yUzyT'>

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

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

                  本文介绍了通过 Selenium Chromedriver 自动授予对 Chrome 48 中视频和音频的访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想通过 Chromedriver 功能自动授予对 Chrome 中视频和音频的访问权限.

                  I would like to automatically grant access to video and audio in Chrome via Chromedriver capabilities.

                  基于 this(相当老的)答案,我尝试了以下方法:

                  Based on this (pretty old) answer I tried the following:

                  DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                  ChromeOptions options = new ChromeOptions();
                  Map<String, Object> prefs = new HashMap<>();
                  
                  // with this chrome still asks for permission
                  prefs.put("profile.managed_default_content_settings.media_stream", 1);
                  prefs.put("profile.managed_default_content_settings.media_stream_camera", 1);
                  prefs.put("profile.managed_default_content_settings.media_stream_mic", 1);
                  
                  // and this prevents chrome from starting
                  prefs.put("profile.content_settings.exceptions.media_stream_mic.https://*,*.setting", 1);
                  prefs.put("profile.content_settings.exceptions.media_stream_mic.https://*,*.last_used", 1);
                  prefs.put("profile.content_settings.exceptions.media_stream_camera.https://*,*.setting", 1);
                  prefs.put("profile.content_settings.exceptions.media_stream_camera.https://*,*.last_used", 1);
                  
                  // and this prevents chrome from starting as well
                  prefs.put("profile.content_settings.pattern_pairs.https://*,*.media_stream.video", "Allow");
                  prefs.put("profile.content_settings.pattern_pairs.https://*,*.media_stream.audio", "Allow");
                  
                  options.setExperimentalOption("prefs", prefs);
                  capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                  

                  关于如何正确授予权限的任何想法?

                  Any ideas on how to grant permissions correctly?

                  推荐答案

                  遇到了类似的问题,用这个解决了:

                  Faced similar issue, solved with this:

                  ChromeOptions options = new ChromeOptions();
                  options.addArguments("--use-fake-ui-for-media-stream=1");
                  driver = new ChromeDriver(options);
                  

                  您也可以使用此方法更改默认相机:

                  You can also change default camera using this method:

                  Map<String, Object> prefs = new HashMap<String, Object>();
                  prefs.put("media.default_video_capture_Device", "\\?\root#media#0002#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global");
                  options.setExperimentalOption("prefs", prefs);
                  

                  相机代码可以从设置窗口(使用开发工具检查)或Chrome目录中的首选项文件中获取.

                  Camera code could be obtained from settings window (inspect with dev tools) or from preferences file in Chrome directory.

                  这篇关于通过 Selenium Chromedriver 自动授予对 Chrome 48 中视频和音频的访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:RemoteWebDriver 抛出“org.openqa.selenium.SessionNotCreate 下一篇:chromedriver 在前台运行的 windows jenkins slave 上失败

                  相关文章

                  最新文章

                  <small id='tjQWq'></small><noframes id='tjQWq'>

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

                    <bdo id='tjQWq'></bdo><ul id='tjQWq'></ul>

                  1. <legend id='tjQWq'><style id='tjQWq'><dir id='tjQWq'><q id='tjQWq'></q></dir></style></legend>