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

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

    2. C# Selenium/ChromeDriver 添加用户配置文件首选项

      时间:2023-09-14

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

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

              <tbody id='ihZ5R'></tbody>
            <tfoot id='ihZ5R'></tfoot>

              • <bdo id='ihZ5R'></bdo><ul id='ihZ5R'></ul>
                本文介绍了C# Selenium/ChromeDriver 添加用户配置文件首选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在使用 selenium + chrome 驱动程序运行测试时,我需要允许所有 cookie.

                I need to allow all cookies when running tests with selenium + chrome driver.

                我正在尝试使用 将此添加为配置文件首选项ChromeOptions.AddUserProfilePreference

                我不能 100% 确定允许所有 cookie 的首选项名称应该是什么.我已经引用了这个文档 https:///src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup

                I'm not 100% sure what the preference name should be to allow all cookies. I have referenced this doc https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup

                并在我的设置中尝试了以下方法,但没有达到预期的效果.

                and have tried the following in my setup but its not having the desired effect.

                options.AddUserProfilePreference("profile.block_third_party_cookies", false);
                

                options.AddUserProfilePreference("security.cookie_behavior", 0);```
                

                这是我的设置代码

                                        new DriverManager().SetUpDriver(new ChromeConfig());
                                        var options = new OpenQA.Selenium.Chrome.ChromeOptions { };
                                        options.AddArgument("–no-sandbox");
                                        options.AddArguments("-disable-gpu");
                                        options.AddArguments("-disable-dev-shm-usage");
                                        options.AddArgument("-incognito");
                                        options.AddArgument("-start-maximized");
                                        options.AddUserProfilePreference("security.cookie_behavior", 0);
                                        CurrentWebDriver = new ChromeDriver(options);
                

                推荐答案

                我遇到了同样的问题.我发现使用以下内容对我有帮助:

                I ran into the same issue. I found that using the following helped me:

                options.AddUserProfilePreference("profile.cookie_controls_mode", 0);
                

                帮助我找到这个的建议是检查 Chrome 首选项文件(在我的例子中 C:Users<user>AppDataLocalGoogleChromeUser DataDefaultPreferences).我保存了一个阻止 cookie 的副本,然后将设置更改为允许所有 cookie 并比较两个版本,这对我来说突出显示了受影响的控件.

                The advice that helped me find this, was to check the Chrome preferences file (in my case C:Users<user>AppDataLocalGoogleChromeUser DataDefaultPreferences). I saved a copy with cookies blocked, then changed the setting to allow all cookies and compared the two versions, and that highlighted the affected control for me.

                这篇关于C# Selenium/ChromeDriver 添加用户配置文件首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

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

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

                    • <tfoot id='cum2S'></tfoot>
                        <tbody id='cum2S'></tbody>