且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-12-05 19:19:25

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

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.